dt-sql-parser 4.1.0-beta.7 → 4.1.0
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/CHANGELOG.md +369 -0
- package/dist/lib/postgresql/PostgreSqlParser.d.ts +3 -4
- package/dist/lib/postgresql/PostgreSqlParser.js +9175 -9197
- package/dist/lib/trino/TrinoSqlListener.d.ts +13 -0
- package/dist/lib/trino/TrinoSqlParser.d.ts +17 -4
- package/dist/lib/trino/TrinoSqlParser.js +1958 -1970
- package/dist/lib/trino/TrinoSqlVisitor.d.ts +8 -0
- package/dist/parser/common/basicSQL.d.ts +1 -1
- package/dist/parser/common/basicSQL.js +1 -1
- package/dist/parser/common/entityCollector.d.ts +7 -1
- package/dist/parser/common/entityCollector.js +20 -3
- package/dist/parser/flink/index.d.ts +6 -6
- package/dist/parser/flink/index.js +5 -5
- package/dist/parser/hive/index.d.ts +4 -4
- package/dist/parser/hive/index.js +3 -3
- package/dist/parser/impala/index.d.ts +4 -4
- package/dist/parser/impala/index.js +3 -3
- package/dist/parser/mysql/index.d.ts +4 -4
- package/dist/parser/mysql/index.js +3 -3
- package/dist/parser/postgresql/index.d.ts +4 -4
- package/dist/parser/postgresql/index.js +4 -4
- package/dist/parser/spark/index.d.ts +6 -6
- package/dist/parser/spark/index.js +4 -4
- package/dist/parser/trino/index.d.ts +6 -6
- package/dist/parser/trino/index.js +4 -4
- package/package.json +2 -1
|
@@ -259,6 +259,7 @@ import { RowTypeContext } from "./TrinoSqlParser.js";
|
|
|
259
259
|
import { IntervalTypeContext } from "./TrinoSqlParser.js";
|
|
260
260
|
import { ArrayTypeContext } from "./TrinoSqlParser.js";
|
|
261
261
|
import { DoublePrecisionTypeContext } from "./TrinoSqlParser.js";
|
|
262
|
+
import { TimeTypeContext } from "./TrinoSqlParser.js";
|
|
262
263
|
import { LegacyArrayTypeContext } from "./TrinoSqlParser.js";
|
|
263
264
|
import { GenericTypeContext } from "./TrinoSqlParser.js";
|
|
264
265
|
import { DateTimeTypeContext } from "./TrinoSqlParser.js";
|
|
@@ -2122,6 +2123,13 @@ export declare class TrinoSqlVisitor<Result> extends AbstractParseTreeVisitor<Re
|
|
|
2122
2123
|
* @return the visitor result
|
|
2123
2124
|
*/
|
|
2124
2125
|
visitDoublePrecisionType?: (ctx: DoublePrecisionTypeContext) => Result;
|
|
2126
|
+
/**
|
|
2127
|
+
* Visit a parse tree produced by the `timeType`
|
|
2128
|
+
* labeled alternative in `TrinoSqlParser.type`.
|
|
2129
|
+
* @param ctx the parse tree
|
|
2130
|
+
* @return the visitor result
|
|
2131
|
+
*/
|
|
2132
|
+
visitTimeType?: (ctx: TimeTypeContext) => Result;
|
|
2125
2133
|
/**
|
|
2126
2134
|
* Visit a parse tree produced by the `legacyArrayType`
|
|
2127
2135
|
* labeled alternative in `TrinoSqlParser.type`.
|
|
@@ -54,7 +54,7 @@ export declare abstract class BasicSQL<L extends Lexer = Lexer, PRC extends Pars
|
|
|
54
54
|
/**
|
|
55
55
|
* Get a new entityCollector instance.
|
|
56
56
|
*/
|
|
57
|
-
protected abstract createEntityCollector(input: string, caretTokenIndex?: number): EntityCollector;
|
|
57
|
+
protected abstract createEntityCollector(input: string, allTokens?: Token[], caretTokenIndex?: number): EntityCollector;
|
|
58
58
|
locale: LOCALE_TYPE;
|
|
59
59
|
/**
|
|
60
60
|
* Create an antlr4 lexer from input.
|
|
@@ -285,7 +285,7 @@ export class BasicSQL {
|
|
|
285
285
|
const caretTokenIndex = caretPosition
|
|
286
286
|
? findCaretTokenIndex(caretPosition, allTokens)
|
|
287
287
|
: void 0;
|
|
288
|
-
const collectListener = this.createEntityCollector(input, caretTokenIndex);
|
|
288
|
+
const collectListener = this.createEntityCollector(input, allTokens, caretTokenIndex);
|
|
289
289
|
// const parser = this.createParserWithCache(input);
|
|
290
290
|
// parser.entityCollecting = true;
|
|
291
291
|
// if(caretPosition) {
|
|
@@ -88,8 +88,9 @@ export declare function findAttribute(ctx: ParserRuleContextWithAttr | null, key
|
|
|
88
88
|
* @todo: [may be need] Combine the entities in each clause.
|
|
89
89
|
*/
|
|
90
90
|
export declare abstract class EntityCollector {
|
|
91
|
-
constructor(input: string, caretTokenIndex?: number);
|
|
91
|
+
constructor(input: string, allTokens?: Token[], caretTokenIndex?: number);
|
|
92
92
|
private readonly _input;
|
|
93
|
+
private readonly _allTokens;
|
|
93
94
|
private readonly _caretTokenIndex;
|
|
94
95
|
private readonly _entitiesSet;
|
|
95
96
|
/** Staging statements that have already entered. */
|
|
@@ -108,6 +109,11 @@ export declare abstract class EntityCollector {
|
|
|
108
109
|
getRootStmt(): StmtContext | null;
|
|
109
110
|
getEntities(): EntityContext[];
|
|
110
111
|
enterProgram(): void;
|
|
112
|
+
/**
|
|
113
|
+
* The antlr4 will ignore hidden tokens, if we type whitespace at the end of a statement,
|
|
114
|
+
* 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
|
|
115
|
+
*/
|
|
116
|
+
protected getPrevNonHiddenTokenIndex(caretTokenIndex: number): number;
|
|
111
117
|
protected pushStmt(ctx: ParserRuleContext, type: StmtContextType): StmtContext | null;
|
|
112
118
|
protected popStmt(): StmtContext;
|
|
113
119
|
protected pushEntity(ctx: ParserRuleContext, type: EntityContextType, attrInfo?: AttrInfo[]): EntityContext | null;
|
|
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { isToken } from 'antlr4ng';
|
|
12
|
+
import { isToken, Token } from 'antlr4ng';
|
|
13
13
|
import { SimpleStack } from './simpleStack';
|
|
14
14
|
import { ctxToText, isWordRange, tokenToWord, } from './textAndWord';
|
|
15
15
|
import { EntityContextType } from './types';
|
|
@@ -173,8 +173,9 @@ function findAttributeChildren(ctx, keyName) {
|
|
|
173
173
|
* @todo: [may be need] Combine the entities in each clause.
|
|
174
174
|
*/
|
|
175
175
|
export class EntityCollector {
|
|
176
|
-
constructor(input, caretTokenIndex) {
|
|
176
|
+
constructor(input, allTokens, caretTokenIndex) {
|
|
177
177
|
this._input = input;
|
|
178
|
+
this._allTokens = allTokens || [];
|
|
178
179
|
this._caretTokenIndex = caretTokenIndex !== null && caretTokenIndex !== void 0 ? caretTokenIndex : -1;
|
|
179
180
|
this._entitiesSet = new Set();
|
|
180
181
|
this._stmtStack = new SimpleStack();
|
|
@@ -197,6 +198,22 @@ export class EntityCollector {
|
|
|
197
198
|
this._entityStack.clear();
|
|
198
199
|
this._rootStmt = null;
|
|
199
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* The antlr4 will ignore hidden tokens, if we type whitespace at the end of a statement,
|
|
203
|
+
* 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
|
|
204
|
+
*/
|
|
205
|
+
getPrevNonHiddenTokenIndex(caretTokenIndex) {
|
|
206
|
+
if (this._allTokens[caretTokenIndex].channel !== Token.HIDDEN_CHANNEL)
|
|
207
|
+
return caretTokenIndex;
|
|
208
|
+
for (let i = caretTokenIndex - 1; i >= 0; i--) {
|
|
209
|
+
const token = this._allTokens[i];
|
|
210
|
+
if (token.channel !== Token.HIDDEN_CHANNEL) {
|
|
211
|
+
// If prev nonhidden token is ';', the current token does not belong to any statement.
|
|
212
|
+
return token.text === ';' ? Infinity : token.tokenIndex;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return Infinity;
|
|
216
|
+
}
|
|
200
217
|
pushStmt(ctx, type) {
|
|
201
218
|
var _a;
|
|
202
219
|
let isContainCaret;
|
|
@@ -205,7 +222,7 @@ export class EntityCollector {
|
|
|
205
222
|
!!ctx.start &&
|
|
206
223
|
!!ctx.stop &&
|
|
207
224
|
ctx.start.tokenIndex <= this._caretTokenIndex &&
|
|
208
|
-
ctx.stop.tokenIndex >= this._caretTokenIndex;
|
|
225
|
+
ctx.stop.tokenIndex >= this.getPrevNonHiddenTokenIndex(this._caretTokenIndex);
|
|
209
226
|
}
|
|
210
227
|
const stmtContext = toStmtContext(ctx, type, this._input, this._rootStmt, this._stmtStack.peek(), isContainCaret);
|
|
211
228
|
if (stmtContext) {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { CharStream, CommonTokenStream, Token } from 'antlr4ng';
|
|
2
1
|
import { CandidatesCollection } from 'antlr4-c3';
|
|
2
|
+
import { CharStream, CommonTokenStream, Token } from 'antlr4ng';
|
|
3
3
|
import { FlinkSqlLexer } from '../../lib/flink/FlinkSqlLexer';
|
|
4
4
|
import { FlinkSqlParser, ProgramContext } from '../../lib/flink/FlinkSqlParser';
|
|
5
|
-
import { Suggestions } from '../common/types';
|
|
6
5
|
import { BasicSQL } from '../common/basicSQL';
|
|
7
|
-
import { FlinkSqlSplitListener } from './flinkSplitListener';
|
|
8
|
-
import { FlinkEntityCollector } from './flinkEntityCollector';
|
|
9
6
|
import { ErrorListener } from '../common/parseErrorListener';
|
|
7
|
+
import { Suggestions } from '../common/types';
|
|
8
|
+
import { FlinkEntityCollector } from './flinkEntityCollector';
|
|
10
9
|
import { FlinkErrorListener } from './flinkErrorListener';
|
|
11
|
-
|
|
10
|
+
import { FlinkSqlSplitListener } from './flinkSplitListener';
|
|
11
|
+
export { FlinkEntityCollector, FlinkSqlSplitListener };
|
|
12
12
|
export declare class FlinkSQL extends BasicSQL<FlinkSqlLexer, ProgramContext, FlinkSqlParser> {
|
|
13
13
|
protected createLexerFromCharStream(charStreams: CharStream): FlinkSqlLexer;
|
|
14
14
|
protected createParserFromTokenStream(tokenStream: CommonTokenStream): FlinkSqlParser;
|
|
15
15
|
protected preferredRules: Set<number>;
|
|
16
16
|
protected get splitListener(): FlinkSqlSplitListener;
|
|
17
17
|
protected createErrorListener(_errorListener: ErrorListener): FlinkErrorListener;
|
|
18
|
-
protected createEntityCollector(input: string, caretTokenIndex?: number): FlinkEntityCollector;
|
|
18
|
+
protected createEntityCollector(input: string, allTokens?: Token[], caretTokenIndex?: number): FlinkEntityCollector;
|
|
19
19
|
protected processCandidates(candidates: CandidatesCollection, allTokens: Token[], caretTokenIndex: number, tokenIndexOffset: number): Suggestions<Token>;
|
|
20
20
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FlinkSqlLexer } from '../../lib/flink/FlinkSqlLexer';
|
|
2
2
|
import { FlinkSqlParser } from '../../lib/flink/FlinkSqlParser';
|
|
3
|
-
import { EntityContextType } from '../common/types';
|
|
4
3
|
import { BasicSQL } from '../common/basicSQL';
|
|
5
|
-
import {
|
|
4
|
+
import { EntityContextType } from '../common/types';
|
|
6
5
|
import { FlinkEntityCollector } from './flinkEntityCollector';
|
|
7
6
|
import { FlinkErrorListener } from './flinkErrorListener';
|
|
8
|
-
|
|
7
|
+
import { FlinkSqlSplitListener } from './flinkSplitListener';
|
|
8
|
+
export { FlinkEntityCollector, FlinkSqlSplitListener };
|
|
9
9
|
export class FlinkSQL extends BasicSQL {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments);
|
|
@@ -36,8 +36,8 @@ export class FlinkSQL extends BasicSQL {
|
|
|
36
36
|
const parserContext = this;
|
|
37
37
|
return new FlinkErrorListener(_errorListener, parserContext, this.preferredRules);
|
|
38
38
|
}
|
|
39
|
-
createEntityCollector(input, caretTokenIndex) {
|
|
40
|
-
return new FlinkEntityCollector(input, caretTokenIndex);
|
|
39
|
+
createEntityCollector(input, allTokens, caretTokenIndex) {
|
|
40
|
+
return new FlinkEntityCollector(input, allTokens, caretTokenIndex);
|
|
41
41
|
}
|
|
42
42
|
processCandidates(candidates, allTokens, caretTokenIndex, tokenIndexOffset) {
|
|
43
43
|
const originalSyntaxSuggestions = [];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { CharStream, CommonTokenStream, Token } from 'antlr4ng';
|
|
2
1
|
import { CandidatesCollection } from 'antlr4-c3';
|
|
2
|
+
import { CharStream, CommonTokenStream, Token } from 'antlr4ng';
|
|
3
3
|
import { HiveSqlLexer } from '../../lib/hive/HiveSqlLexer';
|
|
4
4
|
import { HiveSqlParser, ProgramContext } from '../../lib/hive/HiveSqlParser';
|
|
5
5
|
import { BasicSQL } from '../common/basicSQL';
|
|
6
|
+
import { ErrorListener } from '../common/parseErrorListener';
|
|
6
7
|
import { Suggestions } from '../common/types';
|
|
7
|
-
import { HiveSqlSplitListener } from './hiveSplitListener';
|
|
8
8
|
import { HiveEntityCollector } from './hiveEntityCollector';
|
|
9
|
-
import { ErrorListener } from '../common/parseErrorListener';
|
|
10
9
|
import { HiveErrorListener } from './hiveErrorListener';
|
|
10
|
+
import { HiveSqlSplitListener } from './hiveSplitListener';
|
|
11
11
|
export { HiveEntityCollector, HiveSqlSplitListener };
|
|
12
12
|
export declare class HiveSQL extends BasicSQL<HiveSqlLexer, ProgramContext, HiveSqlParser> {
|
|
13
13
|
protected createLexerFromCharStream(charStreams: CharStream): HiveSqlLexer;
|
|
@@ -15,6 +15,6 @@ export declare class HiveSQL extends BasicSQL<HiveSqlLexer, ProgramContext, Hive
|
|
|
15
15
|
protected preferredRules: Set<number>;
|
|
16
16
|
protected get splitListener(): HiveSqlSplitListener;
|
|
17
17
|
protected createErrorListener(_errorListener: ErrorListener): HiveErrorListener;
|
|
18
|
-
protected createEntityCollector(input: string, caretTokenIndex?: number): HiveEntityCollector;
|
|
18
|
+
protected createEntityCollector(input: string, allTokens?: Token[], caretTokenIndex?: number): HiveEntityCollector;
|
|
19
19
|
protected processCandidates(candidates: CandidatesCollection, allTokens: Token[], caretTokenIndex: number, tokenIndexOffset: number): Suggestions<Token>;
|
|
20
20
|
}
|
|
@@ -2,9 +2,9 @@ import { HiveSqlLexer } from '../../lib/hive/HiveSqlLexer';
|
|
|
2
2
|
import { HiveSqlParser } from '../../lib/hive/HiveSqlParser';
|
|
3
3
|
import { BasicSQL } from '../common/basicSQL';
|
|
4
4
|
import { EntityContextType } from '../common/types';
|
|
5
|
-
import { HiveSqlSplitListener } from './hiveSplitListener';
|
|
6
5
|
import { HiveEntityCollector } from './hiveEntityCollector';
|
|
7
6
|
import { HiveErrorListener } from './hiveErrorListener';
|
|
7
|
+
import { HiveSqlSplitListener } from './hiveSplitListener';
|
|
8
8
|
export { HiveEntityCollector, HiveSqlSplitListener };
|
|
9
9
|
export class HiveSQL extends BasicSQL {
|
|
10
10
|
constructor() {
|
|
@@ -36,8 +36,8 @@ export class HiveSQL extends BasicSQL {
|
|
|
36
36
|
const parserContext = this;
|
|
37
37
|
return new HiveErrorListener(_errorListener, parserContext, this.preferredRules);
|
|
38
38
|
}
|
|
39
|
-
createEntityCollector(input, caretTokenIndex) {
|
|
40
|
-
return new HiveEntityCollector(input, caretTokenIndex);
|
|
39
|
+
createEntityCollector(input, allTokens, caretTokenIndex) {
|
|
40
|
+
return new HiveEntityCollector(input, allTokens, caretTokenIndex);
|
|
41
41
|
}
|
|
42
42
|
processCandidates(candidates, allTokens, caretTokenIndex, tokenIndexOffset) {
|
|
43
43
|
const originalSyntaxSuggestions = [];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { CharStream, CommonTokenStream, Token } from 'antlr4ng';
|
|
2
1
|
import { CandidatesCollection } from 'antlr4-c3';
|
|
2
|
+
import { CharStream, CommonTokenStream, Token } from 'antlr4ng';
|
|
3
3
|
import { ImpalaSqlLexer } from '../../lib/impala/ImpalaSqlLexer';
|
|
4
4
|
import { ImpalaSqlParser, ProgramContext } from '../../lib/impala/ImpalaSqlParser';
|
|
5
5
|
import { BasicSQL } from '../common/basicSQL';
|
|
6
|
+
import { ErrorListener } from '../common/parseErrorListener';
|
|
6
7
|
import { Suggestions } from '../common/types';
|
|
7
|
-
import { ImpalaSqlSplitListener } from './impalaSplitListener';
|
|
8
8
|
import { ImpalaEntityCollector } from './impalaEntityCollector';
|
|
9
|
-
import { ErrorListener } from '../common/parseErrorListener';
|
|
10
9
|
import { ImpalaErrorListener } from './ImpalaErrorListener';
|
|
10
|
+
import { ImpalaSqlSplitListener } from './impalaSplitListener';
|
|
11
11
|
export { ImpalaEntityCollector, ImpalaSqlSplitListener };
|
|
12
12
|
export declare class ImpalaSQL extends BasicSQL<ImpalaSqlLexer, ProgramContext, ImpalaSqlParser> {
|
|
13
13
|
protected createLexerFromCharStream(charStreams: CharStream): ImpalaSqlLexer;
|
|
@@ -15,6 +15,6 @@ export declare class ImpalaSQL extends BasicSQL<ImpalaSqlLexer, ProgramContext,
|
|
|
15
15
|
protected preferredRules: Set<number>;
|
|
16
16
|
protected get splitListener(): ImpalaSqlSplitListener;
|
|
17
17
|
protected createErrorListener(_errorListener: ErrorListener): ImpalaErrorListener;
|
|
18
|
-
protected createEntityCollector(input: string, caretTokenIndex?: number): ImpalaEntityCollector;
|
|
18
|
+
protected createEntityCollector(input: string, allTokens?: Token[], caretTokenIndex?: number): ImpalaEntityCollector;
|
|
19
19
|
protected processCandidates(candidates: CandidatesCollection, allTokens: Token[], caretTokenIndex: number, tokenIndexOffset: number): Suggestions<Token>;
|
|
20
20
|
}
|
|
@@ -2,9 +2,9 @@ import { ImpalaSqlLexer } from '../../lib/impala/ImpalaSqlLexer';
|
|
|
2
2
|
import { ImpalaSqlParser } from '../../lib/impala/ImpalaSqlParser';
|
|
3
3
|
import { BasicSQL } from '../common/basicSQL';
|
|
4
4
|
import { EntityContextType } from '../common/types';
|
|
5
|
-
import { ImpalaSqlSplitListener } from './impalaSplitListener';
|
|
6
5
|
import { ImpalaEntityCollector } from './impalaEntityCollector';
|
|
7
6
|
import { ImpalaErrorListener } from './ImpalaErrorListener';
|
|
7
|
+
import { ImpalaSqlSplitListener } from './impalaSplitListener';
|
|
8
8
|
export { ImpalaEntityCollector, ImpalaSqlSplitListener };
|
|
9
9
|
export class ImpalaSQL extends BasicSQL {
|
|
10
10
|
constructor() {
|
|
@@ -35,8 +35,8 @@ export class ImpalaSQL extends BasicSQL {
|
|
|
35
35
|
const parserContext = this;
|
|
36
36
|
return new ImpalaErrorListener(_errorListener, parserContext, this.preferredRules);
|
|
37
37
|
}
|
|
38
|
-
createEntityCollector(input, caretTokenIndex) {
|
|
39
|
-
return new ImpalaEntityCollector(input, caretTokenIndex);
|
|
38
|
+
createEntityCollector(input, allTokens, caretTokenIndex) {
|
|
39
|
+
return new ImpalaEntityCollector(input, allTokens, caretTokenIndex);
|
|
40
40
|
}
|
|
41
41
|
processCandidates(candidates, allTokens, caretTokenIndex, tokenIndexOffset) {
|
|
42
42
|
const originalSyntaxSuggestions = [];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { CharStream, CommonTokenStream, Token } from 'antlr4ng';
|
|
2
1
|
import { CandidatesCollection } from 'antlr4-c3';
|
|
2
|
+
import { CharStream, CommonTokenStream, Token } from 'antlr4ng';
|
|
3
3
|
import { MySqlLexer } from '../../lib/mysql/MySqlLexer';
|
|
4
4
|
import { MySqlParser, ProgramContext } from '../../lib/mysql/MySqlParser';
|
|
5
5
|
import { BasicSQL } from '../common/basicSQL';
|
|
6
|
+
import { ErrorListener } from '../common/parseErrorListener';
|
|
6
7
|
import { Suggestions } from '../common/types';
|
|
7
|
-
import { MysqlSplitListener } from './mysqlSplitListener';
|
|
8
8
|
import { MySqlEntityCollector } from './mysqlEntityCollector';
|
|
9
9
|
import { MysqlErrorListener } from './mysqlErrorListener';
|
|
10
|
-
import {
|
|
10
|
+
import { MysqlSplitListener } from './mysqlSplitListener';
|
|
11
11
|
export { MySqlEntityCollector, MysqlSplitListener };
|
|
12
12
|
export declare class MySQL extends BasicSQL<MySqlLexer, ProgramContext, MySqlParser> {
|
|
13
13
|
protected createLexerFromCharStream(charStreams: CharStream): MySqlLexer;
|
|
@@ -15,6 +15,6 @@ export declare class MySQL extends BasicSQL<MySqlLexer, ProgramContext, MySqlPar
|
|
|
15
15
|
protected preferredRules: Set<number>;
|
|
16
16
|
protected get splitListener(): MysqlSplitListener;
|
|
17
17
|
protected createErrorListener(_errorListener: ErrorListener): MysqlErrorListener;
|
|
18
|
-
protected createEntityCollector(input: string, caretTokenIndex?: number): MySqlEntityCollector;
|
|
18
|
+
protected createEntityCollector(input: string, allTokens?: Token[], caretTokenIndex?: number): MySqlEntityCollector;
|
|
19
19
|
protected processCandidates(candidates: CandidatesCollection, allTokens: Token[], caretTokenIndex: number, tokenIndexOffset: number): Suggestions<Token>;
|
|
20
20
|
}
|
|
@@ -2,9 +2,9 @@ import { MySqlLexer } from '../../lib/mysql/MySqlLexer';
|
|
|
2
2
|
import { MySqlParser } from '../../lib/mysql/MySqlParser';
|
|
3
3
|
import { BasicSQL } from '../common/basicSQL';
|
|
4
4
|
import { EntityContextType } from '../common/types';
|
|
5
|
-
import { MysqlSplitListener } from './mysqlSplitListener';
|
|
6
5
|
import { MySqlEntityCollector } from './mysqlEntityCollector';
|
|
7
6
|
import { MysqlErrorListener } from './mysqlErrorListener';
|
|
7
|
+
import { MysqlSplitListener } from './mysqlSplitListener';
|
|
8
8
|
export { MySqlEntityCollector, MysqlSplitListener };
|
|
9
9
|
export class MySQL extends BasicSQL {
|
|
10
10
|
constructor() {
|
|
@@ -35,8 +35,8 @@ export class MySQL extends BasicSQL {
|
|
|
35
35
|
const parserContext = this;
|
|
36
36
|
return new MysqlErrorListener(_errorListener, parserContext, this.preferredRules);
|
|
37
37
|
}
|
|
38
|
-
createEntityCollector(input, caretTokenIndex) {
|
|
39
|
-
return new MySqlEntityCollector(input, caretTokenIndex);
|
|
38
|
+
createEntityCollector(input, allTokens, caretTokenIndex) {
|
|
39
|
+
return new MySqlEntityCollector(input, allTokens, caretTokenIndex);
|
|
40
40
|
}
|
|
41
41
|
processCandidates(candidates, allTokens, caretTokenIndex, tokenIndexOffset) {
|
|
42
42
|
const originalSyntaxSuggestions = [];
|
|
@@ -2,12 +2,12 @@ import { CandidatesCollection } from 'antlr4-c3';
|
|
|
2
2
|
import { CharStream, CommonTokenStream, Token } from 'antlr4ng';
|
|
3
3
|
import { PostgreSqlLexer } from '../../lib/postgresql/PostgreSqlLexer';
|
|
4
4
|
import { PostgreSqlParser, ProgramContext } from '../../lib/postgresql/PostgreSqlParser';
|
|
5
|
-
import { Suggestions } from '../common/types';
|
|
6
5
|
import { BasicSQL } from '../common/basicSQL';
|
|
7
|
-
import { PostgreSqlEntityCollector } from './postgreEntityCollector';
|
|
8
|
-
import { PostgreSqlSplitListener } from './postgreSplitListener';
|
|
9
6
|
import { ErrorListener } from '../common/parseErrorListener';
|
|
7
|
+
import { Suggestions } from '../common/types';
|
|
8
|
+
import { PostgreSqlEntityCollector } from './postgreEntityCollector';
|
|
10
9
|
import { PostgreSqlErrorListener } from './postgreErrorListener';
|
|
10
|
+
import { PostgreSqlSplitListener } from './postgreSplitListener';
|
|
11
11
|
export { PostgreSqlEntityCollector, PostgreSqlSplitListener };
|
|
12
12
|
export declare class PostgreSQL extends BasicSQL<PostgreSqlLexer, ProgramContext, PostgreSqlParser> {
|
|
13
13
|
protected createLexerFromCharStream(charStreams: CharStream): PostgreSqlLexer;
|
|
@@ -15,6 +15,6 @@ export declare class PostgreSQL extends BasicSQL<PostgreSqlLexer, ProgramContext
|
|
|
15
15
|
protected preferredRules: Set<number>;
|
|
16
16
|
protected get splitListener(): PostgreSqlSplitListener;
|
|
17
17
|
protected createErrorListener(_errorListener: ErrorListener): PostgreSqlErrorListener;
|
|
18
|
-
protected createEntityCollector(input: string, caretTokenIndex?: number): PostgreSqlEntityCollector;
|
|
18
|
+
protected createEntityCollector(input: string, allTokens?: Token[], caretTokenIndex?: number): PostgreSqlEntityCollector;
|
|
19
19
|
protected processCandidates(candidates: CandidatesCollection, allTokens: Token[], caretTokenIndex: number, tokenIndexOffset: number): Suggestions<Token>;
|
|
20
20
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PostgreSqlLexer } from '../../lib/postgresql/PostgreSqlLexer';
|
|
2
2
|
import { PostgreSqlParser } from '../../lib/postgresql/PostgreSqlParser';
|
|
3
|
-
import { EntityContextType } from '../common/types';
|
|
4
3
|
import { BasicSQL } from '../common/basicSQL';
|
|
4
|
+
import { EntityContextType } from '../common/types';
|
|
5
5
|
import { PostgreSqlEntityCollector } from './postgreEntityCollector';
|
|
6
|
-
import { PostgreSqlSplitListener } from './postgreSplitListener';
|
|
7
6
|
import { PostgreSqlErrorListener } from './postgreErrorListener';
|
|
7
|
+
import { PostgreSqlSplitListener } from './postgreSplitListener';
|
|
8
8
|
export { PostgreSqlEntityCollector, PostgreSqlSplitListener };
|
|
9
9
|
export class PostgreSQL extends BasicSQL {
|
|
10
10
|
constructor() {
|
|
@@ -39,8 +39,8 @@ export class PostgreSQL extends BasicSQL {
|
|
|
39
39
|
const parserContext = this;
|
|
40
40
|
return new PostgreSqlErrorListener(_errorListener, parserContext, this.preferredRules);
|
|
41
41
|
}
|
|
42
|
-
createEntityCollector(input, caretTokenIndex) {
|
|
43
|
-
return new PostgreSqlEntityCollector(input, caretTokenIndex);
|
|
42
|
+
createEntityCollector(input, allTokens, caretTokenIndex) {
|
|
43
|
+
return new PostgreSqlEntityCollector(input, allTokens, caretTokenIndex);
|
|
44
44
|
}
|
|
45
45
|
processCandidates(candidates, allTokens, caretTokenIndex, tokenIndexOffset) {
|
|
46
46
|
const originalSyntaxSuggestions = [];
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { CharStream, CommonTokenStream, Token } from 'antlr4ng';
|
|
2
1
|
import { CandidatesCollection } from 'antlr4-c3';
|
|
2
|
+
import { CharStream, CommonTokenStream, Token } from 'antlr4ng';
|
|
3
3
|
import { SparkSqlLexer } from '../../lib/spark/SparkSqlLexer';
|
|
4
|
-
import {
|
|
4
|
+
import { ProgramContext, SparkSqlParser } from '../../lib/spark/SparkSqlParser';
|
|
5
5
|
import { BasicSQL } from '../common/basicSQL';
|
|
6
|
+
import { ErrorListener } from '../common/parseErrorListener';
|
|
6
7
|
import { Suggestions } from '../common/types';
|
|
7
|
-
import { SparkSqlSplitListener } from './sparkSplitListener';
|
|
8
8
|
import { SparkEntityCollector } from './sparkEntityCollector';
|
|
9
9
|
import { SparkErrorListener } from './sparkErrorListener';
|
|
10
|
-
import {
|
|
11
|
-
export {
|
|
10
|
+
import { SparkSqlSplitListener } from './sparkSplitListener';
|
|
11
|
+
export { SparkEntityCollector, SparkSqlSplitListener };
|
|
12
12
|
export declare class SparkSQL extends BasicSQL<SparkSqlLexer, ProgramContext, SparkSqlParser> {
|
|
13
13
|
protected createLexerFromCharStream(charStreams: CharStream): SparkSqlLexer;
|
|
14
14
|
protected createParserFromTokenStream(tokenStream: CommonTokenStream): SparkSqlParser;
|
|
15
15
|
protected preferredRules: Set<number>;
|
|
16
16
|
protected get splitListener(): SparkSqlSplitListener;
|
|
17
17
|
protected createErrorListener(_errorListener: ErrorListener): SparkErrorListener;
|
|
18
|
-
protected createEntityCollector(input: string, caretTokenIndex?: number): SparkEntityCollector;
|
|
18
|
+
protected createEntityCollector(input: string, allTokens?: Token[], caretTokenIndex?: number): SparkEntityCollector;
|
|
19
19
|
protected processCandidates(candidates: CandidatesCollection, allTokens: Token[], caretTokenIndex: number, tokenIndexOffset: number): Suggestions<Token>;
|
|
20
20
|
}
|
|
@@ -2,10 +2,10 @@ import { SparkSqlLexer } from '../../lib/spark/SparkSqlLexer';
|
|
|
2
2
|
import { SparkSqlParser } from '../../lib/spark/SparkSqlParser';
|
|
3
3
|
import { BasicSQL } from '../common/basicSQL';
|
|
4
4
|
import { EntityContextType } from '../common/types';
|
|
5
|
-
import { SparkSqlSplitListener } from './sparkSplitListener';
|
|
6
5
|
import { SparkEntityCollector } from './sparkEntityCollector';
|
|
7
6
|
import { SparkErrorListener } from './sparkErrorListener';
|
|
8
|
-
|
|
7
|
+
import { SparkSqlSplitListener } from './sparkSplitListener';
|
|
8
|
+
export { SparkEntityCollector, SparkSqlSplitListener };
|
|
9
9
|
export class SparkSQL extends BasicSQL {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments);
|
|
@@ -35,8 +35,8 @@ export class SparkSQL extends BasicSQL {
|
|
|
35
35
|
const parserContext = this;
|
|
36
36
|
return new SparkErrorListener(_errorListener, parserContext, this.preferredRules);
|
|
37
37
|
}
|
|
38
|
-
createEntityCollector(input, caretTokenIndex) {
|
|
39
|
-
return new SparkEntityCollector(input, caretTokenIndex);
|
|
38
|
+
createEntityCollector(input, allTokens, caretTokenIndex) {
|
|
39
|
+
return new SparkEntityCollector(input, allTokens, caretTokenIndex);
|
|
40
40
|
}
|
|
41
41
|
processCandidates(candidates, allTokens, caretTokenIndex, tokenIndexOffset) {
|
|
42
42
|
const originalSyntaxSuggestions = [];
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { CharStream, CommonTokenStream, Token } from 'antlr4ng';
|
|
2
1
|
import { CandidatesCollection } from 'antlr4-c3';
|
|
2
|
+
import { CharStream, CommonTokenStream, Token } from 'antlr4ng';
|
|
3
3
|
import { TrinoSqlLexer } from '../../lib/trino/TrinoSqlLexer';
|
|
4
|
-
import {
|
|
4
|
+
import { ProgramContext, TrinoSqlParser } from '../../lib/trino/TrinoSqlParser';
|
|
5
5
|
import { BasicSQL } from '../common/basicSQL';
|
|
6
|
+
import { ErrorListener } from '../common/parseErrorListener';
|
|
6
7
|
import { Suggestions } from '../common/types';
|
|
7
|
-
import { TrinoSqlSplitListener } from './trinoSplitListener';
|
|
8
8
|
import { TrinoEntityCollector } from './trinoEntityCollector';
|
|
9
|
-
import { ErrorListener } from '../common/parseErrorListener';
|
|
10
9
|
import { TrinoErrorListener } from './trinoErrorListener';
|
|
11
|
-
|
|
10
|
+
import { TrinoSqlSplitListener } from './trinoSplitListener';
|
|
11
|
+
export { TrinoEntityCollector, TrinoSqlSplitListener };
|
|
12
12
|
export declare class TrinoSQL extends BasicSQL<TrinoSqlLexer, ProgramContext, TrinoSqlParser> {
|
|
13
13
|
protected createLexerFromCharStream(charStreams: CharStream): TrinoSqlLexer;
|
|
14
14
|
protected createParserFromTokenStream(tokenStream: CommonTokenStream): TrinoSqlParser;
|
|
15
15
|
protected get splitListener(): TrinoSqlSplitListener;
|
|
16
16
|
protected createErrorListener(_errorListener: ErrorListener): TrinoErrorListener;
|
|
17
|
-
protected createEntityCollector(input: string, caretTokenIndex?: number): TrinoEntityCollector;
|
|
17
|
+
protected createEntityCollector(input: string, allTokens?: Token[], caretTokenIndex?: number): TrinoEntityCollector;
|
|
18
18
|
protected preferredRules: Set<number>;
|
|
19
19
|
protected processCandidates(candidates: CandidatesCollection, allTokens: Token[], caretTokenIndex: number, tokenIndexOffset: number): Suggestions<Token>;
|
|
20
20
|
}
|
|
@@ -2,10 +2,10 @@ import { TrinoSqlLexer } from '../../lib/trino/TrinoSqlLexer';
|
|
|
2
2
|
import { TrinoSqlParser } from '../../lib/trino/TrinoSqlParser';
|
|
3
3
|
import { BasicSQL } from '../common/basicSQL';
|
|
4
4
|
import { EntityContextType } from '../common/types';
|
|
5
|
-
import { TrinoSqlSplitListener } from './trinoSplitListener';
|
|
6
5
|
import { TrinoEntityCollector } from './trinoEntityCollector';
|
|
7
6
|
import { TrinoErrorListener } from './trinoErrorListener';
|
|
8
|
-
|
|
7
|
+
import { TrinoSqlSplitListener } from './trinoSplitListener';
|
|
8
|
+
export { TrinoEntityCollector, TrinoSqlSplitListener };
|
|
9
9
|
export class TrinoSQL extends BasicSQL {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments);
|
|
@@ -37,8 +37,8 @@ export class TrinoSQL extends BasicSQL {
|
|
|
37
37
|
const parserContext = this;
|
|
38
38
|
return new TrinoErrorListener(_errorListener, parserContext, this.preferredRules);
|
|
39
39
|
}
|
|
40
|
-
createEntityCollector(input, caretTokenIndex) {
|
|
41
|
-
return new TrinoEntityCollector(input, caretTokenIndex);
|
|
40
|
+
createEntityCollector(input, allTokens, caretTokenIndex) {
|
|
41
|
+
return new TrinoEntityCollector(input, allTokens, caretTokenIndex);
|
|
42
42
|
}
|
|
43
43
|
processCandidates(candidates, allTokens, caretTokenIndex, tokenIndexOffset) {
|
|
44
44
|
const originalSyntaxSuggestions = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dt-sql-parser",
|
|
3
|
-
"version": "4.1.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"authors": "DTStack Corporation",
|
|
5
5
|
"description": "SQL Parsers for BigData, built with antlr4",
|
|
6
6
|
"keywords": [
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"chalk": "4.1.2",
|
|
56
56
|
"commitizen": "^4.3.0",
|
|
57
57
|
"console-table-printer": "^2.12.0",
|
|
58
|
+
"crypto": "^1.0.1",
|
|
58
59
|
"envinfo": "^7.11.1",
|
|
59
60
|
"glob": "^10.3.10",
|
|
60
61
|
"husky": "^8.0.3",
|