Skip to content

Commit

Permalink
Remove console logging for parsing errors (parsing errors are expecte…
Browse files Browse the repository at this point in the history
…d when autocompleting)
  • Loading branch information
mtriff committed Oct 30, 2020
1 parent f37ca14 commit f069c29
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sql-autocomplete",
"version": "1.0.1",
"version": "1.0.2",
"description": "Autocomplete recommendations for SQL statements. Supports PostgreSQL, MySQL, SQL Server and Oracle (PL/SQL) dialects.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -29,10 +29,10 @@
"bugs": {
"url": "https://github.com/modeldba/sql-autocomplete/issues"
},
"homepage": "https://github.com/modeldba/sql-autocomplete#readme",
"homepage": "https://modeldba.com/sql-autocomplete",
"dependencies": {
"antlr4-c3": "^1.1.12",
"antlr4ts-sql": "^1.0.2"
"antlr4ts-sql": "^1.0.3"
},
"devDependencies": {
"jest": "^26.5.2",
Expand Down
11 changes: 7 additions & 4 deletions src/SQLAutocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class SQLAutocomplete {
// it's not needed and keeping it in may impact which token gets selected for prediction
sqlScript = sqlScript.substring(0, atIndex);
}
const tokens = this.antlr4tssql.getTokens(sqlScript);
const tokens = this._getTokens(sqlScript);
const parser = this._getParser(tokens);
const core = new CodeCompletionCore(parser);
const preferredRulesTable = this._getPreferredRulesForTable();
Expand Down Expand Up @@ -92,14 +92,17 @@ export class SQLAutocomplete {
return autocompleteOptions;
}

_getTokens(sqlScript: string): CommonTokenStream {
const tokens = this.antlr4tssql.getTokens(sqlScript, []);
return tokens;
}

_getParser(tokens: CommonTokenStream): Parser {
let parser = this.antlr4tssql.getParser(tokens);
parser.removeErrorListener(ConsoleErrorListener.INSTANCE);
let parser = this.antlr4tssql.getParser(tokens, []);
parser.interpreter.setPredictionMode(PredictionMode.LL);
return parser;
}


_tokenizeWhitespace() {
if (this.dialect === SQLDialect.TSQL) {
return false; // TSQL grammar SKIPs whitespace
Expand Down

0 comments on commit f069c29

Please sign in to comment.