Handle module specifiers

This commit is contained in:
Sheetal Nandi
2019-06-06 12:51:26 -07:00
parent a120c59015
commit a67b375d0e
15 changed files with 62 additions and 46 deletions

View File

@@ -51,16 +51,6 @@ namespace ts.FindAllReferences {
if (!node.parent) return undefined;
if (!isDeclaration(node.parent) && !isExportAssignment(node.parent)) {
// Jsx Tags
if (isJsxOpeningElement(node.parent) || isJsxClosingElement(node.parent)) {
return node.parent.parent;
}
else if (isJsxSelfClosingElement(node.parent) ||
isLabeledStatement(node.parent) ||
isBreakOrContinueStatement(node.parent)) {
return node.parent;
}
// Special property assignment in javascript
if (isInJSFile(node)) {
const binaryExpression = isBinaryExpression(node.parent) ?
@@ -75,6 +65,29 @@ namespace ts.FindAllReferences {
}
}
// Jsx Tags
if (isJsxOpeningElement(node.parent) || isJsxClosingElement(node.parent)) {
return node.parent.parent;
}
else if (isJsxSelfClosingElement(node.parent) ||
isLabeledStatement(node.parent) ||
isBreakOrContinueStatement(node.parent)) {
return node.parent;
}
else if (isStringLiteralLike(node)) {
const validImport = tryGetImportFromModuleSpecifier(node);
if (validImport) {
const declOrStatement = findAncestor(validImport, node =>
isDeclaration(node) ||
isStatement(node) ||
isJSDocTag(node)
)! as NamedDeclaration | Statement | JSDocTag;
return isDeclaration(declOrStatement) ?
getDeclarationForDeclarationSpan(declOrStatement) :
declOrStatement;
}
}
// Handle computed property name
const propertyName = findAncestor(node, isComputedPropertyName);
return propertyName ?