@@ -2088,7 +2088,7 @@ module ts {
2088
2088
}
2089
2089
2090
2090
// TODO: this is a hack for now, we need a proper walking mechanism to verify that we have the correct node
2091
- var mappedNode = getTokenAtPosition ( sourceFile , TypeScript . end ( node ) - 1 , /*includeItemAtEndPosition*/ undefined ) ;
2091
+ var mappedNode = getTokenAtPosition ( sourceFile , TypeScript . end ( node ) - 1 ) ;
2092
2092
if ( isPunctuation ( mappedNode . kind ) ) {
2093
2093
mappedNode = mappedNode . parent ;
2094
2094
}
@@ -2325,7 +2325,7 @@ module ts {
2325
2325
2326
2326
fileName = TypeScript . switchToForwardSlashes ( fileName ) ;
2327
2327
var sourceFile = getSourceFile ( fileName ) ;
2328
- var node = getTokenAtPosition ( sourceFile , position , /*includeItemAtEndPosition*/ undefined ) ;
2328
+ var node = getTouchingPropertyName ( sourceFile , position ) ;
2329
2329
if ( ! node ) {
2330
2330
return undefined ;
2331
2331
}
@@ -2434,7 +2434,7 @@ module ts {
2434
2434
2435
2435
fileName = TypeScript . switchToForwardSlashes ( fileName ) ;
2436
2436
var sourceFile = getSourceFile ( fileName ) ;
2437
- var node = getTokenAtPosition ( sourceFile , position , /*includeItemAtEndPosition*/ undefined ) ;
2437
+ var node = getTouchingWord ( sourceFile , position ) ;
2438
2438
if ( ! node ) {
2439
2439
return undefined ;
2440
2440
}
@@ -2512,25 +2512,12 @@ module ts {
2512
2512
return false ;
2513
2513
}
2514
2514
2515
- function isValidGotoDefinitionTarget ( n : Node ) : boolean {
2516
- switch ( n . kind ) {
2517
- case SyntaxKind . Identifier :
2518
- case SyntaxKind . SuperKeyword :
2519
- case SyntaxKind . ThisKeyword :
2520
- case SyntaxKind . NumericLiteral :
2521
- case SyntaxKind . StringLiteral :
2522
- return true ;
2523
- default :
2524
- return false ;
2525
- }
2526
- }
2527
-
2528
2515
synchronizeHostData ( ) ;
2529
2516
2530
2517
filename = TypeScript . switchToForwardSlashes ( filename ) ;
2531
2518
var sourceFile = getSourceFile ( filename ) ;
2532
2519
2533
- var node = getTokenAtPosition ( sourceFile , position , isValidGotoDefinitionTarget ) ;
2520
+ var node = getTouchingPropertyName ( sourceFile , position ) ;
2534
2521
if ( ! node ) {
2535
2522
return undefined ;
2536
2523
}
@@ -2594,7 +2581,7 @@ module ts {
2594
2581
filename = TypeScript . switchToForwardSlashes ( filename ) ;
2595
2582
var sourceFile = getSourceFile ( filename ) ;
2596
2583
2597
- var node = getTokenAtPosition ( sourceFile , position , isValidFindOccurencesTarget ) ;
2584
+ var node = getTouchingWord ( sourceFile , position ) ;
2598
2585
if ( ! node ) {
2599
2586
return undefined ;
2600
2587
}
@@ -2660,32 +2647,6 @@ module ts {
2660
2647
2661
2648
return undefined ;
2662
2649
2663
- function isValidFindOccurencesTarget ( n : Node ) : boolean {
2664
- switch ( n . kind ) {
2665
- case SyntaxKind . Identifier :
2666
- case SyntaxKind . SuperKeyword :
2667
- case SyntaxKind . ThisKeyword :
2668
- case SyntaxKind . IfKeyword :
2669
- case SyntaxKind . ElseKeyword :
2670
- case SyntaxKind . ReturnKeyword :
2671
- case SyntaxKind . TryKeyword :
2672
- case SyntaxKind . CatchKeyword :
2673
- case SyntaxKind . FinallyKeyword :
2674
- case SyntaxKind . SwitchKeyword :
2675
- case SyntaxKind . CaseKeyword :
2676
- case SyntaxKind . DefaultKeyword :
2677
- case SyntaxKind . BreakKeyword :
2678
- case SyntaxKind . ContinueKeyword :
2679
- case SyntaxKind . ForKeyword :
2680
- case SyntaxKind . WhileKeyword :
2681
- case SyntaxKind . DoKeyword :
2682
- case SyntaxKind . Constructor :
2683
- return true ;
2684
- default :
2685
- return false ;
2686
- }
2687
- }
2688
-
2689
2650
function getIfElseOccurrences ( ifStatement : IfStatement ) : ReferenceEntry [ ] {
2690
2651
var keywords : Node [ ] = [ ] ;
2691
2652
@@ -2942,7 +2903,7 @@ module ts {
2942
2903
filename = TypeScript . switchToForwardSlashes ( filename ) ;
2943
2904
var sourceFile = getSourceFile ( filename ) ;
2944
2905
2945
- var node = getTokenAtPosition ( sourceFile , position , /*includeItemAtEndPosition*/ undefined ) ;
2906
+ var node = getTouchingPropertyName ( sourceFile , position ) ;
2946
2907
if ( ! node ) {
2947
2908
return undefined ;
2948
2909
}
@@ -3125,7 +3086,7 @@ module ts {
3125
3086
forEach ( possiblePositions , position => {
3126
3087
cancellationToken . throwIfCancellationRequested ( ) ;
3127
3088
3128
- var node = getTokenAtPosition ( sourceFile , position , /*includeItemAtEndPosition*/ undefined ) ;
3089
+ var node = getTouchingWord ( sourceFile , position ) ;
3129
3090
if ( ! node || node . getWidth ( ) !== labelName . length ) {
3130
3091
return ;
3131
3092
}
@@ -3181,7 +3142,7 @@ module ts {
3181
3142
forEach ( possiblePositions , position => {
3182
3143
cancellationToken . throwIfCancellationRequested ( ) ;
3183
3144
3184
- var referenceLocation = getTokenAtPosition ( sourceFile , position , /*includeItemAtEndPosition*/ undefined ) ;
3145
+ var referenceLocation = getTouchingPropertyName ( sourceFile , position ) ;
3185
3146
if ( ! isValidReferencePosition ( referenceLocation , searchText ) ) {
3186
3147
return ;
3187
3148
}
@@ -3233,7 +3194,7 @@ module ts {
3233
3194
forEach ( possiblePositions , position => {
3234
3195
cancellationToken . throwIfCancellationRequested ( ) ;
3235
3196
3236
- var node = getTokenAtPosition ( sourceFile , position , n => n . kind === SyntaxKind . SuperKeyword ) ;
3197
+ var node = getTouchingWord ( sourceFile , position ) ;
3237
3198
3238
3199
if ( ! node || node . kind !== SyntaxKind . SuperKeyword ) {
3239
3200
return ;
@@ -3299,7 +3260,7 @@ module ts {
3299
3260
forEach ( possiblePositions , position => {
3300
3261
cancellationToken . throwIfCancellationRequested ( ) ;
3301
3262
3302
- var node = getTokenAtPosition ( sourceFile , position , n => n . kind === SyntaxKind . ThisKeyword ) ;
3263
+ var node = getTouchingWord ( sourceFile , position ) ;
3303
3264
if ( ! node || node . kind !== SyntaxKind . ThisKeyword ) {
3304
3265
return ;
3305
3266
}
@@ -4345,7 +4306,7 @@ module ts {
4345
4306
fileName = TypeScript . switchToForwardSlashes ( fileName ) ;
4346
4307
var sourceFile = getSourceFile ( fileName ) ;
4347
4308
4348
- var node = getTokenAtPosition ( sourceFile , position , n => n . kind === SyntaxKind . Identifier ) ;
4309
+ var node = getTouchingWord ( sourceFile , position ) ;
4349
4310
4350
4311
// Can only rename an identifier.
4351
4312
if ( node && node . kind === SyntaxKind . Identifier ) {
0 commit comments