This commit is contained in:
Aleksey Kladov 2019-12-30 19:12:49 +01:00
parent 260df66b77
commit 68f47a5b10
2 changed files with 11 additions and 11 deletions

View File

@ -1,8 +1,8 @@
import * as vscode from 'vscode';
import { Ctx, Cmd } from '../ctx';
// Shows status of rust-analyzer (for debugging)
// Shows status of rust-analyzer (for debugging)
export function analyzerStatus(ctx: Ctx): Cmd {
let poller: NodeJS.Timer | null = null;
const tdcp = new TextDocumentContentProvider(ctx);

View File

@ -7,12 +7,12 @@ import { Ctx, Cmd } from '../ctx';
//
// The contents of the file come from the `TextDocumentContentProvider`
export function syntaxTree(ctx: Ctx): Cmd {
const stcp = new SyntaxTreeContentProvider(ctx);
const tdcp = new TextDocumentContentProvider(ctx);
ctx.pushCleanup(
vscode.workspace.registerTextDocumentContentProvider(
'rust-analyzer',
stcp,
tdcp,
),
);
@ -20,7 +20,7 @@ export function syntaxTree(ctx: Ctx): Cmd {
(event: vscode.TextDocumentChangeEvent) => {
const doc = event.document;
if (doc.languageId !== 'rust') return;
afterLs(() => stcp.eventEmitter.fire(stcp.uri));
afterLs(() => tdcp.eventEmitter.fire(tdcp.uri));
},
ctx.subscriptions,
);
@ -28,7 +28,7 @@ export function syntaxTree(ctx: Ctx): Cmd {
vscode.window.onDidChangeActiveTextEditor(
(editor: vscode.TextEditor | undefined) => {
if (!editor || editor.document.languageId !== 'rust') return;
stcp.eventEmitter.fire(stcp.uri);
tdcp.eventEmitter.fire(tdcp.uri);
},
ctx.subscriptions,
);
@ -38,12 +38,12 @@ export function syntaxTree(ctx: Ctx): Cmd {
const rangeEnabled = !!(editor && !editor.selection.isEmpty);
const uri = rangeEnabled
? vscode.Uri.parse(`${stcp.uri.toString()}?range=true`)
: stcp.uri;
? vscode.Uri.parse(`${tdcp.uri.toString()}?range=true`)
: tdcp.uri;
const document = await vscode.workspace.openTextDocument(uri);
stcp.eventEmitter.fire(uri);
tdcp.eventEmitter.fire(uri);
return vscode.window.showTextDocument(
document,
@ -64,7 +64,7 @@ interface SyntaxTreeParams {
range?: lc.Range;
}
export class SyntaxTreeContentProvider
class TextDocumentContentProvider
implements vscode.TextDocumentContentProvider {
ctx: Ctx;
uri = vscode.Uri.parse('rust-analyzer://syntaxtree');
@ -86,8 +86,8 @@ export class SyntaxTreeContentProvider
range = editor.selection.isEmpty
? undefined
: this.ctx.client.code2ProtocolConverter.asRange(
editor.selection,
);
editor.selection,
);
}
const request: SyntaxTreeParams = {