Skip to content

Commit

Permalink
Build new functionality into go-to-implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbranch committed Mar 11, 2022
1 parent 309c4bb commit 381799d
Show file tree
Hide file tree
Showing 18 changed files with 177 additions and 237 deletions.
20 changes: 0 additions & 20 deletions src/harness/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,26 +334,6 @@ namespace ts.server {
}));
}

getSourceDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan {
const args: protocol.FileLocationRequestArgs = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.SourceDefinitionAndBoundSpanRequest>(CommandNames.SourceDefinitionAndBoundSpan, args);
const response = this.processResponse<protocol.DefinitionInfoAndBoundSpanResponse>(request);
const body = Debug.checkDefined(response.body); // TODO: GH#18217

return {
definitions: body.definitions.map(entry => ({
containerKind: ScriptElementKind.unknown,
containerName: "",
fileName: entry.file,
textSpan: this.decodeSpan(entry),
kind: ScriptElementKind.unknown,
name: "",
unverified: entry.unverified,
})),
textSpan: this.decodeSpan(body.textSpan, request.arguments.file)
};
}

getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] {
const args = this.createFileLocationRequestArgs(fileName, position);

Expand Down
14 changes: 6 additions & 8 deletions src/harness/fourslashImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,13 +697,6 @@ namespace FourSlash {
this.verifyGoToX(arg0, endMarkerNames, () => this.getGoToDefinitionAndBoundSpan());
}

public verifyGoToSourceDefinition(startMarkerNames: ArrayOrSingle<string>, end?: ArrayOrSingle<string | { marker: string, unverified?: boolean }> | { file: string, unverified?: boolean }) {
if (this.testType !== FourSlashTestType.Server) {
this.raiseError("goToSourceDefinition may only be used in fourslash/server tests.");
}
this.verifyGoToX(startMarkerNames, end, () => (this.languageService as ts.server.SessionClient).getSourceDefinitionAndBoundSpan(this.activeFile.fileName, this.currentCaretPosition)!);
}

private getGoToDefinition(): readonly ts.DefinitionInfo[] {
return this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition)!;
}
Expand Down Expand Up @@ -2447,7 +2440,12 @@ namespace FourSlash {
assert.isTrue(implementations && implementations.length > 0, "Expected at least one implementation but got 0");
}
else {
assert.isUndefined(implementations, "Expected implementation list to be empty but implementations returned");
if (this.testType === FourSlashTestType.Server) {
assert.deepEqual(implementations, [], "Expected implementation list to be empty but implementations returned");
}
else {
assert.isUndefined(implementations, "Expected implementation list to be empty but implementations returned");
}
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/harness/fourslashInterfaceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,6 @@ namespace FourSlashInterface {
this.state.verifyGoToType(arg0, endMarkerName);
}

public goToSourceDefinition(startMarkerNames: ArrayOrSingle<string>, end: { file: string } | ArrayOrSingle<string>) {
this.state.verifyGoToSourceDefinition(startMarkerNames, end);
}

public goToDefinitionForMarkers(...markerNames: string[]) {
this.state.verifyGoToDefinitionForMarkers(markerNames);
}
Expand Down
7 changes: 0 additions & 7 deletions src/server/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ namespace ts.server.protocol {
SignatureHelp = "signatureHelp",
/* @internal */
SignatureHelpFull = "signatureHelp-full",
SourceDefinitionAndBoundSpan = "sourceDefinitionAndBoundSpan",
/* @internal */
SourceDefinitionAndBoundSpanFull = "sourceDefinitionAndBoundSpan-full",
Status = "status",
TypeDefinition = "typeDefinition",
ProjectInfo = "projectInfo",
Expand Down Expand Up @@ -907,10 +904,6 @@ namespace ts.server.protocol {
readonly command: CommandTypes.DefinitionAndBoundSpan;
}

export interface SourceDefinitionAndBoundSpanRequest extends FileLocationRequest {
readonly command: CommandTypes.SourceDefinitionAndBoundSpan;
}

export interface DefinitionAndBoundSpanResponse extends Response {
readonly body: DefinitionInfoAndBoundSpan;
}
Expand Down
Loading

0 comments on commit 381799d

Please sign in to comment.