@@ -39,7 +39,7 @@ let projectsFiles: Map<
39
39
// ^ caching AND states AND distributed system. Why does LSP has to be stupid like this
40
40
41
41
// 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 = ( _ ) => { } ;
43
43
44
44
let sendUpdatedDiagnostics = ( ) => {
45
45
projectsFiles . forEach ( ( { filesWithDiagnostics } , projectRootPath ) => {
@@ -296,6 +296,7 @@ function onMessage(msg: m.Message) {
296
296
documentFormattingProvider : true ,
297
297
hoverProvider : true ,
298
298
definitionProvider : true ,
299
+ referencesProvider : true ,
299
300
completionProvider : { triggerCharacters : [ "." , ">" , "@" , "~" ] } ,
300
301
} ,
301
302
} ;
@@ -359,7 +360,7 @@ function onMessage(msg: m.Message) {
359
360
send ( hoverResponse ) ;
360
361
} else if ( msg . method === p . DefinitionRequest . method ) {
361
362
// 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 (
363
364
msg ,
364
365
( filePath ) => [
365
366
"definition" ,
@@ -375,19 +376,37 @@ function onMessage(msg: m.Message) {
375
376
// error: code and message set in case an exception happens during the definition request.
376
377
} ;
377
378
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 ) ;
378
397
} else if ( msg . method === p . CompletionRequest . method ) {
379
398
let code = getOpenedFileContent ( msg . params . textDocument . uri ) ;
380
399
let tmpname = utils . createFileInTempDir ( ) ;
381
400
fs . writeFileSync ( tmpname , code , { encoding : "utf-8" } ) ;
382
401
let result :
383
402
| CompletionItem [ ]
384
403
| 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
+ ] ) ;
391
410
fs . unlink ( tmpname , ( ) => null ) ;
392
411
let completionResponse : m . ResponseMessage = {
393
412
jsonrpc : c . jsonrpcVersion ,
0 commit comments