From 0df92a1ba111fc98cc126d05858ba31158fdc42f Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 19 Mar 2018 11:59:22 -0700 Subject: [PATCH] Simplify isImplementation (#22660) --- src/services/findAllReferences.ts | 34 ++++--------------------------- 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index fc68e27dc84..89627774fe6 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1681,36 +1681,10 @@ namespace ts.FindAllReferences.Core { } function isImplementation(node: Node): boolean { - if (!node) { - return false; - } - else if (isVariableLike(node) && hasInitializer(node)) { - return true; - } - else if (node.kind === SyntaxKind.VariableDeclaration) { - const parentStatement = getParentStatementOfVariableDeclaration(node); - return parentStatement && hasModifier(parentStatement, ModifierFlags.Ambient); - } - else if (isFunctionLike(node)) { - return !!(node as FunctionLikeDeclaration).body || hasModifier(node, ModifierFlags.Ambient); - } - else { - switch (node.kind) { - case SyntaxKind.ClassDeclaration: - case SyntaxKind.ClassExpression: - case SyntaxKind.EnumDeclaration: - case SyntaxKind.ModuleDeclaration: - return true; - } - } - return false; - } - - function getParentStatementOfVariableDeclaration(node: VariableDeclaration): VariableStatement { - if (node.parent && node.parent.parent && node.parent.parent.kind === SyntaxKind.VariableStatement) { - Debug.assert(node.parent.kind === SyntaxKind.VariableDeclarationList); - return node.parent.parent; - } + return !!(node.flags & NodeFlags.Ambient) + || (isVariableLike(node) ? hasInitializer(node) + : isFunctionLikeDeclaration(node) ? !!node.body + : isClassLike(node) || isModuleOrEnumDeclaration(node)); } export function getReferenceEntriesForShorthandPropertyAssignment(node: Node, checker: TypeChecker, addReference: (node: Node) => void): void {