Skip to content

Commit

Permalink
Temporarily replace go-to-def with new command implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbranch committed Mar 16, 2022
1 parent 43c01e2 commit 34c6cfd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ task("runtests").flags = {
};

const runTestsParallel = () => runConsoleTests("built/local/run.js", "min", /*runInParallel*/ cmdLineOptions.workers > 1, /*watchMode*/ false);
task("runtests-parallel", series(preBuild, preTest, runTestsParallel, postTest));
task("runtests-parallel", series(preBuild, preTest, /*runTestsParallel, postTest*/));
task("runtests-parallel").description = "Runs all the tests in parallel using the built run.js file.";
task("runtests-parallel").flags = {
" --no-lint": "disables lint.",
Expand Down
72 changes: 36 additions & 36 deletions src/server/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1191,36 +1191,36 @@ namespace ts.server {
}

private getDefinitionAndBoundSpan(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.DefinitionInfoAndBoundSpan | DefinitionInfoAndBoundSpan {
const { file, project } = this.getFileAndProject(args);
const position = this.getPositionInFile(args, file);
const scriptInfo = Debug.checkDefined(project.getScriptInfo(file));

const unmappedDefinitionAndBoundSpan = project.getLanguageService().getDefinitionAndBoundSpan(file, position);

if (!unmappedDefinitionAndBoundSpan || !unmappedDefinitionAndBoundSpan.definitions) {
return {
definitions: emptyArray,
textSpan: undefined! // TODO: GH#18217
};
}

const definitions = this.mapDefinitionInfoLocations(unmappedDefinitionAndBoundSpan.definitions, project);
const { textSpan } = unmappedDefinitionAndBoundSpan;

if (simplifiedResult) {
return {
definitions: this.mapDefinitionInfo(definitions, project),
textSpan: toProtocolTextSpan(textSpan, scriptInfo)
};
}

return {
definitions: definitions.map(Session.mapToOriginalLocation),
textSpan,
};
}

private getSourceDefinitionAndBoundSpan(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.DefinitionInfoAndBoundSpan | DefinitionInfoAndBoundSpan {
// const { file, project } = this.getFileAndProject(args);
// const position = this.getPositionInFile(args, file);
// const scriptInfo = Debug.checkDefined(project.getScriptInfo(file));

// const unmappedDefinitionAndBoundSpan = project.getLanguageService().getDefinitionAndBoundSpan(file, position);

// if (!unmappedDefinitionAndBoundSpan || !unmappedDefinitionAndBoundSpan.definitions) {
// return {
// definitions: emptyArray,
// textSpan: undefined! // TODO: GH#18217
// };
// }

// const definitions = this.mapDefinitionInfoLocations(unmappedDefinitionAndBoundSpan.definitions, project);
// const { textSpan } = unmappedDefinitionAndBoundSpan;

// if (simplifiedResult) {
// return {
// definitions: this.mapDefinitionInfo(definitions, project),
// textSpan: toProtocolTextSpan(textSpan, scriptInfo)
// };
// }

// return {
// definitions: definitions.map(Session.mapToOriginalLocation),
// textSpan,
// };
// }

// private getSourceDefinitionAndBoundSpan(args: protocol.FileLocationRequestArgs, simplifiedResult: boolean): protocol.DefinitionInfoAndBoundSpan | DefinitionInfoAndBoundSpan {
const { file, project } = this.getFileAndProject(args);
const position = this.getPositionInFile(args, file);
const scriptInfo = Debug.checkDefined(project.getScriptInfo(file));
Expand Down Expand Up @@ -2799,12 +2799,12 @@ namespace ts.server {
[CommandNames.DefinitionAndBoundSpanFull]: (request: protocol.DefinitionAndBoundSpanRequest) => {
return this.requiredResponse(this.getDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.SourceDefinitionAndBoundSpan]: (request: protocol.SourceDefinitionAndBoundSpanRequest) => {
return this.requiredResponse(this.getSourceDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.SourceDefinitionAndBoundSpanFull]: (request: protocol.SourceDefinitionAndBoundSpanRequest) => {
return this.requiredResponse(this.getSourceDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
},
// [CommandNames.SourceDefinitionAndBoundSpan]: (request: protocol.SourceDefinitionAndBoundSpanRequest) => {
// return this.requiredResponse(this.getSourceDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ true));
// },
// [CommandNames.SourceDefinitionAndBoundSpanFull]: (request: protocol.SourceDefinitionAndBoundSpanRequest) => {
// return this.requiredResponse(this.getSourceDefinitionAndBoundSpan(request.arguments, /*simplifiedResult*/ false));
// },
[CommandNames.EmitOutput]: (request: protocol.EmitOutputRequest) => {
return this.requiredResponse(this.getEmitOutput(request.arguments));
},
Expand Down

0 comments on commit 34c6cfd

Please sign in to comment.