@@ -2629,7 +2629,7 @@ module ts {
2629
2629
2630
2630
function getReferencesForThisKeyword ( thisKeyword : Node , sourceFiles : SourceFile [ ] ) {
2631
2631
// Get the owner" of the 'this' keyword.
2632
- var thisContainer = getThisContainer ( thisKeyword ) ;
2632
+ var thisContainer = getThisContainer ( thisKeyword , /* includeArrowFunctions */ false ) ;
2633
2633
2634
2634
var searchSpaceNode : Node ;
2635
2635
@@ -2645,9 +2645,13 @@ module ts {
2645
2645
searchSpaceNode = thisContainer . parent ; // should be the owning class
2646
2646
staticFlag &= thisContainer . flags
2647
2647
break ;
2648
+ case SyntaxKind . SourceFile :
2649
+ if ( isExternalModule ( < SourceFile > thisContainer ) ) {
2650
+ return undefined ;
2651
+ }
2652
+ // Fall through
2648
2653
case SyntaxKind . FunctionDeclaration :
2649
2654
case SyntaxKind . FunctionExpression :
2650
- case SyntaxKind . SourceFile :
2651
2655
searchSpaceNode = thisContainer ;
2652
2656
break ;
2653
2657
default :
@@ -2679,8 +2683,9 @@ module ts {
2679
2683
return ;
2680
2684
}
2681
2685
2682
- // Get the owner" of the 'this' keyword.
2683
- var container = getThisContainer ( node ) ;
2686
+ // Get the owner of the 'this' keyword.
2687
+ // This *should* be a node that occurs somewhere within searchSpaceNode.
2688
+ var container = getThisContainer ( node , /* includeArrowFunctions */ false ) ;
2684
2689
2685
2690
switch ( container . kind ) {
2686
2691
case SyntaxKind . Property :
@@ -2702,7 +2707,7 @@ module ts {
2702
2707
break ;
2703
2708
case SyntaxKind . SourceFile :
2704
2709
// Add all 'this' keywords that belong to the top-level scope.
2705
- if ( searchSpaceNode . kind === SyntaxKind . SourceFile ) {
2710
+ if ( searchSpaceNode . kind === SyntaxKind . SourceFile && ! isExternalModule ( < SourceFile > searchSpaceNode ) ) {
2706
2711
result . push ( getReferenceEntryFromNode ( node ) ) ;
2707
2712
}
2708
2713
break ;
@@ -2970,21 +2975,7 @@ module ts {
2970
2975
}
2971
2976
else if ( parent . kind === SyntaxKind . BinaryExpression && ( < BinaryExpression > parent ) . left === node ) {
2972
2977
var operator = ( < BinaryExpression > parent ) . operator ;
2973
- switch ( operator ) {
2974
- case SyntaxKind . AsteriskEqualsToken :
2975
- case SyntaxKind . SlashEqualsToken :
2976
- case SyntaxKind . PercentEqualsToken :
2977
- case SyntaxKind . MinusEqualsToken :
2978
- case SyntaxKind . LessThanLessThanEqualsToken :
2979
- case SyntaxKind . GreaterThanGreaterThanEqualsToken :
2980
- case SyntaxKind . GreaterThanGreaterThanGreaterThanEqualsToken :
2981
- case SyntaxKind . BarEqualsToken :
2982
- case SyntaxKind . CaretEqualsToken :
2983
- case SyntaxKind . AmpersandEqualsToken :
2984
- case SyntaxKind . PlusEqualsToken :
2985
- case SyntaxKind . EqualsToken :
2986
- return true ;
2987
- }
2978
+ return SyntaxKind . FirstAssignment <= operator && operator <= SyntaxKind . LastAssignment ;
2988
2979
}
2989
2980
}
2990
2981
0 commit comments