mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:13:31 -06:00
Comments/naming
This commit is contained in:
parent
64b1c23a9b
commit
f01338fa33
@ -700,6 +700,13 @@ namespace ts.server {
|
||||
return definitions.map(def => this.toFileSpan(def.fileName, def.textSpan, project));
|
||||
}
|
||||
|
||||
/*
|
||||
* When we map a .d.ts location to .ts, Visual Studio gets confused because there's no associated Roslyn Document in
|
||||
* the same project which corresponds to the file. VS Code has no problem with this, and luckily we have two protocols.
|
||||
* This retains the existing behavior for the "simplified" (VS Code) protocol but stores the .d.ts location in a
|
||||
* set of additional fields, and does the reverse for VS (store the .d.ts location where
|
||||
* it used to be and stores the .ts location in the additional fields).
|
||||
*/
|
||||
private static mapToOriginalLocation<T extends DocumentSpan>(def: T): T {
|
||||
if (def.originalFileName) {
|
||||
Debug.assert(def.originalTextSpan !== undefined, "originalTextSpan should be present if originalFileName is");
|
||||
|
||||
@ -1600,10 +1600,10 @@ namespace ts {
|
||||
|
||||
function makeGetTargetOfMappedPosition<TIn>(
|
||||
extract: (original: TIn) => sourcemaps.SourceMappableLocation,
|
||||
create: (result: sourcemaps.SourceMappableLocation, original: TIn, firstOriginal: TIn) => TIn
|
||||
create: (result: sourcemaps.SourceMappableLocation, unmapped: TIn, original: TIn) => TIn
|
||||
) {
|
||||
return getTargetOfMappedPosition;
|
||||
function getTargetOfMappedPosition(input: TIn, firstOriginal = input): TIn {
|
||||
function getTargetOfMappedPosition(input: TIn, original = 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, firstOriginal), firstOriginal);
|
||||
return getTargetOfMappedPosition(create(newLoc, input, original), original);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
@ -1625,7 +1625,7 @@ namespace ts {
|
||||
|
||||
const getTargetOfMappedDeclarationInfo = makeGetTargetOfMappedPosition(
|
||||
(info: DefinitionInfo) => ({ fileName: info.fileName, position: info.textSpan.start }),
|
||||
(newLoc, info, firstOriginal) => ({
|
||||
(newLoc, info, original) => ({
|
||||
containerKind: info.containerKind,
|
||||
containerName: info.containerName,
|
||||
fileName: newLoc.fileName,
|
||||
@ -1635,8 +1635,8 @@ namespace ts {
|
||||
start: newLoc.position,
|
||||
length: info.textSpan.length
|
||||
},
|
||||
originalFileName: firstOriginal.fileName,
|
||||
originalTextSpan: firstOriginal.textSpan
|
||||
originalFileName: original.fileName,
|
||||
originalTextSpan: original.textSpan
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user