Made a getThisContainer function.

This commit is contained in:
Daniel Rosenwasser 2014-09-05 12:14:50 -07:00
parent a6a6d77d4a
commit 84e385ddfa
2 changed files with 10 additions and 8 deletions

View file

@ -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;
}

View file

@ -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: