diff options
| author | 2014-12-06 17:33:25 -0500 | |
|---|---|---|
| committer | 2014-12-06 17:33:25 -0500 | |
| commit | 7167ce41b61d2ba2cdb526777a4233eb84a3b66a (patch) | |
| tree | a35c14143716e1f2c98f808c81f89426045a946f /SQLiteStudio3/coreSQLiteStudio/completioncomparer.h | |
Imported Upstream version 2.99.6upstream/2.99.6
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/completioncomparer.h')
| -rw-r--r-- | SQLiteStudio3/coreSQLiteStudio/completioncomparer.h | 74 |
1 files changed, 74 insertions, 0 deletions
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<SelectResolver::Column> 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<QStringList>& 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<QStringList>& 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<SelectResolver::Column>& columnList); +}; + +#endif // COMPLETIONCOMPARER_H |
