From bc2863b502e230d999e184e252d172a700b3462a Mon Sep 17 00:00:00 2001 From: Josh Pinkney Date: Mon, 13 Apr 2020 16:41:23 -0400 Subject: [PATCH] Implemented more vscode.executeXXX commands Signed-off-by: Josh Pinkney --- .../plugin-vscode-commands-contribution.ts | 143 ++++++++++++++++-- .../plugin-ext/src/plugin/known-commands.ts | 10 +- 2 files changed, 139 insertions(+), 14 deletions(-) mode change 100644 => 100755 packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts mode change 100644 => 100755 packages/plugin-ext/src/plugin/known-commands.ts diff --git a/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts b/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts old mode 100644 new mode 100755 index cfd762563bd3e..3ee7606528993 --- a/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts +++ b/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts @@ -35,7 +35,11 @@ import { Location, CallHierarchyItem, CallHierarchyIncomingCall, - CallHierarchyOutgoingCall + CallHierarchyOutgoingCall, + Hover, + TextEdit, + FormattingOptions, + DocumentHighlight } from '@theia/plugin-ext/lib/common/plugin-api-rpc-model'; import { DocumentsMainImpl } from '@theia/plugin-ext/lib/main/browser/documents-main'; import { createUntitledURI } from '@theia/plugin-ext/lib/main/browser/editor/untitled-resource'; @@ -375,6 +379,107 @@ export class PluginVscodeCommandsContribution implements CommandContribution { // Register built-in language service commands // see https://code.visualstudio.com/api/references/commands /* eslint-disable @typescript-eslint/no-explicit-any */ + + // TODO register other `vscode.execute...` commands. + // see https://github.com/microsoft/vscode/blob/master/src/vs/workbench/api/common/extHostApiCommands.ts + commands.registerCommand( + { + id: 'vscode.executeDefinitionProvider' + }, + { + execute: ((resource: URI, position: Position) => { + const args = { + resource: monaco.Uri.from(resource), + position: position + }; + return commands.executeCommand('_executeDefinitionProvider', args); + }) + } + ); + commands.registerCommand( + { + id: 'vscode.executeDeclarationProvider' + }, + { + execute: ((resource: URI, position: Position) => { + const args = { + resource: monaco.Uri.from(resource), + position: position + }; + return commands.executeCommand('_executeDeclarationProvider', args); + }) + } + ); + commands.registerCommand( + { + id: 'vscode.executeTypeDefinitionProvider' + }, + { + execute: ((resource: URI, position: Position) => { + const args = { + resource: monaco.Uri.from(resource), + position: position + }; + return commands.executeCommand('_executeTypeDefinitionProvider', args); + }) + } + ); + commands.registerCommand( + { + id: 'vscode.executeImplementationProvider' + }, + { + execute: ((resource: URI, position: Position) => { + const args = { + resource: monaco.Uri.from(resource), + position: position + }; + return commands.executeCommand('_executeImplementationProvider', args); + }) + } + ); + commands.registerCommand( + { + id: 'vscode.executeHoverProvider' + }, + { + execute: ((resource: URI, position: Position) => { + const args = { + resource: monaco.Uri.from(resource), + position: position + }; + return commands.executeCommand('_executeHoverProvider', args); + }) + } + ); + commands.registerCommand( + { + id: 'vscode.executeDocumentHighlights' + }, + { + execute: ((resource: URI, position: Position) => { + const args = { + resource: monaco.Uri.from(resource), + position: position + }; + return commands.executeCommand('_executeDocumentHighlights', args); + }) + } + ); + commands.registerCommand( + { + id: 'vscode.executeReferenceProvider' + }, + { + execute: ((resource: URI, position: Position) => { + const args = { + resource: monaco.Uri.from(resource), + position: position + }; + return commands.executeCommand('_executeReferenceProvider', args); + }) + } + ); commands.registerCommand( { id: 'vscode.executeDocumentSymbolProvider' @@ -390,34 +495,48 @@ export class PluginVscodeCommandsContribution implements CommandContribution { }) } ); - - // TODO register other `vscode.execute...` commands. - // see https://github.com/microsoft/vscode/blob/master/src/vs/workbench/api/common/extHostApiCommands.ts commands.registerCommand( { - id: 'vscode.executeReferenceProvider' + id: 'vscode.executeFormatDocumentProvider' }, { - execute: ((resource: URI, position: Position) => { + execute: ((resource: URI, options: FormattingOptions) => { const args = { resource: monaco.Uri.from(resource), - position: position + options: options }; - return commands.executeCommand('_executeReferenceProvider', args); + return commands.executeCommand('_executeFormatDocumentProvider', args); }) } ); commands.registerCommand( { - id: 'vscode.executeImplementationProvider' + id: 'vscode.executeFormatRangeProvider' }, { - execute: ((resource: URI, position: Position) => { + execute: ((resource: URI, range: Range, options: FormattingOptions) => { const args = { resource: monaco.Uri.from(resource), - position: position + range: range, + options: options }; - return commands.executeCommand('_executeImplementationProvider', args); + return commands.executeCommand('_executeFormatRangeProvider', args); + }) + } + ); + commands.registerCommand( + { + id: 'vscode.executeFormatOnTypeProvider' + }, + { + execute: ((resource: URI, position: Position, ch: string, options: FormattingOptions) => { + const args = { + resource: monaco.Uri.from(resource), + position: position, + ch: ch, + options: options + }; + return commands.executeCommand('_executeFormatOnTypeProvider', args); }) } ); diff --git a/packages/plugin-ext/src/plugin/known-commands.ts b/packages/plugin-ext/src/plugin/known-commands.ts old mode 100644 new mode 100755 index 0e027e4d205b7..dd6d2984edc0e --- a/packages/plugin-ext/src/plugin/known-commands.ts +++ b/packages/plugin-ext/src/plugin/known-commands.ts @@ -282,8 +282,14 @@ export namespace KnownCommands { }; // vscode-'executeXXX'-like commands - mappings['vscode.executeReferenceProvider'] = ['vscode.executeReferenceProvider', CONVERT_VSCODE_TO_MONACO, CONVERT_MONACO_TO_VSCODE]; - mappings['vscode.executeImplementationProvider'] = ['vscode.executeImplementationProvider', CONVERT_VSCODE_TO_MONACO, CONVERT_MONACO_TO_VSCODE]; + mappings['vscode.executeDefinitionProvider'] = ['vscode.executeDefinitionProvider', CONVERT_VSCODE_TO_MONACO, CONVERT_MONACO_TO_VSCODE]; + mappings['vscode.executeDeclarationProvider'] = ['vscode.executeDeclarationProvider', CONVERT_VSCODE_TO_MONACO, CONVERT_MONACO_TO_VSCODE]; + mappings['vscode.executeTypeDefinitionProvider'] = ['vscode.executeTypeDefinitionProvider', CONVERT_VSCODE_TO_MONACO, CONVERT_MONACO_TO_VSCODE]; + mappings['vscode.executeHoverProvider'] = ['vscode.executeHoverProvider', CONVERT_VSCODE_TO_MONACO, CONVERT_MONACO_TO_VSCODE]; + mappings['vscode.executeDocumentHighlights'] = ['vscode.executeDocumentHighlights', CONVERT_VSCODE_TO_MONACO, CONVERT_MONACO_TO_VSCODE]; + mappings['vscode.executeFormatDocumentProvider'] = ['vscode.executeFormatDocumentProvider', CONVERT_VSCODE_TO_MONACO, CONVERT_MONACO_TO_VSCODE]; + mappings['vscode.executeFormatRangeProvider'] = ['vscode.executeFormatRangeProvider', CONVERT_VSCODE_TO_MONACO, CONVERT_MONACO_TO_VSCODE]; + mappings['vscode.executeFormatOnTypeProvider'] = ['vscode.executeFormatOnTypeProvider', CONVERT_VSCODE_TO_MONACO, CONVERT_MONACO_TO_VSCODE]; mappings['vscode.prepareCallHierarchy'] = ['vscode.prepareCallHierarchy', CONVERT_VSCODE_TO_MONACO, CONVERT_MONACO_TO_VSCODE]; mappings['vscode.provideIncomingCalls'] = ['vscode.provideIncomingCalls', CONVERT_VSCODE_TO_MONACO, CONVERT_MONACO_TO_VSCODE]; mappings['vscode.provideOutgoingCalls'] = ['vscode.provideOutgoingCalls', CONVERT_VSCODE_TO_MONACO, CONVERT_MONACO_TO_VSCODE];