mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
go-to-type-definition, and find-all-refs should work for import.meta (#44364)
* go-to-type-definition, and find-all-refs should work for import.meta * search `meta` instead of `import.meta` * remove `definition` * fix compilation error * update baseline * revert definition
This commit is contained in:
@@ -890,6 +890,10 @@ namespace ts.FindAllReferences {
|
||||
node.kind === SyntaxKind.ReadonlyKeyword ? isReadonlyTypeOperator : undefined);
|
||||
}
|
||||
|
||||
if (isImportMeta(node.parent) && node.parent.name === node) {
|
||||
return getAllReferencesForImportMeta(sourceFiles, cancellationToken);
|
||||
}
|
||||
|
||||
if (isStaticModifier(node) && isClassStaticBlockDeclaration(node.parent)) {
|
||||
return [{ definition: { type: DefinitionKind.Keyword, node }, references: [nodeEntry(node)] }];
|
||||
}
|
||||
@@ -1435,6 +1439,19 @@ namespace ts.FindAllReferences {
|
||||
}
|
||||
}
|
||||
|
||||
function getAllReferencesForImportMeta(sourceFiles: readonly SourceFile[], cancellationToken: CancellationToken): SymbolAndEntries[] | undefined {
|
||||
const references = flatMap(sourceFiles, sourceFile => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
return mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "meta", sourceFile), node => {
|
||||
const parent = node.parent;
|
||||
if (isImportMeta(parent)) {
|
||||
return nodeEntry(parent);
|
||||
}
|
||||
});
|
||||
});
|
||||
return references.length ? [{ definition: { type: DefinitionKind.Keyword, node: references[0].node }, references }] : undefined;
|
||||
}
|
||||
|
||||
function getAllReferencesForKeyword(sourceFiles: readonly SourceFile[], keywordKind: SyntaxKind, cancellationToken: CancellationToken, filter?: (node: Node) => boolean): SymbolAndEntries[] | undefined {
|
||||
const references = flatMap(sourceFiles, sourceFile => {
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
@@ -198,6 +198,10 @@ namespace ts.GoToDefinition {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (isImportMeta(node.parent) && node.parent.name === node) {
|
||||
return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent);
|
||||
}
|
||||
|
||||
const symbol = getSymbol(node, typeChecker);
|
||||
if (!symbol) return undefined;
|
||||
|
||||
|
||||
@@ -1724,6 +1724,9 @@ namespace ts {
|
||||
if (isNamedTupleMember(node.parent) && node.pos === node.parent.pos) {
|
||||
return node.parent;
|
||||
}
|
||||
if (isImportMeta(node.parent) && node.parent.name === node) {
|
||||
return node.parent;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -1740,6 +1743,8 @@ namespace ts {
|
||||
case SyntaxKind.SuperKeyword:
|
||||
case SyntaxKind.NamedTupleMember:
|
||||
return true;
|
||||
case SyntaxKind.MetaProperty:
|
||||
return isImportMeta(node);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user