@@ -289,7 +289,6 @@ namespace ts.server {
289
289
function combineProjectOutputWhileOpeningReferencedProjects < T > (
290
290
projects : Projects ,
291
291
defaultProject : Project ,
292
- projectService : ProjectService ,
293
292
action : ( project : Project ) => ReadonlyArray < T > ,
294
293
getLocation : ( t : T ) => sourcemaps . SourceMappableLocation ,
295
294
resultsEqual : ( a : T , b : T ) => boolean ,
@@ -299,7 +298,6 @@ namespace ts.server {
299
298
projects ,
300
299
defaultProject ,
301
300
/*initialLocation*/ undefined ,
302
- projectService ,
303
301
( { project } , tryAddToTodo ) => {
304
302
for ( const output of action ( project ) ) {
305
303
if ( ! contains ( outputs , output , resultsEqual ) && ! tryAddToTodo ( project , getLocation ( output ) ) ) {
@@ -312,17 +310,27 @@ namespace ts.server {
312
310
}
313
311
314
312
function combineProjectOutputForRenameLocations (
315
- projects : Projects , defaultProject : Project , initialLocation : sourcemaps . SourceMappableLocation , projectService : ProjectService , findInStrings : boolean , findInComments : boolean
313
+ projects : Projects ,
314
+ defaultProject : Project ,
315
+ initialLocation : sourcemaps . SourceMappableLocation ,
316
+ findInStrings : boolean ,
317
+ findInComments : boolean
316
318
) : ReadonlyArray < RenameLocation > {
317
319
const outputs : RenameLocation [ ] = [ ] ;
318
320
319
- combineProjectOutputWorker < sourcemaps . SourceMappableLocation > ( projects , defaultProject , initialLocation , projectService , ( { project, location } , tryAddToTodo ) => {
320
- for ( const output of project . getLanguageService ( ) . findRenameLocations ( location . fileName , location . position , findInStrings , findInComments ) || emptyArray ) {
321
- if ( ! contains ( outputs , output , documentSpansEqual ) && ! tryAddToTodo ( project , documentSpanLocation ( output ) ) ) {
322
- outputs . push ( output ) ;
321
+ combineProjectOutputWorker < sourcemaps . SourceMappableLocation > (
322
+ projects ,
323
+ defaultProject ,
324
+ initialLocation ,
325
+ ( { project, location } , tryAddToTodo ) => {
326
+ for ( const output of project . getLanguageService ( ) . findRenameLocations ( location . fileName , location . position , findInStrings , findInComments ) || emptyArray ) {
327
+ if ( ! contains ( outputs , output , documentSpansEqual ) && ! tryAddToTodo ( project , documentSpanLocation ( output ) ) ) {
328
+ outputs . push ( output ) ;
329
+ }
323
330
}
324
- }
325
- } , ( ) => getDefinitionLocation ( defaultProject , initialLocation ) ) ;
331
+ } ,
332
+ ( ) => getDefinitionLocation ( defaultProject , initialLocation )
333
+ ) ;
326
334
327
335
return outputs ;
328
336
}
@@ -333,31 +341,41 @@ namespace ts.server {
333
341
return info && { fileName : info . fileName , position : info . textSpan . start } ;
334
342
}
335
343
336
- function combineProjectOutputForReferences ( projects : Projects , defaultProject : Project , initialLocation : sourcemaps . SourceMappableLocation , projectService : ProjectService ) : ReadonlyArray < ReferencedSymbol > {
344
+ function combineProjectOutputForReferences (
345
+ projects : Projects ,
346
+ defaultProject : Project ,
347
+ initialLocation : sourcemaps . SourceMappableLocation
348
+ ) : ReadonlyArray < ReferencedSymbol > {
337
349
const outputs : ReferencedSymbol [ ] = [ ] ;
338
350
339
- combineProjectOutputWorker < sourcemaps . SourceMappableLocation > ( projects , defaultProject , initialLocation , projectService , ( { project, location } , getMappedLocation ) => {
340
- for ( const outputReferencedSymbol of project . getLanguageService ( ) . findReferences ( location . fileName , location . position ) || emptyArray ) {
341
- const mappedDefinitionFile = getMappedLocation ( project , documentSpanLocation ( outputReferencedSymbol . definition ) ) ;
342
- const definition : ReferencedSymbolDefinitionInfo = mappedDefinitionFile === undefined ? outputReferencedSymbol . definition : {
343
- ...outputReferencedSymbol . definition ,
344
- textSpan : createTextSpan ( mappedDefinitionFile . position , outputReferencedSymbol . definition . textSpan . length ) ,
345
- fileName : mappedDefinitionFile . fileName ,
346
- } ;
347
- let symbolToAddTo = find ( outputs , o => documentSpansEqual ( o . definition , definition ) ) ;
348
- if ( ! symbolToAddTo ) {
349
- symbolToAddTo = { definition, references : [ ] } ;
350
- outputs . push ( symbolToAddTo ) ;
351
- }
351
+ combineProjectOutputWorker < sourcemaps . SourceMappableLocation > (
352
+ projects ,
353
+ defaultProject ,
354
+ initialLocation ,
355
+ ( { project, location } , getMappedLocation ) => {
356
+ for ( const outputReferencedSymbol of project . getLanguageService ( ) . findReferences ( location . fileName , location . position ) || emptyArray ) {
357
+ const mappedDefinitionFile = getMappedLocation ( project , documentSpanLocation ( outputReferencedSymbol . definition ) ) ;
358
+ const definition : ReferencedSymbolDefinitionInfo = mappedDefinitionFile === undefined ? outputReferencedSymbol . definition : {
359
+ ...outputReferencedSymbol . definition ,
360
+ textSpan : createTextSpan ( mappedDefinitionFile . position , outputReferencedSymbol . definition . textSpan . length ) ,
361
+ fileName : mappedDefinitionFile . fileName ,
362
+ } ;
363
+ let symbolToAddTo = find ( outputs , o => documentSpansEqual ( o . definition , definition ) ) ;
364
+ if ( ! symbolToAddTo ) {
365
+ symbolToAddTo = { definition, references : [ ] } ;
366
+ outputs . push ( symbolToAddTo ) ;
367
+ }
352
368
353
- for ( const ref of outputReferencedSymbol . references ) {
354
- // If it's in a mapped file, that is added to the todo list by `getMappedLocation`.
355
- if ( ! contains ( symbolToAddTo . references , ref , documentSpansEqual ) && ! getMappedLocation ( project , documentSpanLocation ( ref ) ) ) {
356
- symbolToAddTo . references . push ( ref ) ;
369
+ for ( const ref of outputReferencedSymbol . references ) {
370
+ // If it's in a mapped file, that is added to the todo list by `getMappedLocation`.
371
+ if ( ! contains ( symbolToAddTo . references , ref , documentSpansEqual ) && ! getMappedLocation ( project , documentSpanLocation ( ref ) ) ) {
372
+ symbolToAddTo . references . push ( ref ) ;
373
+ }
357
374
}
358
375
}
359
- }
360
- } , ( ) => getDefinitionLocation ( defaultProject , initialLocation ) ) ;
376
+ } ,
377
+ ( ) => getDefinitionLocation ( defaultProject , initialLocation )
378
+ ) ;
361
379
362
380
return outputs . filter ( o => o . references . length !== 0 ) ;
363
381
}
@@ -389,10 +407,10 @@ namespace ts.server {
389
407
projects : Projects ,
390
408
defaultProject : Project ,
391
409
initialLocation : TLocation ,
392
- projectService : ProjectService ,
393
410
cb : CombineProjectOutputCallback < TLocation > ,
394
411
getDefinition : ( ( ) => sourcemaps . SourceMappableLocation | undefined ) | undefined ,
395
412
) : void {
413
+ const projectService = defaultProject . projectService ;
396
414
let toDo : ProjectAndLocation < TLocation > [ ] | undefined ;
397
415
const seenProjects = createMap < true > ( ) ;
398
416
forEachProjectInProjects ( projects , initialLocation && initialLocation . fileName , ( project , path ) => {
@@ -1208,7 +1226,13 @@ namespace ts.server {
1208
1226
const position = this . getPositionInFile ( args , file ) ;
1209
1227
const projects = this . getProjects ( args ) ;
1210
1228
1211
- const locations = combineProjectOutputForRenameLocations ( projects , this . getDefaultProject ( args ) , { fileName : args . file , position } , this . projectService , ! ! args . findInStrings , ! ! args . findInComments ) ;
1229
+ const locations = combineProjectOutputForRenameLocations (
1230
+ projects ,
1231
+ this . getDefaultProject ( args ) ,
1232
+ { fileName : args . file , position } ,
1233
+ ! ! args . findInStrings ,
1234
+ ! ! args . findInComments
1235
+ ) ;
1212
1236
if ( ! simplifiedResult ) return locations ;
1213
1237
1214
1238
const defaultProject = this . getDefaultProject ( args ) ;
@@ -1242,7 +1266,11 @@ namespace ts.server {
1242
1266
const file = toNormalizedPath ( args . file ) ;
1243
1267
const projects = this . getProjects ( args ) ;
1244
1268
const position = this . getPositionInFile ( args , file ) ;
1245
- const references = combineProjectOutputForReferences ( projects , this . getDefaultProject ( args ) , { fileName : args . file , position } , this . projectService ) ;
1269
+ const references = combineProjectOutputForReferences (
1270
+ projects ,
1271
+ this . getDefaultProject ( args ) ,
1272
+ { fileName : args . file , position } ,
1273
+ ) ;
1246
1274
1247
1275
if ( simplifiedResult ) {
1248
1276
const defaultProject = this . getDefaultProject ( args ) ;
@@ -1749,7 +1777,6 @@ namespace ts.server {
1749
1777
return combineProjectOutputWhileOpeningReferencedProjects < NavigateToItem > (
1750
1778
this . getProjects ( args ) ,
1751
1779
this . getDefaultProject ( args ) ,
1752
- this . projectService ,
1753
1780
project =>
1754
1781
project . getLanguageService ( ) . getNavigateToItems ( searchValue , maxResultCount , /*fileName*/ undefined , /*excludeDts*/ project . isNonTsProject ( ) ) ,
1755
1782
documentSpanLocation ,
0 commit comments