Skip to content

Commit 32323ce

Browse files
authored
redirectsTarget is keyed with Path (microsoft#44278)
* redirectsTarget is keyed with Path * sourceFileToPackageName to keyed with Path * feedback
1 parent b1eaf3e commit 32323ce

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/compiler/program.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,9 +883,9 @@ namespace ts {
883883
// `packageIdToSourceFile` is only used while building the program, while `sourceFileToPackageName` and `isSourceFileTargetOfRedirect` are kept around.
884884
const packageIdToSourceFile = new Map<string, SourceFile>();
885885
// Maps from a SourceFile's `.path` to the name of the package it was imported with.
886-
let sourceFileToPackageName = new Map<string, string>();
886+
let sourceFileToPackageName = new Map<Path, string>();
887887
// Key is a file name. Value is the (non-empty, or undefined) list of files that redirect to it.
888-
let redirectTargetsMap = createMultiMap<string>();
888+
let redirectTargetsMap = createMultiMap<Path, string>();
889889

890890
/**
891891
* map with

src/compiler/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3944,9 +3944,9 @@ namespace ts {
39443944
/* @internal */ getLibFileFromReference(ref: FileReference): SourceFile | undefined;
39453945

39463946
/** Given a source file, get the name of the package it was imported from. */
3947-
/* @internal */ sourceFileToPackageName: ESMap<string, string>;
3947+
/* @internal */ sourceFileToPackageName: ESMap<Path, string>;
39483948
/** Set of all source files that some other source file redirects to. */
3949-
/* @internal */ redirectTargetsMap: MultiMap<string, string>;
3949+
/* @internal */ redirectTargetsMap: MultiMap<Path, string>;
39503950
/** Is the file emitted file */
39513951
/* @internal */ isEmittedFile(file: string): boolean;
39523952
/* @internal */ getFileIncludeReasons(): MultiMap<Path, FileIncludeReason>;
@@ -3974,7 +3974,7 @@ namespace ts {
39743974
}
39753975

39763976
/* @internal */
3977-
export type RedirectTargetsMap = ReadonlyESMap<string, readonly string[]>;
3977+
export type RedirectTargetsMap = ReadonlyESMap<Path, readonly string[]>;
39783978

39793979
export interface ResolvedProjectReference {
39803980
commandLine: ParsedCommandLine;

src/services/documentHighlights.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ namespace ts {
3232
const referenceEntries = FindAllReferences.getReferenceEntriesForNode(position, node, program, sourceFilesToSearch, cancellationToken, /*options*/ undefined, sourceFilesSet);
3333
if (!referenceEntries) return undefined;
3434
const map = arrayToMultiMap(referenceEntries.map(FindAllReferences.toHighlightSpan), e => e.fileName, e => e.span);
35+
const getCanonicalFileName = createGetCanonicalFileName(program.useCaseSensitiveFileNames());
3536
return mapDefined(arrayFrom(map.entries()), ([fileName, highlightSpans]) => {
3637
if (!sourceFilesSet.has(fileName)) {
37-
if (!program.redirectTargetsMap.has(fileName)) {
38+
if (!program.redirectTargetsMap.has(toPath(fileName, program.getCurrentDirectory(), getCanonicalFileName))) {
3839
return undefined;
3940
}
4041
const redirectTarget = program.getSourceFile(fileName);

0 commit comments

Comments
 (0)