diff options
| author | 2015-02-22 14:06:38 -0500 | |
|---|---|---|
| committer | 2015-02-22 14:06:38 -0500 | |
| commit | 6d42c08a54f15ddfdd8ee73643e3ddf8907bccc2 (patch) | |
| tree | 0a6554677b6a7fea5c81134c0804f0acdb00e632 /SQLiteStudio3/coreSQLiteStudio/completionhelper.cpp | |
| parent | a0cf2bb71de2b70a2b293c4ce907ecaaf24275bf (diff) | |
| parent | 306d6d3ca9c9ad774d19135681a7f9805f77035f (diff) | |
Merge tag 'upstream/3.0.3'
Upstream version 3.0.3
# gpg: Signature made Sun 22 Feb 2015 02:06:37 PM EST using RSA key ID EBE9BD91
# gpg: Good signature from "Unit 193 <unit193@gmail.com>"
# gpg: aka "Unit 193 <unit193@ninthfloor.org>"
# gpg: aka "Unit 193 <unit193@ubuntu.com>"
# gpg: aka "Unit 193 <unit193@ninthfloor.com>"
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/completionhelper.cpp')
| -rw-r--r-- | SQLiteStudio3/coreSQLiteStudio/completionhelper.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/SQLiteStudio3/coreSQLiteStudio/completionhelper.cpp b/SQLiteStudio3/coreSQLiteStudio/completionhelper.cpp index 99eb334..528df73 100644 --- a/SQLiteStudio3/coreSQLiteStudio/completionhelper.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/completionhelper.cpp @@ -1029,9 +1029,6 @@ void CompletionHelper::parseFullSql() { Dialect dialect = db->getDialect(); - Parser parser(dialect); - parser.setLemonDebug(enableLemonDebug); - QString sql = fullSql; // Selecting query at cursor position @@ -1046,11 +1043,30 @@ void CompletionHelper::parseFullSql() query += ";"; // Parsing query - if (parser.parse(query, true) && !parser.getQueries().isEmpty()) + Parser parser(dialect); + parser.setLemonDebug(enableLemonDebug); + if (tryToParse(&parser, query)) + return; + + // Second try - handling open parenthesis for expr (which could not be handled by the grammar, because of bug #2755) + parser.setLemonDebug(false); // avoid spamming with lemon debug + QString truncatedSql = sql.left(cursorPosition); + query = getQueryWithPosition(truncatedSql, cursorPosition, dialect); + query += ");"; + + if (tryToParse(&parser, query)) + return; +} + +bool CompletionHelper::tryToParse(Parser* parser, const QString& query) +{ + if (parser->parse(query, true) && !parser->getQueries().isEmpty()) { - parsedQuery = parser.getQueries().first(); + parsedQuery = parser->getQueries().first(); originalParsedQuery = SqliteQueryPtr(dynamic_cast<SqliteQuery*>(parsedQuery->clone())); + return true; } + return false; } void CompletionHelper::sort(QList<ExpectedTokenPtr> &resultsSoFar) |
