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 782e544dbfa65..c18ef40d7792a --- 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'; @@ -363,6 +367,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' @@ -378,34 +483,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];