@@ -98,11 +98,11 @@ interface Tokenized {
9898}
9999
100100export default class QLangServer {
101- private declare connection : Connection ;
102- private declare params : InitializeParams ;
103- private declare settings : Settings ;
104- private declare cached : Map < string , Token [ ] > ;
105- public declare documents : TextDocuments < TextDocument > ;
101+ declare private connection : Connection ;
102+ declare private params : InitializeParams ;
103+ declare private settings : Settings ;
104+ declare private cached : Map < string , Token [ ] > ;
105+ declare public documents : TextDocuments < TextDocument > ;
106106
107107 constructor ( connection : Connection , params : InitializeParams ) {
108108 this . connection = connection ;
@@ -202,8 +202,9 @@ export default class QLangServer {
202202 public onDidChangeContent ( {
203203 document,
204204 } : TextDocumentChangeEvent < TextDocument > ) {
205+ const uri = document . uri ;
206+ this . cached . delete ( uri ) ;
205207 if ( this . settings . linting ) {
206- const uri = document . uri ;
207208 const diagnostics = lint ( this . parse ( document ) ) . map ( ( item ) =>
208209 Diagnostic . create (
209210 rangeFromToken ( item . token ) ,
@@ -502,7 +503,7 @@ export default class QLangServer {
502503 absolute : true ,
503504 nodir : true ,
504505 follow : false ,
505- ignore : " node_modules/**/*.*" ,
506+ ignore : [ "**/ node_modules/**/*" , "**/build/**/*" ] ,
506507 cwd : fileURLToPath ( folder . uri ) ,
507508 } ) ,
508509 ) ;
@@ -522,11 +523,17 @@ export default class QLangServer {
522523 }
523524
524525 private parse ( textDocument : TextDocumentIdentifier ) : Token [ ] {
525- const document = this . documents . get ( textDocument . uri ) ;
526- if ( ! document ) {
527- return [ ] ;
526+ const uri = textDocument . uri ;
527+ let tokens = this . cached . get ( uri ) ;
528+ if ( ! tokens ) {
529+ const document = this . documents . get ( uri ) ;
530+ if ( ! document ) {
531+ return [ ] ;
532+ }
533+ tokens = parse ( document . getText ( ) ) ;
534+ this . cached . set ( uri , tokens ) ;
528535 }
529- return parse ( document . getText ( ) ) ;
536+ return tokens ;
530537 }
531538
532539 private context ( { uri, tokens } : Tokenized , all = true ) : Tokenized [ ] {
0 commit comments