Skip to content

Commit 0df92a1

Browse files
author
Andy
authored
Simplify isImplementation (microsoft#22660)
1 parent c7215a1 commit 0df92a1

File tree

1 file changed

+4
-30
lines changed

1 file changed

+4
-30
lines changed

src/services/findAllReferences.ts

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,36 +1681,10 @@ namespace ts.FindAllReferences.Core {
16811681
}
16821682

16831683
function isImplementation(node: Node): boolean {
1684-
if (!node) {
1685-
return false;
1686-
}
1687-
else if (isVariableLike(node) && hasInitializer(node)) {
1688-
return true;
1689-
}
1690-
else if (node.kind === SyntaxKind.VariableDeclaration) {
1691-
const parentStatement = getParentStatementOfVariableDeclaration(<VariableDeclaration>node);
1692-
return parentStatement && hasModifier(parentStatement, ModifierFlags.Ambient);
1693-
}
1694-
else if (isFunctionLike(node)) {
1695-
return !!(node as FunctionLikeDeclaration).body || hasModifier(node, ModifierFlags.Ambient);
1696-
}
1697-
else {
1698-
switch (node.kind) {
1699-
case SyntaxKind.ClassDeclaration:
1700-
case SyntaxKind.ClassExpression:
1701-
case SyntaxKind.EnumDeclaration:
1702-
case SyntaxKind.ModuleDeclaration:
1703-
return true;
1704-
}
1705-
}
1706-
return false;
1707-
}
1708-
1709-
function getParentStatementOfVariableDeclaration(node: VariableDeclaration): VariableStatement {
1710-
if (node.parent && node.parent.parent && node.parent.parent.kind === SyntaxKind.VariableStatement) {
1711-
Debug.assert(node.parent.kind === SyntaxKind.VariableDeclarationList);
1712-
return node.parent.parent;
1713-
}
1684+
return !!(node.flags & NodeFlags.Ambient)
1685+
|| (isVariableLike(node) ? hasInitializer(node)
1686+
: isFunctionLikeDeclaration(node) ? !!node.body
1687+
: isClassLike(node) || isModuleOrEnumDeclaration(node));
17141688
}
17151689

17161690
export function getReferenceEntriesForShorthandPropertyAssignment(node: Node, checker: TypeChecker, addReference: (node: Node) => void): void {

0 commit comments

Comments
 (0)