Skip to content

Commit 46a51ec

Browse files
committed
feat: use createParser to get parserIns and remove parserWithNewInput
1 parent 3915739 commit 46a51ec

File tree

1 file changed

+4
-32
lines changed

1 file changed

+4
-32
lines changed

src/parser/common/basicSQL.ts

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -214,28 +214,6 @@ export abstract class BasicSQL<
214214
return this._parseTree;
215215
}
216216

217-
/**
218-
* Get the parseTree of the input string.
219-
* @param input source string
220-
* @returns parse and parserTree
221-
*/
222-
private parserWithNewInput(inputSlice: string) {
223-
const lexer = this.createLexer(inputSlice);
224-
lexer.removeErrorListeners();
225-
const tokenStream = new CommonTokenStream(lexer);
226-
tokenStream.fill();
227-
const parser = this.createParserFromTokenStream(tokenStream);
228-
parser.interpreter.predictionMode = PredictionMode.SLL;
229-
parser.removeErrorListeners();
230-
parser.buildParseTrees = true;
231-
parser.errorHandler = new ErrorStrategy();
232-
233-
return {
234-
sqlParserIns: parser,
235-
parseTree: parser.program(),
236-
};
237-
}
238-
239217
/**
240218
* Validate input string and return syntax errors if exists.
241219
* @param input source string
@@ -487,11 +465,8 @@ export abstract class BasicSQL<
487465
* and c3 will collect candidates in the newly generated parseTree when input changed.
488466
*/
489467
if (inputSlice !== input) {
490-
const { sqlParserIns: _sqlParserIns, parseTree: _parseTree } =
491-
this.parserWithNewInput(inputSlice);
492-
493-
sqlParserIns = _sqlParserIns;
494-
parseTree = _parseTree;
468+
sqlParserIns = this.createParser(inputSlice);
469+
parseTree = sqlParserIns.program();
495470
}
496471

497472
return {
@@ -556,11 +531,8 @@ export abstract class BasicSQL<
556531
* and c3 will collect candidates in the newly generated parseTree when input changed.
557532
*/
558533
if (inputSlice !== input) {
559-
const { sqlParserIns: _sqlParserIns, parseTree: _parseTree } =
560-
this.parserWithNewInput(inputSlice);
561-
562-
sqlParserIns = _sqlParserIns;
563-
parseTree = _parseTree;
534+
sqlParserIns = this.createParser(inputSlice);
535+
parseTree = sqlParserIns.program();
564536
}
565537

566538
const core = new CodeCompletionCore(sqlParserIns);

0 commit comments

Comments
 (0)