mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 15:54:15 +00:00
Cleanup
This commit is contained in:
parent
260df66b77
commit
68f47a5b10
@ -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);
|
||||
|
@ -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 = {
|
||||
|
Loading…
Reference in New Issue
Block a user