aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/extension.ts
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-03-04 10:50:40 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-03-04 10:50:40 +0000
commit698aa9b3f6420351a41a3fb4819b871fec3c891c (patch)
treec782b2b62dcfaa253b8ed55824772ea7bf8fa16d /editors/code/src/extension.ts
parent17aaece6b39c2fb525be0eccce4626fc622e8236 (diff)
parent1ef2c0613134633ef0fe0d515f7d416e482f07fb (diff)
Merge #924
924: Improve show syntax tree r=matklad a=vipentti This implements some of the features discussed in #820. You can now select a range of syntax in a file and then use "Show Syntax Tree" to show its syntax. In addition you can select a range of syntax that is inside a string (typically test cases) and show its syntax as well. Previous behavior is still available, simply use "Show Syntax Tree" without a selection, and you get the live updating syntax tree. Additionally now the live updating tree will update when the active file is changed. Previously you had to type something in the new file to get the syntax tree to update. Co-authored-by: Ville Penttinen <[email protected]>
Diffstat (limited to 'editors/code/src/extension.ts')
-rw-r--r--editors/code/src/extension.ts16
1 files changed, 10 insertions, 6 deletions
diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts
index 8b332eeb2..941beba18 100644
--- a/editors/code/src/extension.ts
+++ b/editors/code/src/extension.ts
@@ -2,7 +2,7 @@ import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient'; 2import * as lc from 'vscode-languageclient';
3 3
4import * as commands from './commands'; 4import * as commands from './commands';
5import { TextDocumentContentProvider } from './commands/syntaxTree'; 5import { SyntaxTreeContentProvider } from './commands/syntaxTree';
6import * as events from './events'; 6import * as events from './events';
7import * as notifications from './notifications'; 7import * as notifications from './notifications';
8import { Server } from './server'; 8import { Server } from './server';
@@ -52,7 +52,6 @@ export function activate(context: vscode.ExtensionContext) {
52 registerCommand('rust-analyzer.collectGarbage', () => 52 registerCommand('rust-analyzer.collectGarbage', () =>
53 Server.client.sendRequest<null>('rust-analyzer/collectGarbage', null) 53 Server.client.sendRequest<null>('rust-analyzer/collectGarbage', null)
54 ); 54 );
55 registerCommand('rust-analyzer.syntaxTree', commands.syntaxTree.handle);
56 registerCommand( 55 registerCommand(
57 'rust-analyzer.extendSelection', 56 'rust-analyzer.extendSelection',
58 commands.extendSelection.handle 57 commands.extendSelection.handle
@@ -95,22 +94,27 @@ export function activate(context: vscode.ExtensionContext) {
95 notifications.publishDecorations.handle 94 notifications.publishDecorations.handle
96 ] 95 ]
97 ]; 96 ];
97 const syntaxTreeContentProvider = new SyntaxTreeContentProvider();
98 98
99 // The events below are plain old javascript events, triggered and handled by vscode 99 // The events below are plain old javascript events, triggered and handled by vscode
100 vscode.window.onDidChangeActiveTextEditor( 100 vscode.window.onDidChangeActiveTextEditor(
101 events.changeActiveTextEditor.handle 101 events.changeActiveTextEditor.makeHandler(syntaxTreeContentProvider)
102 ); 102 );
103 103
104 const textDocumentContentProvider = new TextDocumentContentProvider();
105 disposeOnDeactivation( 104 disposeOnDeactivation(
106 vscode.workspace.registerTextDocumentContentProvider( 105 vscode.workspace.registerTextDocumentContentProvider(
107 'rust-analyzer', 106 'rust-analyzer',
108 textDocumentContentProvider 107 syntaxTreeContentProvider
109 ) 108 )
110 ); 109 );
111 110
111 registerCommand(
112 'rust-analyzer.syntaxTree',
113 commands.syntaxTree.createHandle(syntaxTreeContentProvider)
114 );
115
112 vscode.workspace.onDidChangeTextDocument( 116 vscode.workspace.onDidChangeTextDocument(
113 events.changeTextDocument.createHandler(textDocumentContentProvider), 117 events.changeTextDocument.createHandler(syntaxTreeContentProvider),
114 null, 118 null,
115 context.subscriptions 119 context.subscriptions
116 ); 120 );