From af8063fe373cf06a345b0d4eee14ef1ef6873bc7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 29 Sep 2020 22:05:18 +0200 Subject: Extend **Status** command to also show dep info for the file This should help with troubleshooting wrong project configuration --- editors/code/src/commands.ts | 19 ++++++++++++------- editors/code/src/lsp_ext.ts | 5 ++++- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index e9581a9b5..1a90f1b7d 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts @@ -21,7 +21,12 @@ export function analyzerStatus(ctx: Ctx): Cmd { provideTextDocumentContent(_uri: vscode.Uri): vscode.ProviderResult { if (!vscode.window.activeTextEditor) return ''; - return ctx.client.sendRequest(ra.analyzerStatus); + const params: ra.AnalyzerStatusParams = {}; + const doc = ctx.activeRustEditor?.document; + if (doc != null) { + params.textDocument = ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(doc); + } + return ctx.client.sendRequest(ra.analyzerStatus, params); } get onDidChange(): vscode.Event { @@ -94,7 +99,7 @@ export function matchingBrace(ctx: Ctx): Cmd { if (!editor || !client) return; const response = await client.sendRequest(ra.matchingBrace, { - textDocument: { uri: editor.document.uri.toString() }, + textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document), positions: editor.selections.map(s => client.code2ProtocolConverter.asPosition(s.active), ), @@ -118,7 +123,7 @@ export function joinLines(ctx: Ctx): Cmd { const items: lc.TextEdit[] = await client.sendRequest(ra.joinLines, { ranges: editor.selections.map((it) => client.code2ProtocolConverter.asRange(it)), - textDocument: { uri: editor.document.uri.toString() }, + textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document), }); editor.edit((builder) => { client.protocol2CodeConverter.asTextEdits(items).forEach((edit: any) => { @@ -136,7 +141,7 @@ export function onEnter(ctx: Ctx): Cmd { if (!editor || !client) return false; const lcEdits = await client.sendRequest(ra.onEnter, { - textDocument: { uri: editor.document.uri.toString() }, + textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document), position: client.code2ProtocolConverter.asPosition( editor.selection.active, ), @@ -165,7 +170,7 @@ export function parentModule(ctx: Ctx): Cmd { if (!editor || !client) return; const response = await client.sendRequest(ra.parentModule, { - textDocument: { uri: editor.document.uri.toString() }, + textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document), position: client.code2ProtocolConverter.asPosition( editor.selection.active, ), @@ -191,7 +196,7 @@ export function ssr(ctx: Ctx): Cmd { const position = editor.selection.active; const selections = editor.selections; - const textDocument = { uri: editor.document.uri.toString() }; + const textDocument = ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document); const options: vscode.InputBoxOptions = { value: "() ==>> ()", @@ -339,7 +344,7 @@ export function expandMacro(ctx: Ctx): Cmd { const position = editor.selection.active; const expanded = await client.sendRequest(ra.expandMacro, { - textDocument: { uri: editor.document.uri.toString() }, + textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document), position, }); diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index d167041c4..eb422d3e7 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts @@ -4,7 +4,10 @@ import * as lc from "vscode-languageclient"; -export const analyzerStatus = new lc.RequestType0("rust-analyzer/analyzerStatus"); +export interface AnalyzerStatusParams { + textDocument?: lc.TextDocumentIdentifier; +} +export const analyzerStatus = new lc.RequestType("rust-analyzer/analyzerStatus"); export const memoryUsage = new lc.RequestType0("rust-analyzer/memoryUsage"); export type Status = "loading" | "ready" | "invalid" | "needsReload"; -- cgit v1.2.3