diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 256d611d4e..288781db78 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -430,6 +430,14 @@ module ts { } } + export function getThisContainer(node: Node): Node { + do { + node = getThisContainerOrArrowFunction(node); + } while (node.kind === SyntaxKind.ArrowFunction); + + return node; + } + export function hasRestParameters(s: SignatureDeclaration): boolean { return s.parameters.length > 0 && (s.parameters[s.parameters.length - 1].flags & NodeFlags.Rest) !== 0; } diff --git a/src/services/services.ts b/src/services/services.ts index fb978aa46a..ef9c8cf40c 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2629,10 +2629,7 @@ module ts { function getReferencesForThisKeyword(thisKeyword: Node, sourceFiles: SourceFile[]) { // Get the owner" of the 'this' keyword. - var thisContainer = thisKeyword; - do { - thisContainer = getThisContainerOrArrowFunction(thisContainer); - } while (thisContainer.kind === SyntaxKind.ArrowFunction); + var thisContainer = getThisContainer(thisKeyword); var searchSpaceNode: Node; @@ -2683,10 +2680,7 @@ module ts { } // Get the owner" of the 'this' keyword. - var container = node; - do { - container = getThisContainerOrArrowFunction(container); - } while (container.kind === SyntaxKind.ArrowFunction); + var container = getThisContainer(node); switch (container.kind) { case SyntaxKind.Property: