@@ -20,6 +20,7 @@ import { assert } from "console";
20
20
import { fileURLToPath } from "url" ;
21
21
import { ChildProcess } from "child_process" ;
22
22
import { Location } from "vscode-languageserver" ;
23
+ import { SymbolInformation } from "vscode-languageserver" ;
23
24
24
25
// https://microsoft.github.io/language-server-protocol/specification#initialize
25
26
// According to the spec, there could be requests before the 'initialize' request. Link in comment tells how to handle them.
@@ -297,6 +298,7 @@ function onMessage(msg: m.Message) {
297
298
hoverProvider : true ,
298
299
definitionProvider : true ,
299
300
referencesProvider : true ,
301
+ documentSymbolProvider : true ,
300
302
completionProvider : { triggerCharacters : [ "." , ">" , "@" , "~" ] } ,
301
303
} ,
302
304
} ;
@@ -394,6 +396,20 @@ function onMessage(msg: m.Message) {
394
396
// error: code and message set in case an exception happens during the definition request.
395
397
} ;
396
398
send ( definitionResponse ) ;
399
+ } else if ( msg . method === p . DocumentSymbolRequest . method ) {
400
+ // https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentSymbol
401
+ let result :
402
+ | SymbolInformation [ ]
403
+ | null = utils . runAnalysisAfterSanityCheck ( msg , ( filePath ) => [
404
+ "documentSymbol" ,
405
+ filePath ,
406
+ ] ) ;
407
+ let definitionResponse : m . ResponseMessage = {
408
+ jsonrpc : c . jsonrpcVersion ,
409
+ id : msg . id ,
410
+ result,
411
+ } ;
412
+ send ( definitionResponse ) ;
397
413
} else if ( msg . method === p . CompletionRequest . method ) {
398
414
let code = getOpenedFileContent ( msg . params . textDocument . uri ) ;
399
415
let tmpname = utils . createFileInTempDir ( ) ;
0 commit comments