aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/main.ts
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-30 18:05:41 +0000
committerAleksey Kladov <[email protected]>2019-12-30 18:07:59 +0000
commitca5c59507f76b8e30658d6c815b823c9636d786a (patch)
treec953cf7eaaf7f6892e7cff63b5b96ff3060826a8 /editors/code/src/main.ts
parentac3d0e83403be22ec31d62a1501d726f6e6f81e1 (diff)
Refactor show syntax tree action
Diffstat (limited to 'editors/code/src/main.ts')
-rw-r--r--editors/code/src/main.ts26
1 files changed, 3 insertions, 23 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 55fedd8bb..d92cd164f 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -4,7 +4,6 @@ import * as lc from 'vscode-languageclient';
4import * as commands from './commands'; 4import * as commands from './commands';
5import { ExpandMacroContentProvider } from './commands/expand_macro'; 5import { ExpandMacroContentProvider } from './commands/expand_macro';
6import { HintsUpdater } from './commands/inlay_hints'; 6import { HintsUpdater } from './commands/inlay_hints';
7import { SyntaxTreeContentProvider } from './commands/syntaxTree';
8import { StatusDisplay } from './commands/watch_status'; 7import { StatusDisplay } from './commands/watch_status';
9import * as events from './events'; 8import * as events from './events';
10import * as notifications from './notifications'; 9import * as notifications from './notifications';
@@ -20,6 +19,7 @@ export async function activate(context: vscode.ExtensionContext) {
20 ctx.registerCommand('matchingBrace', commands.matchingBrace); 19 ctx.registerCommand('matchingBrace', commands.matchingBrace);
21 ctx.registerCommand('joinLines', commands.joinLines); 20 ctx.registerCommand('joinLines', commands.joinLines);
22 ctx.registerCommand('parentModule', commands.parentModule); 21 ctx.registerCommand('parentModule', commands.parentModule);
22 ctx.registerCommand('syntaxTree', commands.syntaxTree);
23 23
24 function disposeOnDeactivation(disposable: vscode.Disposable) { 24 function disposeOnDeactivation(disposable: vscode.Disposable) {
25 context.subscriptions.push(disposable); 25 context.subscriptions.push(disposable);
@@ -55,10 +55,7 @@ export async function activate(context: vscode.ExtensionContext) {
55 disposeOnDeactivation(watchStatus); 55 disposeOnDeactivation(watchStatus);
56 56
57 // Notifications are events triggered by the language server 57 // Notifications are events triggered by the language server
58 const allNotifications: Iterable<[ 58 const allNotifications: [string, lc.GenericNotificationHandler][] = [
59 string,
60 lc.GenericNotificationHandler,
61 ]> = [
62 [ 59 [
63 'rust-analyzer/publishDecorations', 60 'rust-analyzer/publishDecorations',
64 notifications.publishDecorations.handle, 61 notifications.publishDecorations.handle,
@@ -68,42 +65,25 @@ export async function activate(context: vscode.ExtensionContext) {
68 params => watchStatus.handleProgressNotification(params), 65 params => watchStatus.handleProgressNotification(params),
69 ], 66 ],
70 ]; 67 ];
71 const syntaxTreeContentProvider = new SyntaxTreeContentProvider();
72 const expandMacroContentProvider = new ExpandMacroContentProvider(); 68 const expandMacroContentProvider = new ExpandMacroContentProvider();
73 69
74 // The events below are plain old javascript events, triggered and handled by vscode 70 // The events below are plain old javascript events, triggered and handled by vscode
75 vscode.window.onDidChangeActiveTextEditor( 71 vscode.window.onDidChangeActiveTextEditor(
76 events.changeActiveTextEditor.makeHandler(syntaxTreeContentProvider), 72 events.changeActiveTextEditor.makeHandler(),
77 ); 73 );
78 74
79 disposeOnDeactivation( 75 disposeOnDeactivation(
80 vscode.workspace.registerTextDocumentContentProvider( 76 vscode.workspace.registerTextDocumentContentProvider(
81 'rust-analyzer', 77 'rust-analyzer',
82 syntaxTreeContentProvider,
83 ),
84 );
85 disposeOnDeactivation(
86 vscode.workspace.registerTextDocumentContentProvider(
87 'rust-analyzer',
88 expandMacroContentProvider, 78 expandMacroContentProvider,
89 ), 79 ),
90 ); 80 );
91 81
92 registerCommand( 82 registerCommand(
93 'rust-analyzer.syntaxTree',
94 commands.syntaxTree.createHandle(syntaxTreeContentProvider),
95 );
96 registerCommand(
97 'rust-analyzer.expandMacro', 83 'rust-analyzer.expandMacro',
98 commands.expandMacro.createHandle(expandMacroContentProvider), 84 commands.expandMacro.createHandle(expandMacroContentProvider),
99 ); 85 );
100 86
101 vscode.workspace.onDidChangeTextDocument(
102 events.changeTextDocument.createHandler(syntaxTreeContentProvider),
103 null,
104 context.subscriptions,
105 );
106
107 const startServer = () => Server.start(allNotifications); 87 const startServer = () => Server.start(allNotifications);
108 const reloadCommand = () => reloadServer(startServer); 88 const reloadCommand = () => reloadServer(startServer);
109 89