@@ -2629,7 +2629,7 @@ module ts {
26292629
26302630 function getReferencesForThisKeyword ( thisKeyword : Node , sourceFiles : SourceFile [ ] ) {
26312631 // Get the owner" of the 'this' keyword.
2632- var thisContainer = getThisContainer ( thisKeyword ) ;
2632+ var thisContainer = getThisContainer ( thisKeyword , /* includeArrowFunctions */ false ) ;
26332633
26342634 var searchSpaceNode : Node ;
26352635
@@ -2645,9 +2645,13 @@ module ts {
26452645 searchSpaceNode = thisContainer . parent ; // should be the owning class
26462646 staticFlag &= thisContainer . flags
26472647 break ;
2648+ case SyntaxKind . SourceFile :
2649+ if ( isExternalModule ( < SourceFile > thisContainer ) ) {
2650+ return undefined ;
2651+ }
2652+ // Fall through
26482653 case SyntaxKind . FunctionDeclaration :
26492654 case SyntaxKind . FunctionExpression :
2650- case SyntaxKind . SourceFile :
26512655 searchSpaceNode = thisContainer ;
26522656 break ;
26532657 default :
@@ -2679,8 +2683,9 @@ module ts {
26792683 return ;
26802684 }
26812685
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 ) ;
26842689
26852690 switch ( container . kind ) {
26862691 case SyntaxKind . Property :
@@ -2702,7 +2707,7 @@ module ts {
27022707 break ;
27032708 case SyntaxKind . SourceFile :
27042709 // 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 ) ) {
27062711 result . push ( getReferenceEntryFromNode ( node ) ) ;
27072712 }
27082713 break ;
@@ -2970,21 +2975,7 @@ module ts {
29702975 }
29712976 else if ( parent . kind === SyntaxKind . BinaryExpression && ( < BinaryExpression > parent ) . left === node ) {
29722977 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 ;
29882979 }
29892980 }
29902981
0 commit comments