@@ -39,7 +39,7 @@ let projectsFiles: Map<
3939// ^ caching AND states AND distributed system. Why does LSP has to be stupid like this
4040
4141// will be properly defined later depending on the mode (stdio/node-rpc)
42- let send : ( msg : m . Message ) => void = ( _ ) => { } ;
42+ let send : ( msg : m . Message ) => void = ( _ ) => { } ;
4343
4444let sendUpdatedDiagnostics = ( ) => {
4545 projectsFiles . forEach ( ( { filesWithDiagnostics } , projectRootPath ) => {
@@ -296,6 +296,7 @@ function onMessage(msg: m.Message) {
296296 documentFormattingProvider : true ,
297297 hoverProvider : true ,
298298 definitionProvider : true ,
299+ referencesProvider : true ,
299300 completionProvider : { triggerCharacters : [ "." , ">" , "@" , "~" ] } ,
300301 } ,
301302 } ;
@@ -359,7 +360,7 @@ function onMessage(msg: m.Message) {
359360 send ( hoverResponse ) ;
360361 } else if ( msg . method === p . DefinitionRequest . method ) {
361362 // https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition
362- let result : Location | null = utils . runAnalysisAfterSanityCheck (
363+ let result : Location [ ] | null = utils . runAnalysisAfterSanityCheck (
363364 msg ,
364365 ( filePath ) => [
365366 "definition" ,
@@ -375,19 +376,37 @@ function onMessage(msg: m.Message) {
375376 // error: code and message set in case an exception happens during the definition request.
376377 } ;
377378 send ( definitionResponse ) ;
379+ } else if ( msg . method === p . ReferencesRequest . method ) {
380+ // https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references
381+ let result : Location | null = utils . runAnalysisAfterSanityCheck (
382+ msg ,
383+ ( filePath ) => [
384+ "references" ,
385+ filePath ,
386+ msg . params . position . line ,
387+ msg . params . position . character ,
388+ ]
389+ ) ;
390+ let definitionResponse : m . ResponseMessage = {
391+ jsonrpc : c . jsonrpcVersion ,
392+ id : msg . id ,
393+ result,
394+ // error: code and message set in case an exception happens during the definition request.
395+ } ;
396+ send ( definitionResponse ) ;
378397 } else if ( msg . method === p . CompletionRequest . method ) {
379398 let code = getOpenedFileContent ( msg . params . textDocument . uri ) ;
380399 let tmpname = utils . createFileInTempDir ( ) ;
381400 fs . writeFileSync ( tmpname , code , { encoding : "utf-8" } ) ;
382401 let result :
383402 | CompletionItem [ ]
384403 | null = utils . runAnalysisAfterSanityCheck ( msg , ( filePath ) => [
385- "complete" ,
386- filePath ,
387- msg . params . position . line ,
388- msg . params . position . character ,
389- tmpname ,
390- ] ) ;
404+ "complete" ,
405+ filePath ,
406+ msg . params . position . line ,
407+ msg . params . position . character ,
408+ tmpname ,
409+ ] ) ;
391410 fs . unlink ( tmpname , ( ) => null ) ;
392411 let completionResponse : m . ResponseMessage = {
393412 jsonrpc : c . jsonrpcVersion ,
0 commit comments