From 3ccd05fedc46796f793295901a8619492256468e Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Mon, 18 Nov 2019 02:47:50 +0800 Subject: Add recursive expand in vscode --- editors/code/src/extension.ts | 20 +++++++++++++++----- 1 file changed, 15 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 c06928d12..1dfa6046f 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts @@ -3,6 +3,7 @@ import * as lc from 'vscode-languageclient'; import * as commands from './commands'; import { CargoWatchProvider } from './commands/cargo_watch'; +import { ExpandMacroHoverProvider } from './commands/expand_macro' import { HintsUpdater } from './commands/inlay_hints'; import { interactivelyStartCargoWatch, @@ -91,11 +92,11 @@ export function activate(context: vscode.ExtensionContext) { const allNotifications: Iterable< [string, lc.GenericNotificationHandler] > = [ - [ - 'rust-analyzer/publishDecorations', - notifications.publishDecorations.handle - ] - ]; + [ + 'rust-analyzer/publishDecorations', + notifications.publishDecorations.handle + ] + ]; const syntaxTreeContentProvider = new SyntaxTreeContentProvider(); // The events below are plain old javascript events, triggered and handled by vscode @@ -121,6 +122,15 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions ); + const expandMacroContentProvider = new ExpandMacroHoverProvider(); + + disposeOnDeactivation( + vscode.languages.registerHoverProvider( + 'rust', + expandMacroContentProvider + ) + ); + const startServer = () => Server.start(allNotifications); const reloadCommand = () => reloadServer(startServer); -- cgit v1.2.3 From 8010b42b21a59e4bb1e025155b8133ae52d3cf45 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Mon, 18 Nov 2019 03:39:11 +0800 Subject: Fix npm formatting --- editors/code/src/extension.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'editors/code/src/extension.ts') diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index 1dfa6046f..8654b6030 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts @@ -3,7 +3,7 @@ import * as lc from 'vscode-languageclient'; import * as commands from './commands'; import { CargoWatchProvider } from './commands/cargo_watch'; -import { ExpandMacroHoverProvider } from './commands/expand_macro' +import { ExpandMacroHoverProvider } from './commands/expand_macro'; import { HintsUpdater } from './commands/inlay_hints'; import { interactivelyStartCargoWatch, @@ -92,11 +92,11 @@ export function activate(context: vscode.ExtensionContext) { const allNotifications: Iterable< [string, lc.GenericNotificationHandler] > = [ - [ - 'rust-analyzer/publishDecorations', - notifications.publishDecorations.handle - ] - ]; + [ + 'rust-analyzer/publishDecorations', + notifications.publishDecorations.handle + ] + ]; const syntaxTreeContentProvider = new SyntaxTreeContentProvider(); // The events below are plain old javascript events, triggered and handled by vscode -- cgit v1.2.3 From d16cc223e100ae9a29384f104a378932088e0c3c Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Wed, 20 Nov 2019 01:06:10 +0800 Subject: Use DocumentProvider instead of Hover --- editors/code/src/extension.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'editors/code/src/extension.ts') diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index 8654b6030..683497dfd 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts @@ -3,7 +3,7 @@ import * as lc from 'vscode-languageclient'; import * as commands from './commands'; import { CargoWatchProvider } from './commands/cargo_watch'; -import { ExpandMacroHoverProvider } from './commands/expand_macro'; +import { ExpandMacroContentProvider } from './commands/expand_macro'; import { HintsUpdater } from './commands/inlay_hints'; import { interactivelyStartCargoWatch, @@ -98,6 +98,7 @@ export function activate(context: vscode.ExtensionContext) { ] ]; const syntaxTreeContentProvider = new SyntaxTreeContentProvider(); + const expandMacroContentProvider = new ExpandMacroContentProvider(); // The events below are plain old javascript events, triggered and handled by vscode vscode.window.onDidChangeActiveTextEditor( @@ -110,11 +111,21 @@ export function activate(context: vscode.ExtensionContext) { syntaxTreeContentProvider ) ); + disposeOnDeactivation( + vscode.workspace.registerTextDocumentContentProvider( + 'rust-analyzer', + expandMacroContentProvider + ) + ); registerCommand( 'rust-analyzer.syntaxTree', commands.syntaxTree.createHandle(syntaxTreeContentProvider) ); + registerCommand( + 'rust-analyzer.expandMacro', + commands.expandMacro.createHandle(expandMacroContentProvider) + ); vscode.workspace.onDidChangeTextDocument( events.changeTextDocument.createHandler(syntaxTreeContentProvider), @@ -122,15 +133,6 @@ export function activate(context: vscode.ExtensionContext) { context.subscriptions ); - const expandMacroContentProvider = new ExpandMacroHoverProvider(); - - disposeOnDeactivation( - vscode.languages.registerHoverProvider( - 'rust', - expandMacroContentProvider - ) - ); - const startServer = () => Server.start(allNotifications); const reloadCommand = () => reloadServer(startServer); -- cgit v1.2.3