@@ -379,8 +379,16 @@ function documentSymbol(msg: p.RequestMessage) {
379
379
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentSymbol
380
380
let params = msg . params as p . DocumentSymbolParams ;
381
381
let filePath = fileURLToPath ( params . textDocument . uri ) ;
382
- let code = getOpenedFileContent ( params . textDocument . uri ) ;
383
382
let extension = path . extname ( params . textDocument . uri ) ;
383
+ if ( extension !== c . resExt && extension !== c . resiExt ) {
384
+ // Can be called on renamed extension after rename
385
+ return {
386
+ jsonrpc : c . jsonrpcVersion ,
387
+ id : msg . id ,
388
+ result : null ,
389
+ } ;
390
+ }
391
+ let code = getOpenedFileContent ( params . textDocument . uri ) ;
384
392
let tmpname = utils . createFileInTempDir ( extension ) ;
385
393
fs . writeFileSync ( tmpname , code , { encoding : "utf-8" } ) ;
386
394
let response = utils . runAnalysisCommand (
@@ -397,8 +405,16 @@ function semanticTokens(msg: p.RequestMessage) {
397
405
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_semanticTokens
398
406
let params = msg . params as p . SemanticTokensParams ;
399
407
let filePath = fileURLToPath ( params . textDocument . uri ) ;
400
- let code = getOpenedFileContent ( params . textDocument . uri ) ;
401
408
let extension = path . extname ( params . textDocument . uri ) ;
409
+ if ( extension !== c . resExt && extension !== c . resiExt ) {
410
+ // Can be called on renamed extension after rename
411
+ return {
412
+ jsonrpc : c . jsonrpcVersion ,
413
+ id : msg . id ,
414
+ result : null ,
415
+ } ;
416
+ }
417
+ let code = getOpenedFileContent ( params . textDocument . uri ) ;
402
418
let tmpname = utils . createFileInTempDir ( extension ) ;
403
419
fs . writeFileSync ( tmpname , code , { encoding : "utf-8" } ) ;
404
420
let response = utils . runAnalysisCommand (
0 commit comments