From 68f47a5b10cfbb7b0168a0f24ddc7d8ced6cedda Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 30 Dec 2019 19:12:49 +0100 Subject: Cleanup --- editors/code/src/commands/syntax_tree.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'editors/code/src/commands/syntax_tree.ts') diff --git a/editors/code/src/commands/syntax_tree.ts b/editors/code/src/commands/syntax_tree.ts index e61fb36df..9831c2a2e 100644 --- a/editors/code/src/commands/syntax_tree.ts +++ b/editors/code/src/commands/syntax_tree.ts @@ -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 = { -- cgit v1.2.3 From 94be27fc44763afbf67d36010d4aa05639191e4b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 30 Dec 2019 19:30:30 +0100 Subject: Move expand macro to the new context --- editors/code/src/commands/syntax_tree.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'editors/code/src/commands/syntax_tree.ts') diff --git a/editors/code/src/commands/syntax_tree.ts b/editors/code/src/commands/syntax_tree.ts index 9831c2a2e..20ff7e5ca 100644 --- a/editors/code/src/commands/syntax_tree.ts +++ b/editors/code/src/commands/syntax_tree.ts @@ -66,10 +66,9 @@ interface SyntaxTreeParams { class TextDocumentContentProvider implements vscode.TextDocumentContentProvider { - ctx: Ctx; + private ctx: Ctx; uri = vscode.Uri.parse('rust-analyzer://syntaxtree'); eventEmitter = new vscode.EventEmitter(); - syntaxTree: string = 'Not available'; constructor(ctx: Ctx) { this.ctx = ctx; @@ -86,8 +85,8 @@ class TextDocumentContentProvider range = editor.selection.isEmpty ? undefined : this.ctx.client.code2ProtocolConverter.asRange( - editor.selection, - ); + editor.selection, + ); } const request: SyntaxTreeParams = { -- cgit v1.2.3