mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Push through original mapping location
This commit is contained in:
parent
86145eedb1
commit
64b1c23a9b
@ -1600,10 +1600,10 @@ namespace ts {
|
||||
|
||||
function makeGetTargetOfMappedPosition<TIn>(
|
||||
extract: (original: TIn) => sourcemaps.SourceMappableLocation,
|
||||
create: (result: sourcemaps.SourceMappableLocation, original: TIn) => TIn
|
||||
create: (result: sourcemaps.SourceMappableLocation, original: TIn, firstOriginal: TIn) => TIn
|
||||
) {
|
||||
return getTargetOfMappedPosition;
|
||||
function getTargetOfMappedPosition(input: TIn): TIn {
|
||||
function getTargetOfMappedPosition(input: TIn, firstOriginal = input): TIn {
|
||||
const info = extract(input);
|
||||
if (endsWith(info.fileName, Extension.Dts)) {
|
||||
let file: SourceFileLike = program.getSourceFile(info.fileName);
|
||||
@ -1617,7 +1617,7 @@ namespace ts {
|
||||
const mapper = getSourceMapper(info.fileName, file);
|
||||
const newLoc = mapper.getOriginalPosition(info);
|
||||
if (newLoc === info) return input;
|
||||
return getTargetOfMappedPosition(create(newLoc, input));
|
||||
return getTargetOfMappedPosition(create(newLoc, input, firstOriginal), firstOriginal);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
@ -1625,7 +1625,7 @@ namespace ts {
|
||||
|
||||
const getTargetOfMappedDeclarationInfo = makeGetTargetOfMappedPosition(
|
||||
(info: DefinitionInfo) => ({ fileName: info.fileName, position: info.textSpan.start }),
|
||||
(newLoc, info) => ({
|
||||
(newLoc, info, firstOriginal) => ({
|
||||
containerKind: info.containerKind,
|
||||
containerName: info.containerName,
|
||||
fileName: newLoc.fileName,
|
||||
@ -1635,13 +1635,13 @@ namespace ts {
|
||||
start: newLoc.position,
|
||||
length: info.textSpan.length
|
||||
},
|
||||
originalFileName: info.fileName,
|
||||
originalTextSpan: info.textSpan
|
||||
originalFileName: firstOriginal.fileName,
|
||||
originalTextSpan: firstOriginal.textSpan
|
||||
})
|
||||
);
|
||||
|
||||
function getTargetOfMappedDeclarationFiles(infos: ReadonlyArray<DefinitionInfo>): DefinitionInfo[] {
|
||||
return map(infos, getTargetOfMappedDeclarationInfo);
|
||||
return map(infos, d => getTargetOfMappedDeclarationInfo(d));
|
||||
}
|
||||
|
||||
/// Goto definition
|
||||
@ -1687,7 +1687,7 @@ namespace ts {
|
||||
);
|
||||
|
||||
function getTargetOfMappedImplementationLocations(infos: ReadonlyArray<ImplementationLocation>): ImplementationLocation[] {
|
||||
return map(infos, getTargetOfMappedImplementationLocation);
|
||||
return map(infos, d => getTargetOfMappedImplementationLocation(d));
|
||||
}
|
||||
|
||||
function getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user