dt-sql-parser 4.1.0-beta.6 → 4.1.0-beta.7
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/dist/lib/flink/FlinkSqlParser.d.ts +3 -3
- package/dist/lib/flink/FlinkSqlParser.js +2179 -2147
- package/dist/parser/common/basicSQL.d.ts +17 -0
- package/dist/parser/common/basicSQL.js +53 -22
- package/dist/parser/common/parseErrorListener.d.ts +5 -3
- package/dist/parser/common/parseErrorListener.js +6 -2
- package/dist/parser/flink/flinkErrorListener.d.ts +1 -4
- package/dist/parser/flink/flinkErrorListener.js +14 -5
- package/dist/parser/flink/index.js +2 -1
- package/dist/parser/hive/hiveErrorListener.d.ts +1 -4
- package/dist/parser/hive/hiveErrorListener.js +14 -5
- package/dist/parser/hive/index.js +2 -1
- package/dist/parser/impala/ImpalaErrorListener.d.ts +1 -4
- package/dist/parser/impala/ImpalaErrorListener.js +14 -5
- package/dist/parser/impala/index.js +2 -1
- package/dist/parser/mysql/index.js +2 -1
- package/dist/parser/mysql/mysqlErrorListener.d.ts +1 -4
- package/dist/parser/mysql/mysqlErrorListener.js +14 -5
- package/dist/parser/postgresql/index.js +2 -1
- package/dist/parser/postgresql/postgreErrorListener.d.ts +1 -4
- package/dist/parser/postgresql/postgreErrorListener.js +14 -5
- package/dist/parser/spark/index.js +2 -1
- package/dist/parser/spark/sparkErrorListener.d.ts +1 -4
- package/dist/parser/spark/sparkErrorListener.js +14 -5
- package/dist/parser/trino/index.js +2 -1
- package/dist/parser/trino/trinoErrorListener.d.ts +1 -4
- package/dist/parser/trino/trinoErrorListener.js +14 -5
- package/package.json +1 -1
|
@@ -2,8 +2,8 @@ import { CodeCompletionCore } from 'antlr4-c3';
|
|
|
2
2
|
import { TrinoSqlParser } from '../../lib/trino/TrinoSqlParser';
|
|
3
3
|
import { ParseErrorListener } from '../common/parseErrorListener';
|
|
4
4
|
export class TrinoErrorListener extends ParseErrorListener {
|
|
5
|
-
constructor(
|
|
6
|
-
super(
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
7
|
this.objectNames = new Map([
|
|
8
8
|
[TrinoSqlParser.RULE_catalogRef, 'catalog'],
|
|
9
9
|
[TrinoSqlParser.RULE_catalogNameCreate, 'catalog'],
|
|
@@ -17,18 +17,27 @@ export class TrinoErrorListener extends ParseErrorListener {
|
|
|
17
17
|
[TrinoSqlParser.RULE_columnRef, 'column'],
|
|
18
18
|
[TrinoSqlParser.RULE_columnNameCreate, 'column'],
|
|
19
19
|
]);
|
|
20
|
-
this.preferredRules = preferredRules;
|
|
21
20
|
}
|
|
22
21
|
getExpectedText(parser, token) {
|
|
23
22
|
var _a;
|
|
24
23
|
let expectedText = '';
|
|
24
|
+
const input = this.parserContext.getParsedInput();
|
|
25
|
+
/**
|
|
26
|
+
* Get the program context.
|
|
27
|
+
* When called error listener, `this._parseTree` is still `undefined`,
|
|
28
|
+
* so we can't use cached parseTree in `getMinimumParserInfo`
|
|
29
|
+
*/
|
|
25
30
|
let currentContext = (_a = parser.context) !== null && _a !== void 0 ? _a : undefined;
|
|
26
31
|
while (currentContext === null || currentContext === void 0 ? void 0 : currentContext.parent) {
|
|
27
32
|
currentContext = currentContext.parent;
|
|
28
33
|
}
|
|
29
|
-
const
|
|
34
|
+
const parserInfo = this.parserContext.getMinimumParserInfo(input, token.tokenIndex, currentContext);
|
|
35
|
+
if (!parserInfo)
|
|
36
|
+
return '';
|
|
37
|
+
const { parser: c3Parser, newTokenIndex, parseTree: c3Context } = parserInfo;
|
|
38
|
+
const core = new CodeCompletionCore(c3Parser);
|
|
30
39
|
core.preferredRules = this.preferredRules;
|
|
31
|
-
const candidates = core.collectCandidates(
|
|
40
|
+
const candidates = core.collectCandidates(newTokenIndex, c3Context);
|
|
32
41
|
if (candidates.rules.size) {
|
|
33
42
|
const result = [];
|
|
34
43
|
// get expectedText as collect rules first
|