Merge pull request #13687 from Microsoft/find_implementation_position
Fix positionToLineOffset conversion for getImplementation
This commit is contained in:
commit
5644b013c9
2 changed files with 28 additions and 7 deletions
|
@ -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…
Reference in a new issue