From 7167ce41b61d2ba2cdb526777a4233eb84a3b66a Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Sat, 6 Dec 2014 17:33:25 -0500 Subject: Imported Upstream version 2.99.6 --- .../coreSQLiteStudio/completioncomparer.h | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 SQLiteStudio3/coreSQLiteStudio/completioncomparer.h (limited to 'SQLiteStudio3/coreSQLiteStudio/completioncomparer.h') diff --git a/SQLiteStudio3/coreSQLiteStudio/completioncomparer.h b/SQLiteStudio3/coreSQLiteStudio/completioncomparer.h new file mode 100644 index 0000000..d482f3a --- /dev/null +++ b/SQLiteStudio3/coreSQLiteStudio/completioncomparer.h @@ -0,0 +1,74 @@ +#ifndef COMPLETIONCOMPARER_H +#define COMPLETIONCOMPARER_H + +#include "expectedtoken.h" +#include "dialect.h" +#include "selectresolver.h" + +class CompletionHelper; + +class CompletionComparer +{ + public: + explicit CompletionComparer(CompletionHelper* helper); + + bool operator()(const ExpectedTokenPtr& token1, const ExpectedTokenPtr& token2); + + private: + CompletionHelper* helper = nullptr; + Dialect dialect; + /** + * @brief contextDatabases + * Context objects are any names mentioned anywhere in the query at the same level as completion takes place. + * The level means the sub-query level, for example in case of sub selects. + */ + QStringList contextDatabases; + QStringList contextTables; + QStringList contextColumns; + + /** + * @brief parentContextDatabases + * Parent context objects are any names mentioned anywhere in the the query at all upper levels. + */ + QStringList parentContextDatabases; + QStringList parentContextTables; + QStringList parentContextColumns; + QList resultColumns; + + /** + * @brief availableTableNames + * Names of all tables mentioned in FROM clause in the current and all parent select cores. + */ + QStringList availableTableNames; + + void init(); + bool initSelect(); + bool compareColumns(const ExpectedTokenPtr& token1, const ExpectedTokenPtr& token2); + bool compareColumnsForSelectResCol(const ExpectedTokenPtr& token1, const ExpectedTokenPtr& token2, bool* result); + bool compareColumnsForUpdateCol(const ExpectedTokenPtr& token1, const ExpectedTokenPtr& token2, bool* result); + bool compareColumnsForDeleteCol(const ExpectedTokenPtr& token1, const ExpectedTokenPtr& token2, bool* result); + bool compareColumnsForCreateTable(const ExpectedTokenPtr& token1, const ExpectedTokenPtr& token2, bool* result); + bool compareTables(const ExpectedTokenPtr& token1, const ExpectedTokenPtr& token2); + bool compareIndexes(const ExpectedTokenPtr& token1, const ExpectedTokenPtr& token2); + bool compareTriggers(const ExpectedTokenPtr& token1, const ExpectedTokenPtr& token2); + bool compareViews(const ExpectedTokenPtr& token1, const ExpectedTokenPtr& token2); + bool compareDatabases(const ExpectedTokenPtr& token1, const ExpectedTokenPtr& token2); + bool compareValues(const ExpectedTokenPtr& token1, const ExpectedTokenPtr& token2, bool handleSystemNames = false); + bool compareValues(const QString& token1, const QString& token2, bool handleSystemNames = false); + bool compareByContext(const QString &token1, const QString &token2, + const QStringList& contextValues, bool* ok = nullptr); + bool compareByContext(const QString &token1, const QString &token2, + const QList& contextValues, bool* ok = nullptr); + bool compareByContext(const QString &token1, const QString &token2, + const QStringList& contextValues, bool handleSystemNames, bool* ok = nullptr); + bool compareByContext(const QString &token1, const QString &token2, + const QList& contextValues, bool handleSystemNames, bool* ok = nullptr); + bool compareByContextOnly(const QString &token1, const QString &token2, + const QStringList& contextValues, bool handleSystemNames, bool* ok); + bool isTokenOnAvailableList(const ExpectedTokenPtr& token); + bool isTokenOnParentAvailableList(const ExpectedTokenPtr& token); + bool isTokenOnResultColumns(const ExpectedTokenPtr& token); + static bool isTokenOnColumnList(const ExpectedTokenPtr& token, const QList& columnList); +}; + +#endif // COMPLETIONCOMPARER_H -- cgit v1.2.3