mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-26 10:43:51 -05:00
getRefs/getOccs support for 'this' keyword.
This commit is contained in:
@@ -3449,29 +3449,6 @@ module ts {
|
||||
return getTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol));
|
||||
}
|
||||
|
||||
function getThisContainer(node: Node): Node {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node) {
|
||||
return node;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.Property:
|
||||
case SyntaxKind.Method:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.SourceFile:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function captureLexicalThis(node: Node, container: Node): void {
|
||||
var classNode = container.parent && container.parent.kind === SyntaxKind.ClassDeclaration ? container.parent : undefined;
|
||||
getNodeLinks(node).flags |= NodeCheckFlags.LexicalThis;
|
||||
@@ -3484,11 +3461,11 @@ module ts {
|
||||
}
|
||||
|
||||
function checkThisExpression(node: Node): Type {
|
||||
var container = getThisContainer(node);
|
||||
var container = getThisContainerOrArrowFunction(node);
|
||||
var needToCaptureLexicalThis = false;
|
||||
// skip arrow functions
|
||||
while (container.kind === SyntaxKind.ArrowFunction) {
|
||||
container = getThisContainer(container);
|
||||
container = getThisContainerOrArrowFunction(container);
|
||||
needToCaptureLexicalThis = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -407,6 +407,29 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function getThisContainerOrArrowFunction(node: Node): Node {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node) {
|
||||
return node;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.Property:
|
||||
case SyntaxKind.Method:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.SourceFile:
|
||||
case 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user