@@ -103,6 +103,7 @@ export class Session {
103
103
conn . onDidSaveTextDocument ( p => this . onDidSaveTextDocument ( p ) ) ;
104
104
conn . onDefinition ( p => this . onDefinition ( p ) ) ;
105
105
conn . onTypeDefinition ( p => this . onTypeDefinition ( p ) ) ;
106
+ conn . onReferences ( p => this . onReferences ( p ) ) ;
106
107
conn . onHover ( p => this . onHover ( p ) ) ;
107
108
conn . onCompletion ( p => this . onCompletion ( p ) ) ;
108
109
conn . onNotification ( notification . NgccComplete , p => this . handleNgccNotification ( p ) ) ;
@@ -262,6 +263,7 @@ export class Session {
262
263
} ,
263
264
definitionProvider : true ,
264
265
typeDefinitionProvider : this . ivy ,
266
+ referencesProvider : this . ivy ,
265
267
hoverProvider : true ,
266
268
workspace : {
267
269
workspaceFolders : { supported : true } ,
@@ -391,6 +393,25 @@ export class Session {
391
393
return this . tsDefinitionsToLspLocationLinks ( definitions ) ;
392
394
}
393
395
396
+ private onReferences ( params : lsp . TextDocumentPositionParams ) : lsp . Location [ ] | undefined {
397
+ const lsInfo = this . getLSAndScriptInfo ( params . textDocument ) ;
398
+ if ( lsInfo === undefined ) {
399
+ return ;
400
+ }
401
+ const { languageService, scriptInfo} = lsInfo ;
402
+ const offset = lspPositionToTsPosition ( scriptInfo , params . position ) ;
403
+ const references = languageService . getReferencesAtPosition ( scriptInfo . fileName , offset ) ;
404
+ if ( references === undefined ) {
405
+ return ;
406
+ }
407
+ return references . map ( ref => {
408
+ const scriptInfo = this . projectService . getScriptInfo ( ref . fileName ) ;
409
+ const range = scriptInfo ? tsTextSpanToLspRange ( scriptInfo , ref . textSpan ) : EMPTY_RANGE ;
410
+ const uri = filePathToUri ( ref . fileName ) ;
411
+ return { uri, range} ;
412
+ } ) ;
413
+ }
414
+
394
415
private tsDefinitionsToLspLocationLinks (
395
416
definitions : readonly ts . DefinitionInfo [ ] ,
396
417
originSelectionRange ?: lsp . Range ) : lsp . LocationLink [ ] {
0 commit comments