@@ -305,11 +305,11 @@ namespace ts.FindAllReferences.Core {
305
305
const labelDefinition = getTargetLabel ( ( < BreakOrContinueStatement > node . parent ) , ( < Identifier > node ) . text ) ;
306
306
// if we have a label definition, look within its statement for references, if not, then
307
307
// the label is undefined and we have no results..
308
- return labelDefinition && getLabelReferencesInNode ( labelDefinition . parent , labelDefinition , cancellationToken ) ;
308
+ return labelDefinition && getLabelReferencesInNode ( labelDefinition . parent , labelDefinition ) ;
309
309
}
310
310
else {
311
311
// it is a label definition and not a target, search within the parent labeledStatement
312
- return getLabelReferencesInNode ( node . parent , < Identifier > node , cancellationToken ) ;
312
+ return getLabelReferencesInNode ( node . parent , < Identifier > node ) ;
313
313
}
314
314
}
315
315
@@ -318,7 +318,7 @@ namespace ts.FindAllReferences.Core {
318
318
}
319
319
320
320
if ( node . kind === SyntaxKind . SuperKeyword ) {
321
- return getReferencesForSuperKeyword ( node , cancellationToken ) ;
321
+ return getReferencesForSuperKeyword ( node ) ;
322
322
}
323
323
324
324
return undefined ;
@@ -460,7 +460,7 @@ namespace ts.FindAllReferences.Core {
460
460
} ;
461
461
462
462
function getImportSearches ( exportSymbol : Symbol , exportInfo : ExportInfo ) : ImportsResult {
463
- if ( ! importTracker ) importTracker = createImportTracker ( sourceFiles , checker ) ;
463
+ if ( ! importTracker ) importTracker = createImportTracker ( sourceFiles , checker , cancellationToken ) ;
464
464
return importTracker ( exportSymbol , exportInfo , options . isForRename ) ;
465
465
}
466
466
@@ -515,7 +515,6 @@ namespace ts.FindAllReferences.Core {
515
515
516
516
// For each import, find all references to that import in its source file.
517
517
for ( const [ importLocation , importSymbol ] of importSearches ) {
518
- state . cancellationToken . throwIfCancellationRequested ( ) ;
519
518
getReferencesInSourceFile ( importLocation . getSourceFile ( ) , state . createSearch ( importLocation , importSymbol , ImportExport . Export ) , state ) ;
520
519
}
521
520
@@ -534,7 +533,6 @@ namespace ts.FindAllReferences.Core {
534
533
}
535
534
if ( indirectSearch ) {
536
535
for ( const indirectUser of indirectUsers ) {
537
- state . cancellationToken . throwIfCancellationRequested ( ) ;
538
536
searchForName ( indirectUser , indirectSearch , state ) ;
539
537
}
540
538
}
@@ -648,7 +646,7 @@ namespace ts.FindAllReferences.Core {
648
646
return parent ? scope . getSourceFile ( ) : scope ;
649
647
}
650
648
651
- function getPossibleSymbolReferencePositions ( sourceFile : SourceFile , symbolName : string , start : number , end : number , cancellationToken : CancellationToken ) : number [ ] {
649
+ function getPossibleSymbolReferencePositions ( sourceFile : SourceFile , symbolName : string , start : number , end : number ) : number [ ] {
652
650
const positions : number [ ] = [ ] ;
653
651
654
652
/// TODO: Cache symbol existence for files to save text search
@@ -665,8 +663,6 @@ namespace ts.FindAllReferences.Core {
665
663
666
664
let position = text . indexOf ( symbolName , start ) ;
667
665
while ( position >= 0 ) {
668
- cancellationToken . throwIfCancellationRequested ( ) ;
669
-
670
666
// If we are past the end, stop looking
671
667
if ( position > end ) break ;
672
668
@@ -685,14 +681,12 @@ namespace ts.FindAllReferences.Core {
685
681
return positions ;
686
682
}
687
683
688
- function getLabelReferencesInNode ( container : Node , targetLabel : Identifier , cancellationToken : CancellationToken ) : SymbolAndEntries [ ] {
684
+ function getLabelReferencesInNode ( container : Node , targetLabel : Identifier ) : SymbolAndEntries [ ] {
689
685
const references : Entry [ ] = [ ] ;
690
686
const sourceFile = container . getSourceFile ( ) ;
691
687
const labelName = targetLabel . text ;
692
- const possiblePositions = getPossibleSymbolReferencePositions ( sourceFile , labelName , container . getStart ( ) , container . getEnd ( ) , cancellationToken ) ;
688
+ const possiblePositions = getPossibleSymbolReferencePositions ( sourceFile , labelName , container . getStart ( ) , container . getEnd ( ) ) ;
693
689
for ( const position of possiblePositions ) {
694
- cancellationToken . throwIfCancellationRequested ( ) ;
695
-
696
690
const node = getTouchingWord ( sourceFile , position ) ;
697
691
if ( ! node || node . getWidth ( ) !== labelName . length ) {
698
692
continue ;
@@ -731,15 +725,14 @@ namespace ts.FindAllReferences.Core {
731
725
const references : NodeEntry [ ] = [ ] ;
732
726
for ( const sourceFile of sourceFiles ) {
733
727
cancellationToken . throwIfCancellationRequested ( ) ;
734
- addReferencesForKeywordInFile ( sourceFile , keywordKind , tokenToString ( keywordKind ) , cancellationToken , references ) ;
728
+ addReferencesForKeywordInFile ( sourceFile , keywordKind , tokenToString ( keywordKind ) , references ) ;
735
729
}
736
730
return references . length ? [ { definition : { type : "keyword" , node : references [ 0 ] . node } , references } ] : undefined ;
737
731
}
738
732
739
- function addReferencesForKeywordInFile ( sourceFile : SourceFile , kind : SyntaxKind , searchText : string , cancellationToken : CancellationToken , references : Push < NodeEntry > ) : void {
740
- const possiblePositions = getPossibleSymbolReferencePositions ( sourceFile , searchText , sourceFile . getStart ( ) , sourceFile . getEnd ( ) , cancellationToken ) ;
733
+ function addReferencesForKeywordInFile ( sourceFile : SourceFile , kind : SyntaxKind , searchText : string , references : Push < NodeEntry > ) : void {
734
+ const possiblePositions = getPossibleSymbolReferencePositions ( sourceFile , searchText , sourceFile . getStart ( ) , sourceFile . getEnd ( ) ) ;
741
735
for ( const position of possiblePositions ) {
742
- cancellationToken . throwIfCancellationRequested ( ) ;
743
736
const referenceLocation = getTouchingPropertyName ( sourceFile , position ) ;
744
737
if ( referenceLocation . kind === kind ) {
745
738
references . push ( nodeEntry ( referenceLocation ) ) ;
@@ -748,6 +741,7 @@ namespace ts.FindAllReferences.Core {
748
741
}
749
742
750
743
function getReferencesInSourceFile ( sourceFile : ts . SourceFile , search : Search , state : State ) : void {
744
+ state . cancellationToken . throwIfCancellationRequested ( ) ;
751
745
return getReferencesInContainer ( sourceFile , sourceFile , search , state ) ;
752
746
}
753
747
@@ -762,9 +756,8 @@ namespace ts.FindAllReferences.Core {
762
756
}
763
757
764
758
const start = state . findInComments ? container . getFullStart ( ) : container . getStart ( ) ;
765
- const possiblePositions = getPossibleSymbolReferencePositions ( sourceFile , search . text , start , container . getEnd ( ) , state . cancellationToken ) ;
759
+ const possiblePositions = getPossibleSymbolReferencePositions ( sourceFile , search . text , start , container . getEnd ( ) ) ;
766
760
for ( const position of possiblePositions ) {
767
- state . cancellationToken . throwIfCancellationRequested ( ) ;
768
761
getReferencesAtLocation ( sourceFile , position , search , state ) ;
769
762
}
770
763
}
@@ -1182,7 +1175,7 @@ namespace ts.FindAllReferences.Core {
1182
1175
}
1183
1176
}
1184
1177
1185
- function getReferencesForSuperKeyword ( superKeyword : Node , cancellationToken : CancellationToken ) : SymbolAndEntries [ ] {
1178
+ function getReferencesForSuperKeyword ( superKeyword : Node ) : SymbolAndEntries [ ] {
1186
1179
let searchSpaceNode = getSuperContainer ( superKeyword , /*stopOnFunctions*/ false ) ;
1187
1180
if ( ! searchSpaceNode ) {
1188
1181
return undefined ;
@@ -1208,10 +1201,8 @@ namespace ts.FindAllReferences.Core {
1208
1201
const references : Entry [ ] = [ ] ;
1209
1202
1210
1203
const sourceFile = searchSpaceNode . getSourceFile ( ) ;
1211
- const possiblePositions = getPossibleSymbolReferencePositions ( sourceFile , "super" , searchSpaceNode . getStart ( ) , searchSpaceNode . getEnd ( ) , cancellationToken ) ;
1204
+ const possiblePositions = getPossibleSymbolReferencePositions ( sourceFile , "super" , searchSpaceNode . getStart ( ) , searchSpaceNode . getEnd ( ) ) ;
1212
1205
for ( const position of possiblePositions ) {
1213
- cancellationToken . throwIfCancellationRequested ( ) ;
1214
-
1215
1206
const node = getTouchingWord ( sourceFile , position ) ;
1216
1207
1217
1208
if ( ! node || node . kind !== SyntaxKind . SuperKeyword ) {
@@ -1271,13 +1262,14 @@ namespace ts.FindAllReferences.Core {
1271
1262
let possiblePositions : number [ ] ;
1272
1263
if ( searchSpaceNode . kind === SyntaxKind . SourceFile ) {
1273
1264
forEach ( sourceFiles , sourceFile => {
1274
- possiblePositions = getPossibleSymbolReferencePositions ( sourceFile , "this" , sourceFile . getStart ( ) , sourceFile . getEnd ( ) , cancellationToken ) ;
1265
+ cancellationToken . throwIfCancellationRequested ( ) ;
1266
+ possiblePositions = getPossibleSymbolReferencePositions ( sourceFile , "this" , sourceFile . getStart ( ) , sourceFile . getEnd ( ) ) ;
1275
1267
getThisReferencesInFile ( sourceFile , sourceFile , possiblePositions , references ) ;
1276
1268
} ) ;
1277
1269
}
1278
1270
else {
1279
1271
const sourceFile = searchSpaceNode . getSourceFile ( ) ;
1280
- possiblePositions = getPossibleSymbolReferencePositions ( sourceFile , "this" , searchSpaceNode . getStart ( ) , searchSpaceNode . getEnd ( ) , cancellationToken ) ;
1272
+ possiblePositions = getPossibleSymbolReferencePositions ( sourceFile , "this" , searchSpaceNode . getStart ( ) , searchSpaceNode . getEnd ( ) ) ;
1281
1273
getThisReferencesInFile ( sourceFile , searchSpaceNode , possiblePositions , references ) ;
1282
1274
}
1283
1275
@@ -1288,8 +1280,6 @@ namespace ts.FindAllReferences.Core {
1288
1280
1289
1281
function getThisReferencesInFile ( sourceFile : SourceFile , searchSpaceNode : Node , possiblePositions : number [ ] , result : Entry [ ] ) : void {
1290
1282
forEach ( possiblePositions , position => {
1291
- cancellationToken . throwIfCancellationRequested ( ) ;
1292
-
1293
1283
const node = getTouchingWord ( sourceFile , position ) ;
1294
1284
if ( ! node || ! isThis ( node ) ) {
1295
1285
return ;
@@ -1333,7 +1323,7 @@ namespace ts.FindAllReferences.Core {
1333
1323
1334
1324
for ( const sourceFile of sourceFiles ) {
1335
1325
cancellationToken . throwIfCancellationRequested ( ) ;
1336
- const possiblePositions = getPossibleSymbolReferencePositions ( sourceFile , node . text , sourceFile . getStart ( ) , sourceFile . getEnd ( ) , cancellationToken ) ;
1326
+ const possiblePositions = getPossibleSymbolReferencePositions ( sourceFile , node . text , sourceFile . getStart ( ) , sourceFile . getEnd ( ) ) ;
1337
1327
getReferencesForStringLiteralInFile ( sourceFile , node . text , possiblePositions , references ) ;
1338
1328
}
1339
1329
0 commit comments