|
1 | | -import { ANTLRInputStream, CommonTokenStream } from 'antlr4ts'; |
| 1 | +import { CharStream, CommonTokenStream } from 'antlr4'; |
2 | 2 | import { Diagnostic } from 'vscode-languageserver'; |
3 | 3 | import { SafeErrorListener, SafeErrorStrategy } from './ErrorListeners'; |
4 | | -import { CashScriptLexer } from './grammar/CashScriptLexer'; |
5 | | -import { CashScriptParser } from './grammar/CashScriptParser'; |
| 4 | +import CashScriptLexer from './grammar/CashScriptLexer'; |
| 5 | +import CashScriptParser from './grammar/CashScriptParser'; |
6 | 6 |
|
7 | 7 | export default class CashscriptLinter { |
8 | | - |
9 | | - static getDiagnostics(code:string):Diagnostic[]{ |
10 | | - |
| 8 | + static getDiagnostics(code: string): Diagnostic[] { |
11 | 9 | const errListener = new SafeErrorListener(); |
12 | 10 |
|
13 | | - const inputStream = new ANTLRInputStream(code); |
| 11 | + const inputStream = new CharStream(code); |
14 | 12 | const lexer = new CashScriptLexer(inputStream); |
15 | 13 | lexer.removeErrorListeners(); |
16 | 14 | lexer.addErrorListener(errListener); |
17 | 15 |
|
18 | 16 | const tokenStream = new CommonTokenStream(lexer); |
19 | 17 | const parser = new CashScriptParser(tokenStream); |
20 | | - parser.errorHandler = new SafeErrorStrategy(); |
| 18 | + parser._errHandler = new SafeErrorStrategy(); |
21 | 19 | parser.removeErrorListeners(); |
22 | 20 | parser.addErrorListener(errListener); |
23 | 21 | const parseTree = parser.sourceFile(); |
24 | | - |
| 22 | + |
25 | 23 | return errListener.getErrs() |
26 | 24 | } |
27 | 25 |
|
28 | 26 | } |
29 | | - |
30 | | - |
0 commit comments