|
@@ -2170,6 +2170,33 @@ const initSqlParser = function(parser) {
|
|
|
return loc;
|
|
return loc;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ parser.addNewDatabaseLocation = function (location, identifierChain) {
|
|
|
|
|
+ parser.yy.definitions.push({
|
|
|
|
|
+ type: 'database',
|
|
|
|
|
+ location: adjustLocationForCursor(location),
|
|
|
|
|
+ identifierChain: identifierChain
|
|
|
|
|
+ })
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ parser.addNewTableLocation = function (location, identifierChain, colSpec) {
|
|
|
|
|
+ var columns = [];
|
|
|
|
|
+ if (colSpec) {
|
|
|
|
|
+ colSpec.forEach(function (col) {
|
|
|
|
|
+ columns.push({
|
|
|
|
|
+ identifierChain: [ col.identifier ], // TODO: Complex
|
|
|
|
|
+ type: col.type,
|
|
|
|
|
+ location: adjustLocationForCursor(col.location)
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ parser.yy.definitions.push({
|
|
|
|
|
+ type: 'table',
|
|
|
|
|
+ location: adjustLocationForCursor(location),
|
|
|
|
|
+ identifierChain: identifierChain,
|
|
|
|
|
+ columns: columns
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
parser.addColRefToVariableIfExists = function(left, right) {
|
|
parser.addColRefToVariableIfExists = function(left, right) {
|
|
|
if (
|
|
if (
|
|
|
left &&
|
|
left &&
|
|
@@ -2269,6 +2296,7 @@ const initSqlParser = function(parser) {
|
|
|
parser.yy.result = { locations: [] };
|
|
parser.yy.result = { locations: [] };
|
|
|
parser.yy.lowerCase = false;
|
|
parser.yy.lowerCase = false;
|
|
|
parser.yy.locations = [];
|
|
parser.yy.locations = [];
|
|
|
|
|
+ parser.yy.definitions = [];
|
|
|
parser.yy.allLocations = [];
|
|
parser.yy.allLocations = [];
|
|
|
parser.yy.subQueries = [];
|
|
parser.yy.subQueries = [];
|
|
|
parser.yy.errors = [];
|
|
parser.yy.errors = [];
|
|
@@ -2388,6 +2416,7 @@ const initSqlParser = function(parser) {
|
|
|
return b.type.localeCompare(a.type);
|
|
return b.type.localeCompare(a.type);
|
|
|
});
|
|
});
|
|
|
parser.yy.result.locations = parser.yy.allLocations;
|
|
parser.yy.result.locations = parser.yy.allLocations;
|
|
|
|
|
+ parser.yy.result.definitions = parser.yy.definitions;
|
|
|
|
|
|
|
|
parser.yy.result.locations.forEach(location => {
|
|
parser.yy.result.locations.forEach(location => {
|
|
|
delete location.linked;
|
|
delete location.linked;
|
|
@@ -2452,62 +2481,64 @@ const initSqlParser = function(parser) {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const SYNTAX_PARSER_NOOP_FUNCTIONS = [
|
|
const SYNTAX_PARSER_NOOP_FUNCTIONS = [
|
|
|
- 'prepareNewStatement',
|
|
|
|
|
- 'addCommonTableExpressions',
|
|
|
|
|
- 'pushQueryState',
|
|
|
|
|
- 'popQueryState',
|
|
|
|
|
- 'suggestSelectListAliases',
|
|
|
|
|
- 'suggestValueExpressionKeywords',
|
|
|
|
|
- 'getSelectListKeywords',
|
|
|
|
|
- 'getValueExpressionKeywords',
|
|
|
|
|
|
|
+ 'addAsteriskLocation',
|
|
|
|
|
+ 'addClauseLocation',
|
|
|
'addColRefIfExists',
|
|
'addColRefIfExists',
|
|
|
- 'selectListNoTableSuggest',
|
|
|
|
|
- 'suggestJoinConditions',
|
|
|
|
|
- 'suggestJoins',
|
|
|
|
|
- 'valueExpressionSuggest',
|
|
|
|
|
- 'applyTypeToSuggestions',
|
|
|
|
|
|
|
+ 'addColRefToVariableIfExists',
|
|
|
|
|
+ 'addColumnAliasLocation',
|
|
|
|
|
+ 'addColumnLocation',
|
|
|
|
|
+ 'addCommonTableExpressions',
|
|
|
|
|
+ 'addCteAliasLocation',
|
|
|
|
|
+ 'addDatabaseLocation',
|
|
|
|
|
+ 'addFileLocation',
|
|
|
|
|
+ 'addFunctionLocation',
|
|
|
|
|
+ 'addNewDatabaseLocation',
|
|
|
|
|
+ 'addNewTableLocation',
|
|
|
|
|
+ 'addStatementLocation',
|
|
|
|
|
+ 'addStatementTypeLocation',
|
|
|
|
|
+ 'addSubqueryAliasLocation',
|
|
|
|
|
+ 'addTableAliasLocation',
|
|
|
|
|
+ 'addTableLocation',
|
|
|
|
|
+ 'addTablePrimary',
|
|
|
|
|
+ 'addUnknownLocation',
|
|
|
|
|
+ 'addVariableLocation',
|
|
|
'applyArgumentTypesToSuggestions',
|
|
'applyArgumentTypesToSuggestions',
|
|
|
|
|
+ 'applyTypeToSuggestions',
|
|
|
|
|
+ 'checkForKeywords',
|
|
|
|
|
+ 'checkForSelectListKeywords',
|
|
|
'commitLocations',
|
|
'commitLocations',
|
|
|
- 'identifyPartials',
|
|
|
|
|
|
|
+ 'firstDefined',
|
|
|
|
|
+ 'getSelectListKeywords',
|
|
|
'getSubQuery',
|
|
'getSubQuery',
|
|
|
- 'addTablePrimary',
|
|
|
|
|
- 'suggestFileFormats',
|
|
|
|
|
- 'suggestDdlAndDmlKeywords',
|
|
|
|
|
- 'checkForSelectListKeywords',
|
|
|
|
|
- 'checkForKeywords',
|
|
|
|
|
- 'suggestKeywords',
|
|
|
|
|
- 'suggestColRefKeywords',
|
|
|
|
|
- 'suggestTablesOrColumns',
|
|
|
|
|
- 'suggestFunctions',
|
|
|
|
|
|
|
+ 'getValueExpressionKeywords',
|
|
|
|
|
+ 'identifyPartials',
|
|
|
|
|
+ 'popQueryState',
|
|
|
|
|
+ 'prepareNewStatement',
|
|
|
|
|
+ 'pushQueryState',
|
|
|
|
|
+ 'selectListNoTableSuggest',
|
|
|
'suggestAggregateFunctions',
|
|
'suggestAggregateFunctions',
|
|
|
'suggestAnalyticFunctions',
|
|
'suggestAnalyticFunctions',
|
|
|
|
|
+ 'suggestColRefKeywords',
|
|
|
'suggestColumns',
|
|
'suggestColumns',
|
|
|
|
|
+ 'suggestDatabases',
|
|
|
|
|
+ 'suggestDdlAndDmlKeywords',
|
|
|
|
|
+ 'suggestFileFormats',
|
|
|
|
|
+ 'suggestFilters',
|
|
|
|
|
+ 'suggestFunctions',
|
|
|
'suggestGroupBys',
|
|
'suggestGroupBys',
|
|
|
|
|
+ 'suggestHdfs',
|
|
|
'suggestIdentifiers',
|
|
'suggestIdentifiers',
|
|
|
- 'suggestOrderBys',
|
|
|
|
|
- 'suggestFilters',
|
|
|
|
|
|
|
+ 'suggestJoinConditions',
|
|
|
|
|
+ 'suggestJoins',
|
|
|
'suggestKeyValues',
|
|
'suggestKeyValues',
|
|
|
|
|
+ 'suggestKeywords',
|
|
|
|
|
+ 'suggestOrderBys',
|
|
|
|
|
+ 'suggestSelectListAliases',
|
|
|
'suggestTables',
|
|
'suggestTables',
|
|
|
- 'addFunctionLocation',
|
|
|
|
|
- 'addStatementLocation',
|
|
|
|
|
- 'firstDefined',
|
|
|
|
|
- 'addClauseLocation',
|
|
|
|
|
- 'addStatementTypeLocation',
|
|
|
|
|
- 'addFileLocation',
|
|
|
|
|
- 'addDatabaseLocation',
|
|
|
|
|
- 'addColumnAliasLocation',
|
|
|
|
|
- 'addTableAliasLocation',
|
|
|
|
|
- 'addSubqueryAliasLocation',
|
|
|
|
|
- 'addTableLocation',
|
|
|
|
|
- 'addAsteriskLocation',
|
|
|
|
|
- 'addVariableLocation',
|
|
|
|
|
- 'addColumnLocation',
|
|
|
|
|
- 'addCteAliasLocation',
|
|
|
|
|
- 'addUnknownLocation',
|
|
|
|
|
- 'addColRefToVariableIfExists',
|
|
|
|
|
- 'suggestDatabases',
|
|
|
|
|
- 'suggestHdfs',
|
|
|
|
|
- 'suggestValues'
|
|
|
|
|
|
|
+ 'suggestTablesOrColumns',
|
|
|
|
|
+ 'suggestValueExpressionKeywords',
|
|
|
|
|
+ 'suggestValues',
|
|
|
|
|
+ 'valueExpressionSuggest'
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
const SYNTAX_PARSER_NOOP = function() {};
|
|
const SYNTAX_PARSER_NOOP = function() {};
|