mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Fix positionToLineOffset conversion for getImplementation
This commit is contained in:
parent
abc30b26c7
commit
16bdaaa0a6
@ -484,18 +484,20 @@ namespace ts.server {
|
||||
|
||||
private getImplementation(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.FileSpan[] | ImplementationLocation[] {
|
||||
const { file, project } = this.getFileAndProject(args);
|
||||
const scriptInfo = project.getScriptInfoForNormalizedPath(file);
|
||||
const position = this.getPosition(args, scriptInfo);
|
||||
const position = this.getPosition(args, project.getScriptInfoForNormalizedPath(file));
|
||||
const implementations = project.getLanguageService().getImplementationAtPosition(file, position);
|
||||
if (!implementations) {
|
||||
return [];
|
||||
}
|
||||
if (simplifiedResult) {
|
||||
return implementations.map(impl => ({
|
||||
file: impl.fileName,
|
||||
start: scriptInfo.positionToLineOffset(impl.textSpan.start),
|
||||
end: scriptInfo.positionToLineOffset(ts.textSpanEnd(impl.textSpan))
|
||||
}));
|
||||
return implementations.map(({ fileName, textSpan }) => {
|
||||
const scriptInfo = project.getScriptInfo(fileName);
|
||||
return {
|
||||
file: fileName,
|
||||
start: scriptInfo.positionToLineOffset(textSpan.start),
|
||||
end: scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan))
|
||||
};
|
||||
});
|
||||
}
|
||||
else {
|
||||
return implementations;
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
/// <reference path='../fourslash.ts'/>
|
||||
|
||||
// @Filename: /bar.ts
|
||||
////import {Foo} from './foo'
|
||||
////
|
||||
////[|class A implements Foo {
|
||||
//// func() {}
|
||||
////}|]
|
||||
////
|
||||
////[|class B implements Foo {
|
||||
//// func() {}
|
||||
////}|]
|
||||
|
||||
// @Filename: /foo.ts
|
||||
////export interface /**/Foo {
|
||||
//// func();
|
||||
////}
|
||||
|
||||
verify.allRangesAppearInImplementationList("");
|
||||
Loading…
x
Reference in New Issue
Block a user