mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
redirectsTarget is keyed with Path (#44278)
* redirectsTarget is keyed with Path * sourceFileToPackageName to keyed with Path * feedback
This commit is contained in:
@@ -883,9 +883,9 @@ namespace ts {
|
||||
// `packageIdToSourceFile` is only used while building the program, while `sourceFileToPackageName` and `isSourceFileTargetOfRedirect` are kept around.
|
||||
const packageIdToSourceFile = new Map<string, SourceFile>();
|
||||
// Maps from a SourceFile's `.path` to the name of the package it was imported with.
|
||||
let sourceFileToPackageName = new Map<string, string>();
|
||||
let sourceFileToPackageName = new Map<Path, string>();
|
||||
// Key is a file name. Value is the (non-empty, or undefined) list of files that redirect to it.
|
||||
let redirectTargetsMap = createMultiMap<string>();
|
||||
let redirectTargetsMap = createMultiMap<Path, string>();
|
||||
|
||||
/**
|
||||
* map with
|
||||
|
||||
@@ -3944,9 +3944,9 @@ namespace ts {
|
||||
/* @internal */ getLibFileFromReference(ref: FileReference): SourceFile | undefined;
|
||||
|
||||
/** Given a source file, get the name of the package it was imported from. */
|
||||
/* @internal */ sourceFileToPackageName: ESMap<string, string>;
|
||||
/* @internal */ sourceFileToPackageName: ESMap<Path, string>;
|
||||
/** Set of all source files that some other source file redirects to. */
|
||||
/* @internal */ redirectTargetsMap: MultiMap<string, string>;
|
||||
/* @internal */ redirectTargetsMap: MultiMap<Path, string>;
|
||||
/** Is the file emitted file */
|
||||
/* @internal */ isEmittedFile(file: string): boolean;
|
||||
/* @internal */ getFileIncludeReasons(): MultiMap<Path, FileIncludeReason>;
|
||||
@@ -3974,7 +3974,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export type RedirectTargetsMap = ReadonlyESMap<string, readonly string[]>;
|
||||
export type RedirectTargetsMap = ReadonlyESMap<Path, readonly string[]>;
|
||||
|
||||
export interface ResolvedProjectReference {
|
||||
commandLine: ParsedCommandLine;
|
||||
|
||||
@@ -32,9 +32,10 @@ namespace ts {
|
||||
const referenceEntries = FindAllReferences.getReferenceEntriesForNode(position, node, program, sourceFilesToSearch, cancellationToken, /*options*/ undefined, sourceFilesSet);
|
||||
if (!referenceEntries) return undefined;
|
||||
const map = arrayToMultiMap(referenceEntries.map(FindAllReferences.toHighlightSpan), e => e.fileName, e => e.span);
|
||||
const getCanonicalFileName = createGetCanonicalFileName(program.useCaseSensitiveFileNames());
|
||||
return mapDefined(arrayFrom(map.entries()), ([fileName, highlightSpans]) => {
|
||||
if (!sourceFilesSet.has(fileName)) {
|
||||
if (!program.redirectTargetsMap.has(fileName)) {
|
||||
if (!program.redirectTargetsMap.has(toPath(fileName, program.getCurrentDirectory(), getCanonicalFileName))) {
|
||||
return undefined;
|
||||
}
|
||||
const redirectTarget = program.getSourceFile(fileName);
|
||||
|
||||
Reference in New Issue
Block a user