Skip to content

Commit

Permalink
Use LSP 3.6 Goto implementation when possible
Browse files Browse the repository at this point in the history
Introduced in the RLS with
rust-lang/rls#936.
  • Loading branch information
Xanewok authored and fj committed Feb 17, 2019
1 parent 95abf5d commit 9bf4e07
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { commands, ExtensionContext, IndentAction, languages, TextEditor,
TextEditorEdit, window, workspace, TextDocument, WorkspaceFolder, Disposable, Uri,
WorkspaceFoldersChangeEvent } from 'vscode';
import { LanguageClient, LanguageClientOptions, Location, NotificationType,
ServerOptions } from 'vscode-languageclient';
ServerOptions, ImplementationRequest } from 'vscode-languageclient';
import { execFile, ExecChildProcessResult } from './utils/child_process';

export async function activate(context: ExtensionContext) {
Expand Down Expand Up @@ -204,14 +204,19 @@ class ClientWorkspace {
return;
}
await this.lc.onReady();
// Prior to https://github.com/rust-lang-nursery/rls/pull/936 we used a custom
// LSP message - if the implementation provider is specified this means we can use the 3.6 one.
const useLSPRequest = this.lc.initializeResult &&
this.lc.initializeResult.capabilities.implementationProvider === true;
const request = useLSPRequest ? ImplementationRequest.type.method : 'rustDocument/implementations';

const params =
this.lc
.code2ProtocolConverter
.asTextDocumentPositionParams(textEditor.document, textEditor.selection.active);
let locations: Location[];
try {
locations = await this.lc.sendRequest<Location[]>('rustDocument/implementations', params);
locations = await this.lc.sendRequest<Location[]>(request, params);
} catch (reason) {
window.showWarningMessage('find implementations failed: ' + reason);
return;
Expand Down

0 comments on commit 9bf4e07

Please sign in to comment.