From d9aa870e5d509cc7309ab82dd102a937ab58613a Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Thu, 9 Feb 2017 04:36:04 -0500 Subject: Imported Upstream version 3.1.1+dfsg1 --- .../SqlEnterpriseFormatter.pro | 6 ++- .../SqlEnterpriseFormatter_de.ts | 2 +- .../SqlEnterpriseFormatter_es.ts | 2 +- .../SqlEnterpriseFormatter_fr.qm | Bin 5804 -> 6264 bytes .../SqlEnterpriseFormatter_fr.ts | 45 +++++++++------------ .../SqlEnterpriseFormatter_it.ts | 2 +- .../SqlEnterpriseFormatter_pl.qm | Bin 5528 -> 6121 bytes .../SqlEnterpriseFormatter_pl.ts | 2 +- .../SqlEnterpriseFormatter_pt_BR.ts | 2 +- .../SqlEnterpriseFormatter_ru.ts | 2 +- .../SqlEnterpriseFormatter_sk.ts | 2 +- .../SqlEnterpriseFormatter_zh_CN.ts | 2 +- .../SqlEnterpriseFormatter/formatcreatetrigger.cpp | 2 +- Plugins/SqlEnterpriseFormatter/formatexpr.cpp | 33 ++++++++++++--- Plugins/SqlEnterpriseFormatter/formatexpr.h | 4 ++ Plugins/SqlEnterpriseFormatter/formatstatement.cpp | 2 +- Plugins/SqlEnterpriseFormatter/formatstatement.h | 2 +- .../sqlenterpriseformatter.qrc | 6 +++ 18 files changed, 73 insertions(+), 43 deletions(-) (limited to 'Plugins/SqlEnterpriseFormatter') diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter.pro b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter.pro index 5af5bfa..2d5b88c 100644 --- a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter.pro +++ b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter.pro @@ -100,10 +100,10 @@ RESOURCES += \ sqlenterpriseformatter.qrc -TRANSLATIONS += SqlEnterpriseFormatter_it.ts \ +TRANSLATIONS += SqlEnterpriseFormatter_de.ts \ + SqlEnterpriseFormatter_it.ts \ SqlEnterpriseFormatter_zh_CN.ts \ SqlEnterpriseFormatter_sk.ts \ - SqlEnterpriseFormatter_de.ts \ SqlEnterpriseFormatter_ru.ts \ SqlEnterpriseFormatter_pt_BR.ts \ SqlEnterpriseFormatter_fr.ts \ @@ -122,3 +122,5 @@ TRANSLATIONS += SqlEnterpriseFormatter_it.ts \ + + diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_de.ts b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_de.ts index b391360..10e3b39 100644 --- a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_de.ts +++ b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_de.ts @@ -1,6 +1,6 @@ - + QObject diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_es.ts b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_es.ts index 4910c3f..cd19bf1 100644 --- a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_es.ts +++ b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_es.ts @@ -1,6 +1,6 @@ - + QObject diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_fr.qm b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_fr.qm index 6e8f481..40423d9 100644 Binary files a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_fr.qm and b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_fr.qm differ diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_fr.ts b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_fr.ts index 6e90f84..5468163 100644 --- a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_fr.ts +++ b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_fr.ts @@ -21,17 +21,17 @@ Line up keywords in multi-line queries - Ligne de most clé en majuscule dans une requête multiligne + Ligne de mots-clefs en majuscule dans une requête multiligne Indent contents of parenthesis block - Indenté le contenu du block entre parenthèses + Indenter le contenu du bloc entre parenthèses Tab size: - Dimension Tab: + taille d’indentation : @@ -41,12 +41,12 @@ Before opening parenthesis in column definitions - Avant l’ouverture des parenthèses dans la définition de la colonne + Avant l’ouverture des parenthèses dans la définition de la colonne After opening parenthesis in column definitions - Après l’ouverture des parenthèses dans la définition de la colonne + Après l’ouverture des parenthèses dans la définition de la colonne @@ -61,27 +61,27 @@ Before opening parenthesis in expressions - Avant l’ouverture des parenthèses dans l’expression + Avant l’ouverture des parenthèses dans l’expression After opening parenthesis in expressions - Après l’ouverture des parenthèses dans l’expression + Après l’ouverture des parenthèses dans l’expression Before closing parenthesis in expressions - Avant la fermeture des parenthèses dans l’expression + Avant la fermeture des parenthèses dans l’expression After closing parenthesis in expressions - Après la fermeture des parenthèses dans l’expression + Après la fermeture des parenthèses dans l’expression After JOIN keywords in FROM clause - Après le mot clé JOIN dans la clause FROM + Après le mot-clef JOIN dans la clause FROM @@ -96,7 +96,7 @@ After comma in expressions - Après la virgule dans l’exoression + Après la virgule dans l’exoression @@ -127,12 +127,12 @@ Before opening parenthesis - Avant l’ouverture des parenthèses + Avant l’ouverture des parenthèses After opening parenthesis - Après l’ouverture des parenthèses + Après l’ouverture des parenthèses @@ -147,7 +147,7 @@ No space between SQL function name and opening parenthesis - aucun espance entre le nom de la fonction SQL et l’ouverture des paranthèses + aucun espance entre le nom de la fonction SQL et l’ouverture des paranthèses @@ -182,12 +182,12 @@ Preferred name wrapper - Preferred name wrapper + Échappement préféré Always use name wrapping - Always use name wrapping + Toujours échapper les identifiants @@ -197,32 +197,27 @@ Uppercase keywords - Mots clé en majuscule + Mots-clefs en majuscule Comments - + Commentaires Preferred comment marker (where possible): - - - SqlEnterpriseFormatter.CommentMarkers - - Move all comments to the line end - + Déplacer tous les commentaires en fin de ligne Line up comments at the line end - + Alignez les commentaires en fin de ligne diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_it.ts b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_it.ts index 93a7ba6..d37b3a0 100644 --- a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_it.ts +++ b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_it.ts @@ -1,6 +1,6 @@ - + QObject diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_pl.qm b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_pl.qm index ea184fe..7c215a2 100644 Binary files a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_pl.qm and b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_pl.qm differ diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_pl.ts b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_pl.ts index f85f8f0..0acec1b 100644 --- a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_pl.ts +++ b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_pl.ts @@ -1,6 +1,6 @@ - + QObject diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_pt_BR.ts b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_pt_BR.ts index 920e9cc..5dcd199 100644 --- a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_pt_BR.ts +++ b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_pt_BR.ts @@ -1,6 +1,6 @@ - + QObject diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ru.ts b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ru.ts index 9436651..8e942c9 100644 --- a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ru.ts +++ b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ru.ts @@ -1,6 +1,6 @@ - + QObject diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_sk.ts b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_sk.ts index ff7f588..9d78cfc 100644 --- a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_sk.ts +++ b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_sk.ts @@ -1,6 +1,6 @@ - + QObject diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_zh_CN.ts b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_zh_CN.ts index 0405ee5..ad44b3c 100644 --- a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_zh_CN.ts +++ b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_zh_CN.ts @@ -1,6 +1,6 @@ - + QObject diff --git a/Plugins/SqlEnterpriseFormatter/formatcreatetrigger.cpp b/Plugins/SqlEnterpriseFormatter/formatcreatetrigger.cpp index 6eb8b21..ee45541 100644 --- a/Plugins/SqlEnterpriseFormatter/formatcreatetrigger.cpp +++ b/Plugins/SqlEnterpriseFormatter/formatcreatetrigger.cpp @@ -107,7 +107,7 @@ void FormatCreateTriggerEvent::formatInternal() withLinedUpKeyword("DELETE", TRIGGER_MARK); break; case SqliteCreateTrigger::Event::UPDATE_OF: - withLinedUpKeyword("UPDATE OF", TRIGGER_MARK).withIdList(ev->columnNames); + withLinedUpKeyword("UPDATE OF", TRIGGER_MARK).withIdList(ev->columnNames, "updateOfCols"); break; case SqliteCreateTrigger::Event::null: break; diff --git a/Plugins/SqlEnterpriseFormatter/formatexpr.cpp b/Plugins/SqlEnterpriseFormatter/formatexpr.cpp index b1a36b5..e79995f 100644 --- a/Plugins/SqlEnterpriseFormatter/formatexpr.cpp +++ b/Plugins/SqlEnterpriseFormatter/formatexpr.cpp @@ -6,6 +6,8 @@ #include "parser/ast/sqliteraise.h" #include "sqlenterpriseformatter.h" +QRegularExpression FormatExpr::WORD_ONLY_RE = QRegularExpression("^[a-zA-Z]+$"); + FormatExpr::FormatExpr(SqliteExpr* expr) : expr(expr) { @@ -51,7 +53,11 @@ void FormatExpr::formatInternal() { // Operator can be a keyword QString opStr = cfg->SqlEnterpriseFormatter.UppercaseKeywords.get() ? expr->unaryOp.toUpper() : expr->unaryOp.toLower(); - withOperator(opStr, FormatToken::Flag::NO_SPACE_BEFORE|FormatToken::Flag::NO_SPACE_AFTER); + if (WORD_ONLY_RE.match(opStr).hasMatch()) + withKeyword(opStr); + else + withOperator(opStr, FormatToken::Flag::NO_SPACE_AFTER); + withStatement(expr->expr1, "unaryOp"); break; } @@ -148,6 +154,11 @@ void FormatExpr::formatInternal() withKeyword("BETWEEN").withStatement(expr->expr2, "between1").withKeyword("AND").withStatement(expr->expr3, "between2"); break; } + case SqliteExpr::Mode::ROW_VALUE: + { + withParExprLeft().withStatementList(expr->exprList, FormatToken::Flag::NO_NEWLINE_AFTER).withParExprRight(); + break; + } case SqliteExpr::Mode::IN: { withStatement(expr->expr1); @@ -183,22 +194,34 @@ void FormatExpr::formatInternal() withStatement(expr->expr1, "case"); bool then = false; - foreach (SqliteExpr* expr, expr->exprList) + for (SqliteExpr* innerExpr : expr->exprList) { if (then) withKeyword("THEN"); else withKeyword("WHEN"); - withIncrIndent("case"); - withStatement(expr); + if (expr->expr1) + withIncrIndent("case"); + else + withIncrIndent(); + + withStatement(innerExpr); withDecrIndent(); then = !then; } if (expr->expr2) - withKeyword("ELSE").withIncrIndent("case").withStatement(expr->expr2).withDecrIndent(); + { + withKeyword("ELSE"); + if (expr->expr1) + withIncrIndent("case"); + else + withIncrIndent(); + + withStatement(expr->expr2).withDecrIndent(); + } withKeyword("END"); break; diff --git a/Plugins/SqlEnterpriseFormatter/formatexpr.h b/Plugins/SqlEnterpriseFormatter/formatexpr.h index 2712adc..bafe442 100644 --- a/Plugins/SqlEnterpriseFormatter/formatexpr.h +++ b/Plugins/SqlEnterpriseFormatter/formatexpr.h @@ -1,8 +1,10 @@ #ifndef FORMATEXPR_H #define FORMATEXPR_H +#include #include "formatstatement.h" + class SqliteExpr; class FormatExpr : public FormatStatement @@ -14,6 +16,8 @@ class FormatExpr : public FormatStatement void formatInternal(); private: + static QRegularExpression WORD_ONLY_RE; + SqliteExpr* expr = nullptr; }; diff --git a/Plugins/SqlEnterpriseFormatter/formatstatement.cpp b/Plugins/SqlEnterpriseFormatter/formatstatement.cpp index 9702d32..2faaa16 100644 --- a/Plugins/SqlEnterpriseFormatter/formatstatement.cpp +++ b/Plugins/SqlEnterpriseFormatter/formatstatement.cpp @@ -600,7 +600,7 @@ QString FormatStatement::detokenize() case FormatToken::FLOAT: { applyIndent(); - line += doubleToString(token->value.toDouble()); + line += doubleToString(token->value); break; } case FormatToken::OPERATOR: diff --git a/Plugins/SqlEnterpriseFormatter/formatstatement.h b/Plugins/SqlEnterpriseFormatter/formatstatement.h index 427efe9..171b2a2 100644 --- a/Plugins/SqlEnterpriseFormatter/formatstatement.h +++ b/Plugins/SqlEnterpriseFormatter/formatstatement.h @@ -139,7 +139,7 @@ class FormatStatement markAndKeepIndent(indentName); bool first = true; - foreach (T* stmt, stmtList) + for (T* stmt : stmtList) { if (!first) withSeparator(sep, flags); diff --git a/Plugins/SqlEnterpriseFormatter/sqlenterpriseformatter.qrc b/Plugins/SqlEnterpriseFormatter/sqlenterpriseformatter.qrc index 00b290f..839720f 100644 --- a/Plugins/SqlEnterpriseFormatter/sqlenterpriseformatter.qrc +++ b/Plugins/SqlEnterpriseFormatter/sqlenterpriseformatter.qrc @@ -3,6 +3,9 @@ sqlenterpriseformatter.ui + SqlEnterpriseFormatter_de.qm + + SqlEnterpriseFormatter_pl.qm SqlEnterpriseFormatter_ru.qm SqlEnterpriseFormatter_fr.qm @@ -10,3 +13,6 @@ SqlEnterpriseFormatter_zh_CN.qm + + + -- cgit v1.2.3