mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Use import export sepcifier as declaration for the property name of import export as well
This commit is contained in:
1 parent
f37ae23f7e
commit
bbfbf8fa95
5 files changed
+39
-24
No files matched your search
@@ -27,16 +27,31 @@ namespace ts.FindAllReferences {
|
||||
readonly textSpan: TextSpan;
|
||||
}
|
||||
export function nodeEntry(node: Node, kind: NodeEntryKind = EntryKind.Node): NodeEntry {
|
||||
return {
|
||||
kind,
|
||||
node: (node as NamedDeclaration).name || node,
|
||||
declaration: getDeclarationForDeclarationSpanForNode(node)
|
||||
};
|
||||
}
|
||||
|
||||
function getDeclarationForDeclarationSpanForNode(node: Node): Node | undefined {
|
||||
if (isDeclaration(node)) {
|
||||
return getDeclarationForDeclarationSpan(node);
|
||||
}
|
||||
|
||||
// TODO(shkamat)::
|
||||
// JSXOpeningElement or JSXElement for tagName ?
|
||||
const declaration = getDeclarationForDeclarationSpan(
|
||||
isDeclaration(node) ?
|
||||
node :
|
||||
node.parent && isDeclaration(node.parent) && node.parent.name === node ?
|
||||
node.parent :
|
||||
undefined
|
||||
);
|
||||
return { kind, node: (node as NamedDeclaration).name || node, declaration };
|
||||
if (!node.parent || !isDeclaration(node.parent)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (node.parent.name === node || // node is name of declaration, use parent
|
||||
// Property name of the import export specifier use import/export specifier
|
||||
isImportOrExportSpecifier(node.parent) && node.parent.propertyName === node) {
|
||||
return getDeclarationForDeclarationSpan(node.parent);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getDeclarationForDeclarationSpan(node: NamedDeclaration | undefined): Node | undefined {
|
||||
|
||||
Reference in new issue
Block a user