diff --git a/editors/code/src/commands/syntaxTree.ts b/editors/code/src/commands/syntaxTree.ts index 7200ae8234..2f50fe14b3 100644 --- a/editors/code/src/commands/syntaxTree.ts +++ b/editors/code/src/commands/syntaxTree.ts @@ -5,7 +5,7 @@ import { Server } from '../server'; export const syntaxTreeUri = vscode.Uri.parse('rust-analyzer://syntaxtree'); -export class TextDocumentContentProvider +export class SyntaxTreeContentProvider implements vscode.TextDocumentContentProvider { public eventEmitter = new vscode.EventEmitter(); public syntaxTree: string = 'Not available'; @@ -54,7 +54,7 @@ type SyntaxTreeResult = string; // Opens the virtual file that will show the syntax tree // // The contents of the file come from the `TextDocumentContentProvider` -export function createHandle(provider: TextDocumentContentProvider) { +export function createHandle(provider: SyntaxTreeContentProvider) { return async () => { const editor = vscode.window.activeTextEditor; const rangeEnabled = !!(editor && !editor.selection.isEmpty); diff --git a/editors/code/src/events/change_text_document.ts b/editors/code/src/events/change_text_document.ts index 6be057245f..89488bc61e 100644 --- a/editors/code/src/events/change_text_document.ts +++ b/editors/code/src/events/change_text_document.ts @@ -1,20 +1,18 @@ import * as vscode from 'vscode'; import { - syntaxTreeUri, - TextDocumentContentProvider + SyntaxTreeContentProvider, + syntaxTreeUri } from '../commands/syntaxTree'; -export function createHandler( - textDocumentContentProvider: TextDocumentContentProvider -) { +export function createHandler(syntaxTreeProvider: SyntaxTreeContentProvider) { return (event: vscode.TextDocumentChangeEvent) => { const doc = event.document; if (doc.languageId !== 'rust') { return; } afterLs(() => { - textDocumentContentProvider.eventEmitter.fire(syntaxTreeUri); + syntaxTreeProvider.eventEmitter.fire(syntaxTreeUri); }); }; } diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index 5134bb258d..894334c55f 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts @@ -2,7 +2,7 @@ import * as vscode from 'vscode'; import * as lc from 'vscode-languageclient'; import * as commands from './commands'; -import { TextDocumentContentProvider } from './commands/syntaxTree'; +import { SyntaxTreeContentProvider } from './commands/syntaxTree'; import * as events from './events'; import * as notifications from './notifications'; import { Server } from './server'; @@ -100,21 +100,21 @@ export function activate(context: vscode.ExtensionContext) { events.changeActiveTextEditor.handle ); - const textDocumentContentProvider = new TextDocumentContentProvider(); + const syntaxTreeContentProvider = new SyntaxTreeContentProvider(); disposeOnDeactivation( vscode.workspace.registerTextDocumentContentProvider( 'rust-analyzer', - textDocumentContentProvider + syntaxTreeContentProvider ) ); registerCommand( 'rust-analyzer.syntaxTree', - commands.syntaxTree.createHandle(textDocumentContentProvider) + commands.syntaxTree.createHandle(syntaxTreeContentProvider) ); vscode.workspace.onDidChangeTextDocument( - events.changeTextDocument.createHandler(textDocumentContentProvider), + events.changeTextDocument.createHandler(syntaxTreeContentProvider), null, context.subscriptions );