From c2d3203d0c708dc2ccb7c0d017ae876180c0e5a8 Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Sun, 3 Mar 2019 21:21:40 +0200 Subject: Add vscode support for range in SyntaxTreeParams This enables the client to use a command to either show the live-updating version of the syntax tree for the current file. Or optionally when a selected range is provided, we then provide a snapshot of the syntax tree for the range. --- editors/code/src/extension.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'editors/code/src/extension.ts') diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index 8b332eeb2..5134bb258 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts @@ -52,7 +52,6 @@ export function activate(context: vscode.ExtensionContext) { registerCommand('rust-analyzer.collectGarbage', () => Server.client.sendRequest('rust-analyzer/collectGarbage', null) ); - registerCommand('rust-analyzer.syntaxTree', commands.syntaxTree.handle); registerCommand( 'rust-analyzer.extendSelection', commands.extendSelection.handle @@ -109,6 +108,11 @@ export function activate(context: vscode.ExtensionContext) { ) ); + registerCommand( + 'rust-analyzer.syntaxTree', + commands.syntaxTree.createHandle(textDocumentContentProvider) + ); + vscode.workspace.onDidChangeTextDocument( events.changeTextDocument.createHandler(textDocumentContentProvider), null, -- cgit v1.2.3 From 1b4e0ec1c868c7f2a0eef1e59bfa382db85a6900 Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Sun, 3 Mar 2019 21:54:51 +0200 Subject: Rename syntaxtree text provider to SyntaxTreeContentProvider --- editors/code/src/extension.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'editors/code/src/extension.ts') diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index 5134bb258..894334c55 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 ); -- cgit v1.2.3 From 0db95fc812d2c839e847527b774dfda170266cec Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Sun, 3 Mar 2019 22:03:37 +0200 Subject: Allow syntax tree to update when changing files Previously when using the file based syntax tree, it would not update until a change had been made in the new file. Now we automatically update the syntax tree to match the current file. --- editors/code/src/extension.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'editors/code/src/extension.ts') diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index 894334c55..941beba18 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts @@ -94,13 +94,13 @@ export function activate(context: vscode.ExtensionContext) { notifications.publishDecorations.handle ] ]; + const syntaxTreeContentProvider = new SyntaxTreeContentProvider(); // The events below are plain old javascript events, triggered and handled by vscode vscode.window.onDidChangeActiveTextEditor( - events.changeActiveTextEditor.handle + events.changeActiveTextEditor.makeHandler(syntaxTreeContentProvider) ); - const syntaxTreeContentProvider = new SyntaxTreeContentProvider(); disposeOnDeactivation( vscode.workspace.registerTextDocumentContentProvider( 'rust-analyzer', -- cgit v1.2.3