dt-sql-parser 4.4.2 → 4.5.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +140 -3
- package/dist/lib/SQLParserBase.d.ts +13 -1
- package/dist/lib/SQLParserBase.js +40 -5
- package/dist/lib/flink/FlinkSqlLexer.d.ts +397 -399
- package/dist/lib/flink/FlinkSqlLexer.js +2489 -2504
- package/dist/lib/flink/FlinkSqlParser.d.ts +726 -728
- package/dist/lib/flink/FlinkSqlParser.js +4727 -5330
- package/dist/lib/flink/FlinkSqlParserListener.d.ts +132 -90
- package/dist/lib/flink/FlinkSqlParserVisitor.d.ts +84 -57
- package/dist/lib/hive/HiveSqlParser.d.ts +338 -239
- package/dist/lib/hive/HiveSqlParser.js +6466 -5794
- package/dist/lib/hive/HiveSqlParserListener.d.ts +88 -0
- package/dist/lib/hive/HiveSqlParserVisitor.d.ts +56 -0
- package/dist/lib/impala/ImpalaSqlParser.d.ts +236 -125
- package/dist/lib/impala/ImpalaSqlParser.js +4257 -3483
- package/dist/lib/impala/ImpalaSqlParserListener.d.ts +109 -14
- package/dist/lib/impala/ImpalaSqlParserVisitor.d.ts +69 -8
- package/dist/lib/mysql/MySqlParser.d.ts +403 -306
- package/dist/lib/mysql/MySqlParser.js +10694 -10030
- package/dist/lib/mysql/MySqlParserListener.d.ts +121 -18
- package/dist/lib/mysql/MySqlParserVisitor.d.ts +75 -10
- package/dist/lib/postgresql/PostgreSqlParser.d.ts +256 -173
- package/dist/lib/postgresql/PostgreSqlParser.js +14934 -11710
- package/dist/lib/postgresql/PostgreSqlParserListener.d.ts +97 -5
- package/dist/lib/postgresql/PostgreSqlParserVisitor.d.ts +61 -3
- package/dist/lib/spark/SparkSqlParser.d.ts +314 -149
- package/dist/lib/spark/SparkSqlParser.js +6185 -5227
- package/dist/lib/spark/SparkSqlParserListener.d.ts +180 -5
- package/dist/lib/spark/SparkSqlParserVisitor.d.ts +113 -3
- package/dist/lib/trino/TrinoSqlListener.d.ts +90 -37
- package/dist/lib/trino/TrinoSqlParser.d.ts +219 -165
- package/dist/lib/trino/TrinoSqlParser.js +4942 -4615
- package/dist/lib/trino/TrinoSqlVisitor.d.ts +55 -21
- package/dist/parser/common/basicSQL.d.ts +5 -5
- package/dist/parser/common/basicSQL.js +4 -2
- package/dist/parser/common/entityCollector.d.ts +91 -4
- package/dist/parser/common/entityCollector.js +227 -11
- package/dist/parser/common/textAndWord.d.ts +9 -1
- package/dist/parser/common/textAndWord.js +2 -0
- package/dist/parser/common/types.d.ts +2 -0
- package/dist/parser/common/types.js +2 -0
- package/dist/parser/flink/flinkEntityCollector.d.ts +10 -2
- package/dist/parser/flink/flinkEntityCollector.js +76 -14
- package/dist/parser/flink/index.js +5 -2
- package/dist/parser/hive/hiveEntityCollector.d.ts +13 -1
- package/dist/parser/hive/hiveEntityCollector.js +85 -12
- package/dist/parser/impala/impalaEntityCollector.d.ts +7 -1
- package/dist/parser/impala/impalaEntityCollector.js +63 -12
- package/dist/parser/impala/index.js +2 -1
- package/dist/parser/mysql/index.js +3 -1
- package/dist/parser/mysql/mysqlEntityCollector.d.ts +10 -1
- package/dist/parser/mysql/mysqlEntityCollector.js +65 -12
- package/dist/parser/mysql/mysqlErrorListener.js +2 -0
- package/dist/parser/postgresql/postgreEntityCollector.d.ts +12 -1
- package/dist/parser/postgresql/postgreEntityCollector.js +99 -22
- package/dist/parser/spark/index.js +3 -1
- package/dist/parser/spark/sparkEntityCollector.d.ts +13 -1
- package/dist/parser/spark/sparkEntityCollector.js +88 -12
- package/dist/parser/trino/trinoEntityCollector.d.ts +7 -1
- package/dist/parser/trino/trinoEntityCollector.js +53 -12
- package/package.json +1 -1
|
@@ -116,6 +116,7 @@ import { SortItemContext } from "./TrinoSqlParser.js";
|
|
|
116
116
|
import { QuerySpecificationContext } from "./TrinoSqlParser.js";
|
|
117
117
|
import { WhereClauseContext } from "./TrinoSqlParser.js";
|
|
118
118
|
import { HavingClauseContext } from "./TrinoSqlParser.js";
|
|
119
|
+
import { SelectListContext } from "./TrinoSqlParser.js";
|
|
119
120
|
import { GroupByContext } from "./TrinoSqlParser.js";
|
|
120
121
|
import { PartitionByContext } from "./TrinoSqlParser.js";
|
|
121
122
|
import { SingleGroupingSetContext } from "./TrinoSqlParser.js";
|
|
@@ -128,8 +129,11 @@ import { WindowDefinitionContext } from "./TrinoSqlParser.js";
|
|
|
128
129
|
import { WindowSpecificationContext } from "./TrinoSqlParser.js";
|
|
129
130
|
import { NamedQueryContext } from "./TrinoSqlParser.js";
|
|
130
131
|
import { SetQuantifierContext } from "./TrinoSqlParser.js";
|
|
131
|
-
import {
|
|
132
|
-
import {
|
|
132
|
+
import { SelectItemContext } from "./TrinoSqlParser.js";
|
|
133
|
+
import { SelectAllWithoutTableContext } from "./TrinoSqlParser.js";
|
|
134
|
+
import { TableAllColumnsContext } from "./TrinoSqlParser.js";
|
|
135
|
+
import { SelectLiteralColumnNameContext } from "./TrinoSqlParser.js";
|
|
136
|
+
import { SelectExpressionColumnNameContext } from "./TrinoSqlParser.js";
|
|
133
137
|
import { RelationDefaultContext } from "./TrinoSqlParser.js";
|
|
134
138
|
import { JoinRelationContext } from "./TrinoSqlParser.js";
|
|
135
139
|
import { JoinTypeContext } from "./TrinoSqlParser.js";
|
|
@@ -151,11 +155,12 @@ import { ColumnListCreateContext } from "./TrinoSqlParser.js";
|
|
|
151
155
|
import { ColumnListContext } from "./TrinoSqlParser.js";
|
|
152
156
|
import { ColumnAliasesContext } from "./TrinoSqlParser.js";
|
|
153
157
|
import { TableNameContext } from "./TrinoSqlParser.js";
|
|
158
|
+
import { ExpressionSourceTableContext } from "./TrinoSqlParser.js";
|
|
159
|
+
import { ParenthesizedRelationContext } from "./TrinoSqlParser.js";
|
|
154
160
|
import { SubqueryRelationContext } from "./TrinoSqlParser.js";
|
|
155
161
|
import { UnnestContext } from "./TrinoSqlParser.js";
|
|
156
162
|
import { LateralContext } from "./TrinoSqlParser.js";
|
|
157
163
|
import { TableFunctionInvocationContext } from "./TrinoSqlParser.js";
|
|
158
|
-
import { ParenthesizedRelationContext } from "./TrinoSqlParser.js";
|
|
159
164
|
import { JsonTableContext } from "./TrinoSqlParser.js";
|
|
160
165
|
import { OrdinalityColumnContext } from "./TrinoSqlParser.js";
|
|
161
166
|
import { ValueColumnContext } from "./TrinoSqlParser.js";
|
|
@@ -1176,6 +1181,12 @@ export declare class TrinoSqlVisitor<Result> extends AbstractParseTreeVisitor<Re
|
|
|
1176
1181
|
* @return the visitor result
|
|
1177
1182
|
*/
|
|
1178
1183
|
visitHavingClause?: (ctx: HavingClauseContext) => Result;
|
|
1184
|
+
/**
|
|
1185
|
+
* Visit a parse tree produced by `TrinoSqlParser.selectList`.
|
|
1186
|
+
* @param ctx the parse tree
|
|
1187
|
+
* @return the visitor result
|
|
1188
|
+
*/
|
|
1189
|
+
visitSelectList?: (ctx: SelectListContext) => Result;
|
|
1179
1190
|
/**
|
|
1180
1191
|
* Visit a parse tree produced by `TrinoSqlParser.groupBy`.
|
|
1181
1192
|
* @param ctx the parse tree
|
|
@@ -1253,19 +1264,35 @@ export declare class TrinoSqlVisitor<Result> extends AbstractParseTreeVisitor<Re
|
|
|
1253
1264
|
*/
|
|
1254
1265
|
visitSetQuantifier?: (ctx: SetQuantifierContext) => Result;
|
|
1255
1266
|
/**
|
|
1256
|
-
* Visit a parse tree produced by
|
|
1257
|
-
* labeled alternative in `TrinoSqlParser.selectItem`.
|
|
1267
|
+
* Visit a parse tree produced by `TrinoSqlParser.selectItem`.
|
|
1258
1268
|
* @param ctx the parse tree
|
|
1259
1269
|
* @return the visitor result
|
|
1260
1270
|
*/
|
|
1261
|
-
|
|
1271
|
+
visitSelectItem?: (ctx: SelectItemContext) => Result;
|
|
1262
1272
|
/**
|
|
1263
|
-
* Visit a parse tree produced by
|
|
1264
|
-
* labeled alternative in `TrinoSqlParser.selectItem`.
|
|
1273
|
+
* Visit a parse tree produced by `TrinoSqlParser.selectAllWithoutTable`.
|
|
1265
1274
|
* @param ctx the parse tree
|
|
1266
1275
|
* @return the visitor result
|
|
1267
1276
|
*/
|
|
1268
|
-
|
|
1277
|
+
visitSelectAllWithoutTable?: (ctx: SelectAllWithoutTableContext) => Result;
|
|
1278
|
+
/**
|
|
1279
|
+
* Visit a parse tree produced by `TrinoSqlParser.tableAllColumns`.
|
|
1280
|
+
* @param ctx the parse tree
|
|
1281
|
+
* @return the visitor result
|
|
1282
|
+
*/
|
|
1283
|
+
visitTableAllColumns?: (ctx: TableAllColumnsContext) => Result;
|
|
1284
|
+
/**
|
|
1285
|
+
* Visit a parse tree produced by `TrinoSqlParser.selectLiteralColumnName`.
|
|
1286
|
+
* @param ctx the parse tree
|
|
1287
|
+
* @return the visitor result
|
|
1288
|
+
*/
|
|
1289
|
+
visitSelectLiteralColumnName?: (ctx: SelectLiteralColumnNameContext) => Result;
|
|
1290
|
+
/**
|
|
1291
|
+
* Visit a parse tree produced by `TrinoSqlParser.selectExpressionColumnName`.
|
|
1292
|
+
* @param ctx the parse tree
|
|
1293
|
+
* @return the visitor result
|
|
1294
|
+
*/
|
|
1295
|
+
visitSelectExpressionColumnName?: (ctx: SelectExpressionColumnNameContext) => Result;
|
|
1269
1296
|
/**
|
|
1270
1297
|
* Visit a parse tree produced by the `relationDefault`
|
|
1271
1298
|
* labeled alternative in `TrinoSqlParser.relation`.
|
|
@@ -1396,43 +1423,50 @@ export declare class TrinoSqlVisitor<Result> extends AbstractParseTreeVisitor<Re
|
|
|
1396
1423
|
*/
|
|
1397
1424
|
visitTableName?: (ctx: TableNameContext) => Result;
|
|
1398
1425
|
/**
|
|
1399
|
-
* Visit a parse tree produced by the `
|
|
1426
|
+
* Visit a parse tree produced by the `expressionSourceTable`
|
|
1427
|
+
* labeled alternative in `TrinoSqlParser.relationPrimary`.
|
|
1428
|
+
* @param ctx the parse tree
|
|
1429
|
+
* @return the visitor result
|
|
1430
|
+
*/
|
|
1431
|
+
visitExpressionSourceTable?: (ctx: ExpressionSourceTableContext) => Result;
|
|
1432
|
+
/**
|
|
1433
|
+
* Visit a parse tree produced by the `parenthesizedRelation`
|
|
1400
1434
|
* labeled alternative in `TrinoSqlParser.relationPrimary`.
|
|
1401
1435
|
* @param ctx the parse tree
|
|
1402
1436
|
* @return the visitor result
|
|
1403
1437
|
*/
|
|
1438
|
+
visitParenthesizedRelation?: (ctx: ParenthesizedRelationContext) => Result;
|
|
1439
|
+
/**
|
|
1440
|
+
* Visit a parse tree produced by the `subqueryRelation`
|
|
1441
|
+
* labeled alternative in `TrinoSqlParser.relationSourceTable`.
|
|
1442
|
+
* @param ctx the parse tree
|
|
1443
|
+
* @return the visitor result
|
|
1444
|
+
*/
|
|
1404
1445
|
visitSubqueryRelation?: (ctx: SubqueryRelationContext) => Result;
|
|
1405
1446
|
/**
|
|
1406
1447
|
* Visit a parse tree produced by the `unnest`
|
|
1407
|
-
* labeled alternative in `TrinoSqlParser.
|
|
1448
|
+
* labeled alternative in `TrinoSqlParser.relationSourceTable`.
|
|
1408
1449
|
* @param ctx the parse tree
|
|
1409
1450
|
* @return the visitor result
|
|
1410
1451
|
*/
|
|
1411
1452
|
visitUnnest?: (ctx: UnnestContext) => Result;
|
|
1412
1453
|
/**
|
|
1413
1454
|
* Visit a parse tree produced by the `lateral`
|
|
1414
|
-
* labeled alternative in `TrinoSqlParser.
|
|
1455
|
+
* labeled alternative in `TrinoSqlParser.relationSourceTable`.
|
|
1415
1456
|
* @param ctx the parse tree
|
|
1416
1457
|
* @return the visitor result
|
|
1417
1458
|
*/
|
|
1418
1459
|
visitLateral?: (ctx: LateralContext) => Result;
|
|
1419
1460
|
/**
|
|
1420
1461
|
* Visit a parse tree produced by the `tableFunctionInvocation`
|
|
1421
|
-
* labeled alternative in `TrinoSqlParser.
|
|
1462
|
+
* labeled alternative in `TrinoSqlParser.relationSourceTable`.
|
|
1422
1463
|
* @param ctx the parse tree
|
|
1423
1464
|
* @return the visitor result
|
|
1424
1465
|
*/
|
|
1425
1466
|
visitTableFunctionInvocation?: (ctx: TableFunctionInvocationContext) => Result;
|
|
1426
|
-
/**
|
|
1427
|
-
* Visit a parse tree produced by the `parenthesizedRelation`
|
|
1428
|
-
* labeled alternative in `TrinoSqlParser.relationPrimary`.
|
|
1429
|
-
* @param ctx the parse tree
|
|
1430
|
-
* @return the visitor result
|
|
1431
|
-
*/
|
|
1432
|
-
visitParenthesizedRelation?: (ctx: ParenthesizedRelationContext) => Result;
|
|
1433
1467
|
/**
|
|
1434
1468
|
* Visit a parse tree produced by the `jsonTable`
|
|
1435
|
-
* labeled alternative in `TrinoSqlParser.
|
|
1469
|
+
* labeled alternative in `TrinoSqlParser.relationSourceTable`.
|
|
1436
1470
|
* @param ctx the parse tree
|
|
1437
1471
|
* @return the visitor result
|
|
1438
1472
|
*/
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Lexer, Token, CommonTokenStream, CharStream, ParserRuleContext, ParseTreeListener, ANTLRErrorListener, Parser } from 'antlr4ng';
|
|
2
1
|
import { CandidatesCollection } from 'antlr4-c3';
|
|
2
|
+
import { ANTLRErrorListener, CharStream, CommonTokenStream, Lexer, Parser, ParserRuleContext, ParseTreeListener, Token } from 'antlr4ng';
|
|
3
3
|
import { SQLParserBase } from '../../lib/SQLParserBase';
|
|
4
|
-
import { TextSlice } from './textAndWord';
|
|
5
|
-
import { CaretPosition, LOCALE_TYPE, SemanticCollectOptions, Suggestions } from './types';
|
|
6
|
-
import { ParseError, ErrorListener } from './parseErrorListener';
|
|
7
|
-
import type { SplitListener } from './splitListener';
|
|
8
4
|
import type { EntityCollector } from './entityCollector';
|
|
9
5
|
import { EntityContext } from './entityCollector';
|
|
6
|
+
import { ErrorListener, ParseError } from './parseErrorListener';
|
|
10
7
|
import SemanticContextCollector from './semanticContextCollector';
|
|
8
|
+
import type { SplitListener } from './splitListener';
|
|
9
|
+
import { TextSlice } from './textAndWord';
|
|
10
|
+
import { CaretPosition, LOCALE_TYPE, SemanticCollectOptions, Suggestions } from './types';
|
|
11
11
|
export declare const SQL_SPLIT_SYMBOL_TEXT = ";";
|
|
12
12
|
/**
|
|
13
13
|
* Basic SQL class, every sql needs extends it.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CharStreams, CommonTokenStream, ParseTreeWalker, PredictionMode, } from 'antlr4ng';
|
|
2
1
|
import { CodeCompletionCore } from 'antlr4-c3';
|
|
2
|
+
import { CharStreams, CommonTokenStream, ParseTreeWalker, PredictionMode, } from 'antlr4ng';
|
|
3
|
+
import { ErrorStrategy } from './errorStrategy';
|
|
3
4
|
import { findCaretTokenIndex } from './findCaretTokenIndex';
|
|
4
5
|
import { ctxToText, tokenToWord } from './textAndWord';
|
|
5
|
-
import { ErrorStrategy } from './errorStrategy';
|
|
6
6
|
export const SQL_SPLIT_SYMBOL_TEXT = ';';
|
|
7
7
|
/**
|
|
8
8
|
* Basic SQL class, every sql needs extends it.
|
|
@@ -359,6 +359,8 @@ export class BasicSQL {
|
|
|
359
359
|
}
|
|
360
360
|
const core = new CodeCompletionCore(sqlParserIns);
|
|
361
361
|
core.preferredRules = this.preferredRules;
|
|
362
|
+
// core.showRuleStack = true;
|
|
363
|
+
// core.showResult = true;
|
|
362
364
|
const candidates = core.collectCandidates(caretTokenIndex, parseTree);
|
|
363
365
|
const originalSuggestions = this.processCandidates(candidates, allTokens, caretTokenIndex);
|
|
364
366
|
const syntaxSuggestions = originalSuggestions.syntax.map((syntaxCtx) => {
|
|
@@ -22,6 +22,8 @@ export interface StmtContext {
|
|
|
22
22
|
readonly rootStmt: StmtContext | null;
|
|
23
23
|
readonly parentStmt: StmtContext | null;
|
|
24
24
|
readonly isContainCaret?: boolean;
|
|
25
|
+
readonly scopeDepth: number;
|
|
26
|
+
readonly text: string;
|
|
25
27
|
}
|
|
26
28
|
export declare function toStmtContext(ctx: ParserRuleContext, type: StmtContextType, input: string, rootStmt: StmtContext | null, parentStmt: StmtContext | null, isContainCaret?: boolean): StmtContext | null;
|
|
27
29
|
/**
|
|
@@ -49,31 +51,77 @@ export interface Argument {
|
|
|
49
51
|
argName?: WordRange;
|
|
50
52
|
argType: WordRange;
|
|
51
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Base interface for all entity contexts in SQL parsing
|
|
56
|
+
*/
|
|
52
57
|
export interface BaseEntityContext {
|
|
58
|
+
/** The type of entity context */
|
|
53
59
|
readonly entityContextType: EntityContextType;
|
|
60
|
+
/** The text representation of this entity */
|
|
54
61
|
readonly text: string;
|
|
62
|
+
/** The position information for this entity */
|
|
55
63
|
readonly position: WordPosition;
|
|
64
|
+
/** The statement this entity belongs to */
|
|
56
65
|
readonly belongStmt: StmtContext;
|
|
66
|
+
/** Reference to another entity or string */
|
|
57
67
|
reference?: string | EntityContext;
|
|
68
|
+
/** Whether the entity is accessible from the caret position, **ONLY** applicable to table entity */
|
|
69
|
+
isAccessible: boolean | null;
|
|
70
|
+
/** Entities related to this entity */
|
|
71
|
+
relatedEntities: EntityContext[] | null;
|
|
72
|
+
/** Comment attribute for this entity */
|
|
58
73
|
[AttrName.comment]: WordRange | null;
|
|
74
|
+
/** Alias attribute for this entity */
|
|
59
75
|
[AttrName.alias]?: WordRange | null;
|
|
60
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Types of column declarations
|
|
79
|
+
*/
|
|
80
|
+
export declare enum ColumnDeclareType {
|
|
81
|
+
/** Literal column name */
|
|
82
|
+
LITERAL = 0,
|
|
83
|
+
/** Using asterisk syntax (tableName.*) */
|
|
84
|
+
ALL = 1,
|
|
85
|
+
/** Complex expressions like subqueries, case statements, function calls */
|
|
86
|
+
EXPRESSION = 2
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Types of table declarations
|
|
90
|
+
*/
|
|
91
|
+
export declare enum TableDeclareType {
|
|
92
|
+
/** Regular table reference */
|
|
93
|
+
LITERAL = 0,
|
|
94
|
+
/** Table defined by expression (e.g., subquery) */
|
|
95
|
+
EXPRESSION = 1
|
|
96
|
+
}
|
|
61
97
|
export interface CommonEntityContext extends BaseEntityContext {
|
|
62
|
-
|
|
98
|
+
/** Columns associated with this entity */
|
|
63
99
|
columns?: ColumnEntityContext[];
|
|
100
|
+
/** Type of table declaration */
|
|
101
|
+
declareType?: TableDeclareType;
|
|
64
102
|
}
|
|
65
103
|
export interface ColumnEntityContext extends BaseEntityContext {
|
|
104
|
+
/** Type of column declaration */
|
|
105
|
+
declareType?: ColumnDeclareType;
|
|
106
|
+
/** Column type information */
|
|
66
107
|
[AttrName.colType]: WordRange | null;
|
|
108
|
+
/** Column alias */
|
|
109
|
+
[AttrName.alias]?: WordRange | null;
|
|
67
110
|
}
|
|
68
111
|
export interface FuncEntityContext extends BaseEntityContext {
|
|
69
|
-
|
|
112
|
+
/** Function arguments */
|
|
70
113
|
arguments: Argument[] | null;
|
|
114
|
+
/** Function return value */
|
|
71
115
|
returns?: Argument;
|
|
72
116
|
}
|
|
73
117
|
export type EntityContext = CommonEntityContext | FuncEntityContext | ColumnEntityContext;
|
|
74
118
|
export declare function isCommonEntityContext(entity: EntityContext): entity is CommonEntityContext;
|
|
75
119
|
export declare function isFuncEntityContext(entity: EntityContext): entity is FuncEntityContext;
|
|
76
120
|
export declare function isColumnEntityContext(entity: EntityContext): entity is ColumnEntityContext;
|
|
121
|
+
/**
|
|
122
|
+
* Check if ctx is a child node of a specific rule type
|
|
123
|
+
*/
|
|
124
|
+
export declare function isChildContextOf(ctx: ParserRuleContext, parentRuleIndex: number): boolean;
|
|
77
125
|
/**
|
|
78
126
|
* what we need when collect attribute information
|
|
79
127
|
* */
|
|
@@ -81,7 +129,10 @@ interface AttrInfo {
|
|
|
81
129
|
attrName: AttrName;
|
|
82
130
|
endContextList: string[];
|
|
83
131
|
}
|
|
84
|
-
|
|
132
|
+
interface MetaInfo {
|
|
133
|
+
declareType: TableDeclareType | ColumnDeclareType;
|
|
134
|
+
}
|
|
135
|
+
export declare function toEntityContext(ctx: ParserRuleContext, type: EntityContextType, input: string, belongStmt: StmtContext, attrInfo?: AttrInfo[], metaInfo?: MetaInfo): EntityContext | null;
|
|
85
136
|
export declare function findAttribute(ctx: ParserRuleContextWithAttr | null, keyName: AttrName, endContextNameList: string[]): Token | null;
|
|
86
137
|
/**
|
|
87
138
|
* @todo: Handle alias, includes column alias, table alias, query as alias and so on.
|
|
@@ -97,6 +148,16 @@ export declare abstract class EntityCollector {
|
|
|
97
148
|
private readonly _stmtStack;
|
|
98
149
|
/** Staging entities inside a single statement or clause. */
|
|
99
150
|
private readonly _entityStack;
|
|
151
|
+
/**
|
|
152
|
+
* The scope depth of the statement containing the caret.
|
|
153
|
+
* This is used to determine the accessibility of entities.
|
|
154
|
+
*/
|
|
155
|
+
private _caretStmtScopeDepth;
|
|
156
|
+
/**
|
|
157
|
+
* The nearest statement containing the caret,
|
|
158
|
+
* Not used for now.
|
|
159
|
+
*/
|
|
160
|
+
private _caretStmt;
|
|
100
161
|
/**
|
|
101
162
|
* Always point to the first non-commonStmt at the bottom of the _stmtStack,
|
|
102
163
|
* unless there are only commonStmts in the _stmtStack.
|
|
@@ -109,6 +170,30 @@ export declare abstract class EntityCollector {
|
|
|
109
170
|
getRootStmt(): StmtContext | null;
|
|
110
171
|
getEntities(): EntityContext[];
|
|
111
172
|
enterProgram(): void;
|
|
173
|
+
exitProgram(): void;
|
|
174
|
+
/**
|
|
175
|
+
* Adds accessibility markers to entities
|
|
176
|
+
* @param entities The list of entities to process
|
|
177
|
+
*/
|
|
178
|
+
protected attachAccessibleToEntities(entities: EntityContext[]): void;
|
|
179
|
+
/**
|
|
180
|
+
* Attach query result to column if the column is derived from expression.
|
|
181
|
+
*/
|
|
182
|
+
protected attachQueryResultToColumn(column: ColumnEntityContext, queryResults: CommonEntityContext[]): void;
|
|
183
|
+
/**
|
|
184
|
+
* Attach related columns to query result
|
|
185
|
+
*/
|
|
186
|
+
protected attachColumnsToQueryResult(queryResult: CommonEntityContext, columns: ColumnEntityContext[]): void;
|
|
187
|
+
/**
|
|
188
|
+
* Attach query result to table if the table is derived from expression.
|
|
189
|
+
*/
|
|
190
|
+
protected attachQueryResultToTable(table: CommonEntityContext, queryResults: CommonEntityContext[]): void;
|
|
191
|
+
/**
|
|
192
|
+
* Gets query result entities inside a statement
|
|
193
|
+
* @param stmt The statement to search within
|
|
194
|
+
* @returns Array of query result entity contexts
|
|
195
|
+
*/
|
|
196
|
+
protected getQueryResultEntitiesInsideStmt(stmt: StmtContext): CommonEntityContext[];
|
|
112
197
|
/**
|
|
113
198
|
* The antlr4 will ignore hidden tokens, if we type whitespace at the end of a statement,
|
|
114
199
|
* the whitespace token will not as stop token, so we consider the whitespace token as a part of the nonhidden token in front of it
|
|
@@ -116,7 +201,7 @@ export declare abstract class EntityCollector {
|
|
|
116
201
|
protected getPrevNonHiddenTokenIndex(caretTokenIndex: number): number;
|
|
117
202
|
protected pushStmt(ctx: ParserRuleContext, type: StmtContextType): StmtContext | null;
|
|
118
203
|
protected popStmt(): StmtContext;
|
|
119
|
-
protected pushEntity(ctx: ParserRuleContext, type: EntityContextType, attrInfo?: AttrInfo[]): EntityContext | null;
|
|
204
|
+
protected pushEntity(ctx: ParserRuleContext, type: EntityContextType, attrInfo?: AttrInfo[], metaInfo?: MetaInfo): EntityContext | null;
|
|
120
205
|
/**
|
|
121
206
|
* Combine entities that inside a single statement.
|
|
122
207
|
* e.g. combine tableName and column if they are inside a same createTableStatement.
|
|
@@ -127,6 +212,8 @@ export declare abstract class EntityCollector {
|
|
|
127
212
|
* Combined all entities under a rootStmt.
|
|
128
213
|
*/
|
|
129
214
|
protected combineRootStmtEntities(stmtContext: StmtContext, entitiesInsideStmt: EntityContext[]): EntityContext[];
|
|
215
|
+
protected combineQueryResultStmtEntities(stmtContext: StmtContext, entitiesInsideStmt: EntityContext[]): EntityContext[];
|
|
216
|
+
protected combineFromTableSource(stmtContext: StmtContext, entitiesInsideStmt: EntityContext[]): EntityContext[];
|
|
130
217
|
protected combineCreateTableOrViewStmtEntities(stmtContext: StmtContext, entitiesInsideStmt: EntityContext[]): EntityContext[];
|
|
131
218
|
}
|
|
132
219
|
export {};
|