mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Handle module specifiers
This commit is contained in:
@@ -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 ?
|
||||
|
||||
@@ -19,7 +19,8 @@ namespace ts.projectSystem {
|
||||
locs: [
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: bTs.content,
|
||||
text: "./a"
|
||||
text: "./a",
|
||||
declarationText: bTs.content
|
||||
})
|
||||
]
|
||||
}],
|
||||
@@ -43,7 +44,8 @@ namespace ts.projectSystem {
|
||||
locs: [
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: bTs.content,
|
||||
text: "./a"
|
||||
text: "./a",
|
||||
declarationText: bTs.content
|
||||
})
|
||||
]
|
||||
}],
|
||||
@@ -68,7 +70,8 @@ namespace ts.projectSystem {
|
||||
locs: [
|
||||
protocolRenameSpanFromSubstring({
|
||||
fileText: bTs.content,
|
||||
text: "./a"
|
||||
text: "./a",
|
||||
declarationText: bTs.content
|
||||
})
|
||||
]
|
||||
}],
|
||||
|
||||
Reference in New Issue
Block a user