From 42c7aa85ce9d2b8a16b6b1429d63afe3c1489a77 Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 16 Mar 2018 14:54:41 -0700 Subject: [PATCH] Clean up isNameOfExternalModuleImportOrDeclaration (#22659) --- src/services/findAllReferences.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index eb2998c6e40..0061479133c 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -772,9 +772,11 @@ namespace ts.FindAllReferences.Core { case SyntaxKind.Identifier: return (node as Identifier).text.length === searchSymbolName.length; - case SyntaxKind.StringLiteral: - return (isLiteralNameOfPropertyDeclarationOrIndexAccess(node as StringLiteral) || isNameOfExternalModuleImportOrDeclaration(node)) && - (node as StringLiteral).text.length === searchSymbolName.length; + case SyntaxKind.StringLiteral: { + const str = node as StringLiteral; + return (isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || isNameOfModuleDeclaration(node) || isExpressionOfExternalModuleImportEqualsDeclaration(node)) && + str.text.length === searchSymbolName.length; + } case SyntaxKind.NumericLiteral: return isLiteralNameOfPropertyDeclarationOrIndexAccess(node as NumericLiteral) && (node as NumericLiteral).text.length === searchSymbolName.length; @@ -1735,14 +1737,6 @@ namespace ts.FindAllReferences.Core { return tryGetClassExtendingExpressionWithTypeArguments(climbPastPropertyAccess(node).parent); } - function isNameOfExternalModuleImportOrDeclaration(node: Node): boolean { - if (node.kind === SyntaxKind.StringLiteral) { - return isNameOfModuleDeclaration(node) || isExpressionOfExternalModuleImportEqualsDeclaration(node); - } - - return false; - } - /** * If we are just looking for implementations and this is a property access expression, we need to get the * symbol of the local type of the symbol the property is being accessed on. This is because our search