diff --git a/package.json b/package.json index b8aff570f3747..37ecf598cdc70 100644 --- a/package.json +++ b/package.json @@ -142,6 +142,7 @@ "vscode-builtin-xml": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/xml-1.39.1-prel.vsix", "vscode-builtin-yaml": "https://github.com/theia-ide/vscode-builtin-extensions/releases/download/v1.39.1-prel/yaml-1.39.1-prel.vsix", "vscode-editorconfig": "https://github.com/theia-ide/editorconfig-vscode/releases/download/v0.14.4/EditorConfig-0.14.4.vsix", - "vscode-eslint": "https://github.com/theia-ide/vscode-eslint/releases/download/release%2F2.0.15/vscode-eslint-2.0.15.vsix" + "vscode-eslint": "https://github.com/theia-ide/vscode-eslint/releases/download/release%2F2.0.15/vscode-eslint-2.0.15.vsix", + "vscode-references-view": "https://github.com/theia-ide/vscode-references-view/releases/download/v0.0.47/references-view-0.0.47.vsix" } } 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 index c379d8391c349..6acb4dadce13e 100644 --- a/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts +++ b/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts @@ -30,7 +30,13 @@ import { CommandService } from '@theia/core/lib/common/command'; import TheiaURI from '@theia/core/lib/common/uri'; import { EditorManager } from '@theia/editor/lib/browser'; import { CodeEditorWidget } from '@theia/plugin-ext/lib/main/browser/menus/menus-contribution-handler'; -import { TextDocumentShowOptions } from '@theia/plugin-ext/lib/common/plugin-api-rpc-model'; +import { + TextDocumentShowOptions, + Location, + CallHierarchyItem, + CallHierarchyIncomingCall, + CallHierarchyOutgoingCall +} 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'; import { toDocumentSymbol } from '@theia/plugin-ext/lib/plugin/type-converters'; @@ -40,6 +46,7 @@ import { WorkspaceService, WorkspaceInput } from '@theia/workspace/lib/browser/w import { DiffService } from '@theia/workspace/lib/browser/diff-service'; import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor'; import { inject, injectable } from 'inversify'; +import { Position } from '@theia/plugin-ext/lib/common/plugin-api-rpc'; import URI from 'vscode-uri'; export namespace VscodeCommands { @@ -374,8 +381,68 @@ 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' + }, + { + execute: ((resource: URI, position: Position) => { + const args = { + resource: monaco.Uri.from(resource), + position: position + }; + return commands.executeCommand('_executeReferenceProvider', 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.prepareCallHierarchy' + }, + { + execute: ((resource: URI, position: Position) => { + const args = { + resource: monaco.Uri.from(resource), + position: position + }; + return commands.executeCommand('_executePrepareCallHierarchy', args); + }) + } + ); + commands.registerCommand( + { + id: 'vscode.provideIncomingCalls' + }, + { + execute: ((item: CallHierarchyItem) => + commands.executeCommand('_executeProvideIncomingCalls', { item })) + } + ); + commands.registerCommand( + { + id: 'vscode.provideOutgoingCalls' + }, + { + execute: ((item: CallHierarchyItem) => + commands.executeCommand('_executeProvideOutgoingCalls', { item })) + } + ); } - } diff --git a/packages/plugin-ext/src/common/index.ts b/packages/plugin-ext/src/common/index.ts index 70fe4d10aa5f9..9d653b922fe83 100644 --- a/packages/plugin-ext/src/common/index.ts +++ b/packages/plugin-ext/src/common/index.ts @@ -18,4 +18,3 @@ export * from './plugin-protocol'; export * from './plugin-api-rpc'; export * from './plugin-ext-api-contribution'; -export * from './known-commands'; diff --git a/packages/plugin-ext/src/common/known-commands.ts b/packages/plugin-ext/src/common/known-commands.ts deleted file mode 100644 index 97bdbcc23f033..0000000000000 --- a/packages/plugin-ext/src/common/known-commands.ts +++ /dev/null @@ -1,327 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2019 Red Hat, Inc. and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -import { Range as R, Position as P, Location as L } from 'vscode-languageserver-types'; -import URI from 'vscode-uri'; -import * as theia from '@theia/plugin'; -import { cloneAndChange } from './objects'; -import { Position, Range, Location } from '../plugin/types-impl'; -import { fromPosition, fromRange, fromLocation } from '../plugin/type-converters'; - -// Here is a mapping of VSCode commands to monaco commands with their conversions -export namespace KnownCommands { - - /** - * Commands that you want to apply custom conversions to rather than pass through the automatic args converter. - * Would be useful in the case where theia provides some command and you need to provide custom conversions - */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const mappings: { [id: string]: [string, (args: any[] | undefined) => any[] | undefined] } = {}; - mappings['editor.action.showReferences'] = ['textEditor.commands.showReferences', createConversionFunction( - (uri: URI) => uri.toString(), - fromPositionToP, - toArrayConversion(fromLocationToL))]; - - /** - * Mapping of all editor.action commands to their conversion function. - * executeCommand inside of the plugin command registry will automatically convert - * incoming arguments from vscode api types to monaco types - */ - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const MONACO_CONVERSION_IDENTITY = (args: any[] | undefined) => { - if (!args) { - return args; - } - const argStack: ConversionFunction[] = []; - args.forEach(_ => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - argStack.push((arg: any) => monacoArgsConverter(arg)); - }); - if (args) { - return createConversionFunction(...argStack)(args); - } - }; - - mappings['editor.action.select.all'] = ['editor.action.select.all', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.toggleHighContrast'] = ['editor.action.toggleHighContrast', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.moveCarretLeftAction'] = ['editor.action.moveCarretLeftAction', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.moveCarretRightAction'] = ['editor.action.moveCarretRightAction', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.transposeLetters'] = ['editor.action.transposeLetters', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.clipboardCopyWithSyntaxHighlightingAction'] = ['editor.action.clipboardCopyWithSyntaxHighlightingAction', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.commentLine'] = ['editor.action.commentLine', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.addCommentLine'] = ['editor.action.addCommentLine', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.removeCommentLine'] = ['editor.action.removeCommentLine', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.blockComment'] = ['editor.action.blockComment', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.showContextMenu'] = ['editor.action.showContextMenu', MONACO_CONVERSION_IDENTITY]; - mappings['cursorUndo'] = ['cursorUndo', MONACO_CONVERSION_IDENTITY]; - mappings['editor.unfold'] = ['editor.unfold', MONACO_CONVERSION_IDENTITY]; - mappings['editor.unfoldRecursively'] = ['editor.unfoldRecursively', MONACO_CONVERSION_IDENTITY]; - mappings['editor.fold'] = ['editor.fold', MONACO_CONVERSION_IDENTITY]; - mappings['editor.foldRecursively'] = ['editor.foldRecursively', MONACO_CONVERSION_IDENTITY]; - mappings['editor.foldAll'] = ['editor.foldAll', MONACO_CONVERSION_IDENTITY]; - mappings['editor.unfoldAll'] = ['editor.unfoldAll', MONACO_CONVERSION_IDENTITY]; - mappings['editor.foldAllBlockComments'] = ['editor.foldAllBlockComments', MONACO_CONVERSION_IDENTITY]; - mappings['editor.foldAllMarkerRegions'] = ['editor.foldAllMarkerRegions', MONACO_CONVERSION_IDENTITY]; - mappings['editor.unfoldAllMarkerRegions'] = ['editor.unfoldAllMarkerRegions', MONACO_CONVERSION_IDENTITY]; - mappings['editor.foldLevel1'] = ['editor.foldLevel1', MONACO_CONVERSION_IDENTITY]; - mappings['editor.foldLevel2'] = ['editor.foldLevel2', MONACO_CONVERSION_IDENTITY]; - mappings['editor.foldLevel3'] = ['editor.foldLevel3', MONACO_CONVERSION_IDENTITY]; - mappings['editor.foldLevel4'] = ['editor.foldLevel4', MONACO_CONVERSION_IDENTITY]; - mappings['editor.foldLevel5'] = ['editor.foldLevel5', MONACO_CONVERSION_IDENTITY]; - mappings['editor.foldLevel6'] = ['editor.foldLevel6', MONACO_CONVERSION_IDENTITY]; - mappings['editor.foldLevel7'] = ['editor.foldLevel7', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.fontZoomIn'] = ['editor.action.fontZoomIn', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.fontZoomOut'] = ['editor.action.fontZoomOut', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.fontZoomReset'] = ['editor.action.fontZoomReset', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.formatDocument'] = ['editor.action.formatDocument', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.formatSelection'] = ['editor.action.formatSelection', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.copyLinesUpAction'] = ['editor.action.copyLinesUpAction', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.copyLinesDownAction'] = ['editor.action.copyLinesDownAction', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.moveLinesUpAction'] = ['editor.action.moveLinesUpAction', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.moveLinesDownAction'] = ['editor.action.moveLinesDownAction', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.sortLinesAscending'] = ['editor.action.sortLinesAscending', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.sortLinesDescending'] = ['editor.action.sortLinesDescending', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.trimTrailingWhitespace'] = ['editor.action.trimTrailingWhitespace', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.deleteLines'] = ['editor.action.deleteLines', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.indentLines'] = ['editor.action.indentLines', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.outdentLines'] = ['editor.action.outdentLines', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.insertLineBefore'] = ['editor.action.insertLineBefore', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.insertLineAfter'] = ['editor.action.insertLineAfter', MONACO_CONVERSION_IDENTITY]; - mappings['deleteAllLeft'] = ['deleteAllLeft', MONACO_CONVERSION_IDENTITY]; - mappings['deleteAllRight'] = ['deleteAllRight', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.joinLines'] = ['editor.action.joinLines', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.transpose'] = ['editor.action.transpose', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.transformToUppercase'] = ['editor.action.transformToUppercase', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.transformToLowercase'] = ['editor.action.transformToLowercase', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.transformToTitlecase'] = ['editor.action.transformToTitlecase', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.smartSelect.expand'] = ['editor.action.smartSelect.expand', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.smartSelect.shrink'] = ['editor.action.smartSelect.shrink', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.forceRetokenize'] = ['editor.action.forceRetokenize', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.toggleTabFocusMode'] = ['editor.action.toggleTabFocusMode', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.gotoLine'] = ['editor.action.gotoLine', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.quickOutline'] = ['editor.action.quickOutline', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.inPlaceReplace.up'] = ['editor.action.inPlaceReplace.up', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.inPlaceReplace.down'] = ['editor.action.inPlaceReplace.down', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.diffReview.next'] = ['editor.action.diffReview.next', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.diffReview.prev'] = ['editor.action.diffReview.prev', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.selectToBracket'] = ['editor.action.selectToBracket', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.jumpToBracket'] = ['editor.action.jumpToBracket', MONACO_CONVERSION_IDENTITY]; - mappings['actions.findWithSelection'] = ['actions.findWithSelection', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.nextMatchFindAction'] = ['editor.action.nextMatchFindAction', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.previousMatchFindAction'] = ['editor.action.previousMatchFindAction', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.nextSelectionMatchFindAction'] = ['editor.action.nextSelectionMatchFindAction', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.previousSelectionMatchFindAction'] = ['editor.action.previousSelectionMatchFindAction', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.openLink'] = ['editor.action.openLink', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.quickFix'] = ['editor.action.quickFix', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.refactor'] = ['editor.action.refactor', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.sourceAction'] = ['editor.action.sourceAction', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.organizeImports'] = ['editor.action.organizeImports', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.autoFix'] = ['editor.action.autoFix', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.fixAll'] = ['editor.action.fixAll', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.rename'] = ['editor.action.rename', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.insertCursorAbove'] = ['editor.action.insertCursorAbove', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.insertCursorBelow'] = ['editor.action.insertCursorBelow', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.insertCursorAtEndOfEachLineSelected'] = ['editor.action.insertCursorAtEndOfEachLineSelected', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.addSelectionToNextFindMatch'] = ['editor.action.addSelectionToNextFindMatch', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.addSelectionToPreviousFindMatch'] = ['editor.action.addSelectionToPreviousFindMatch', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.moveSelectionToNextFindMatch'] = ['editor.action.moveSelectionToNextFindMatch', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.moveSelectionToPreviousFindMatch'] = ['editor.action.moveSelectionToPreviousFindMatch', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.selectHighlights'] = ['editor.action.selectHighlights', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.changeAll'] = ['editor.action.changeAll', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.addCursorsToBottom'] = ['editor.action.addCursorsToBottom', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.addCursorsToTop'] = ['editor.action.addCursorsToTop', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.triggerParameterHints'] = ['editor.action.triggerParameterHints', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.wordHighlight.next'] = ['editor.action.wordHighlight.next', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.wordHighlight.prev'] = ['editor.action.wordHighlight.prev', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.wordHighlight.trigger'] = ['editor.action.wordHighlight.trigger', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.showAccessibilityHelp'] = ['editor.action.showAccessibilityHelp', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.inspectTokens'] = ['editor.action.inspectTokens', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.marker.next'] = ['editor.action.marker.next', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.marker.prev'] = ['editor.action.marker.prev', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.marker.nextInFiles'] = ['editor.action.marker.nextInFiles', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.marker.prevInFiles'] = ['editor.action.marker.prevInFiles', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.showHover'] = ['editor.action.showHover', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.revealDefinition'] = ['editor.action.revealDefinition', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.revealDefinitionAside'] = ['editor.action.revealDefinitionAside', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.peekDefinition'] = ['editor.action.peekDefinition', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.revealDeclaration'] = ['editor.action.revealDeclaration', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.peekDeclaration'] = ['editor.action.peekDeclaration', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.goToImplementation'] = ['editor.action.goToImplementation', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.peekImplementation'] = ['editor.action.peekImplementation', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.goToTypeDefinition'] = ['editor.action.goToTypeDefinition', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.peekTypeDefinition'] = ['editor.action.peekTypeDefinition', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.referenceSearch.trigger'] = ['editor.action.referenceSearch.trigger', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.triggerSuggest'] = ['editor.action.triggerSuggest', MONACO_CONVERSION_IDENTITY]; - mappings['closeReferenceSearchEditor'] = ['closeReferenceSearchEditor', MONACO_CONVERSION_IDENTITY]; - mappings['cancelSelection'] = ['cancelSelection', MONACO_CONVERSION_IDENTITY]; - mappings['cursorBottom'] = ['cursorBottom', MONACO_CONVERSION_IDENTITY]; - mappings['cursorBottomSelect'] = ['cursorBottomSelect', MONACO_CONVERSION_IDENTITY]; - mappings['cursorDown'] = ['cursorDown', MONACO_CONVERSION_IDENTITY]; - mappings['cursorDownSelect'] = ['cursorDownSelect', MONACO_CONVERSION_IDENTITY]; - mappings['cursorEnd'] = ['cursorEnd', MONACO_CONVERSION_IDENTITY]; - mappings['cursorEndSelect'] = ['cursorEndSelect', MONACO_CONVERSION_IDENTITY]; - mappings['cursorHome'] = ['cursorHome', MONACO_CONVERSION_IDENTITY]; - mappings['cursorHomeSelect'] = ['cursorHomeSelect', MONACO_CONVERSION_IDENTITY]; - mappings['cursorLeft'] = ['cursorLeft', MONACO_CONVERSION_IDENTITY]; - mappings['cursorLeftSelect'] = ['cursorLeftSelect', MONACO_CONVERSION_IDENTITY]; - mappings['cursorPageDown'] = ['cursorPageDown', MONACO_CONVERSION_IDENTITY]; - mappings['cursorPageDownSelect'] = ['cursorPageDownSelect', MONACO_CONVERSION_IDENTITY]; - mappings['cursorPageUp'] = ['cursorPageUp', MONACO_CONVERSION_IDENTITY]; - mappings['cursorPageUpSelect'] = ['cursorPageUpSelect', MONACO_CONVERSION_IDENTITY]; - mappings['cursorRight'] = ['cursorRight', MONACO_CONVERSION_IDENTITY]; - mappings['cursorRightSelect'] = ['cursorRightSelect', MONACO_CONVERSION_IDENTITY]; - mappings['cursorTop'] = ['cursorTop', MONACO_CONVERSION_IDENTITY]; - mappings['cursorTopSelect'] = ['cursorTopSelect', MONACO_CONVERSION_IDENTITY]; - mappings['cursorUp'] = ['cursorUp', MONACO_CONVERSION_IDENTITY]; - mappings['cursorUpSelect'] = ['cursorUpSelect', MONACO_CONVERSION_IDENTITY]; - mappings['deleteLeft'] = ['deleteLeft', MONACO_CONVERSION_IDENTITY]; - mappings['deleteRight'] = ['deleteRight', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.selectAll'] = ['editor.action.selectAll', MONACO_CONVERSION_IDENTITY]; - mappings['expandLineSelection'] = ['expandLineSelection', MONACO_CONVERSION_IDENTITY]; - mappings['outdent'] = ['outdent', MONACO_CONVERSION_IDENTITY]; - mappings['scrollLineDown'] = ['scrollLineDown', MONACO_CONVERSION_IDENTITY]; - mappings['scrollLineUp'] = ['scrollLineUp', MONACO_CONVERSION_IDENTITY]; - mappings['scrollPageDown'] = ['scrollPageDown', MONACO_CONVERSION_IDENTITY]; - mappings['scrollPageUp'] = ['scrollPageUp', MONACO_CONVERSION_IDENTITY]; - mappings['tab'] = ['tab', MONACO_CONVERSION_IDENTITY]; - mappings['removeSecondaryCursors'] = ['removeSecondaryCursors', MONACO_CONVERSION_IDENTITY]; - mappings['cursorWordRight'] = ['cursorWordEndRight', MONACO_CONVERSION_IDENTITY]; - mappings['cursorWordEndRight'] = ['cursorWordEndRight', MONACO_CONVERSION_IDENTITY]; - mappings['cursorWordEndRightSelect'] = ['cursorWordEndRightSelect', MONACO_CONVERSION_IDENTITY]; - mappings['cursorWordLeft'] = ['cursorWordStartLeft', MONACO_CONVERSION_IDENTITY]; - mappings['cursorWordStartLeft'] = ['cursorWordStartLeft', MONACO_CONVERSION_IDENTITY]; - mappings['cursorWordStartLeftSelect'] = ['cursorWordStartLeftSelect', MONACO_CONVERSION_IDENTITY]; - mappings['deleteWordLeft'] = ['deleteWordLeft', MONACO_CONVERSION_IDENTITY]; - mappings['deleteWordRight'] = ['deleteWordRight', MONACO_CONVERSION_IDENTITY]; - mappings['editor.cancelOperation'] = ['editor.cancelOperation', MONACO_CONVERSION_IDENTITY]; - mappings['editor.gotoNextSymbolFromResult'] = ['editor.gotoNextSymbolFromResult', MONACO_CONVERSION_IDENTITY]; - mappings['editor.gotoNextSymbolFromResult.cancel'] = ['editor.gotoNextSymbolFromResult.cancel', MONACO_CONVERSION_IDENTITY]; - mappings['openReferenceToSide'] = ['openReferenceToSide', MONACO_CONVERSION_IDENTITY]; - mappings['toggleExplainMode'] = ['toggleExplainMode', MONACO_CONVERSION_IDENTITY]; - mappings['closeFindWidget'] = ['closeFindWidget', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.replaceAll'] = ['editor.action.replaceAll', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.replaceOne'] = ['editor.action.replaceOne', MONACO_CONVERSION_IDENTITY]; - mappings['editor.action.selectAllMatches'] = ['editor.action.selectAllMatches', MONACO_CONVERSION_IDENTITY]; - mappings['toggleFindCaseSensitive'] = ['toggleFindCaseSensitive', MONACO_CONVERSION_IDENTITY]; - mappings['toggleFindInSelection'] = ['toggleFindInSelection', MONACO_CONVERSION_IDENTITY]; - mappings['toggleFindRegex'] = ['toggleFindRegex', MONACO_CONVERSION_IDENTITY]; - mappings['toggleFindWholeWord'] = ['toggleFindWholeWord', MONACO_CONVERSION_IDENTITY]; - mappings['jumpToNextSnippetPlaceholder'] = ['jumpToNextSnippetPlaceholder', MONACO_CONVERSION_IDENTITY]; - mappings['jumpToPrevSnippetPlaceholder'] = ['jumpToPrevSnippetPlaceholder', MONACO_CONVERSION_IDENTITY]; - mappings['leaveEditorMessage'] = ['leaveEditorMessage', MONACO_CONVERSION_IDENTITY]; - mappings['leaveSnippet'] = ['leaveSnippet', MONACO_CONVERSION_IDENTITY]; - mappings['closeMarkersNavigation'] = ['closeMarkersNavigation', MONACO_CONVERSION_IDENTITY]; - mappings['goToNextReferenceFromEmbeddedEditor'] = ['goToNextReferenceFromEmbeddedEditor', MONACO_CONVERSION_IDENTITY]; - mappings['goToPreviousReferenceFromEmbeddedEditor'] = ['goToPreviousReferenceFromEmbeddedEditor', MONACO_CONVERSION_IDENTITY]; - mappings['closeParameterHints'] = ['closeParameterHints', MONACO_CONVERSION_IDENTITY]; - mappings['showNextParameterHint'] = ['showNextParameterHint', MONACO_CONVERSION_IDENTITY]; - mappings['showPrevParameterHint'] = ['showPrevParameterHint', MONACO_CONVERSION_IDENTITY]; - mappings['acceptSelectedSuggestion'] = ['acceptSelectedSuggestion', MONACO_CONVERSION_IDENTITY]; - mappings['acceptSelectedSuggestionOnEnter'] = ['acceptSelectedSuggestionOnEnter', MONACO_CONVERSION_IDENTITY]; - mappings['hideSuggestWidget'] = ['hideSuggestWidget', MONACO_CONVERSION_IDENTITY]; - mappings['insertBestCompletion'] = ['insertBestCompletion', MONACO_CONVERSION_IDENTITY]; - mappings['insertNextSuggestion'] = ['insertNextSuggestion', MONACO_CONVERSION_IDENTITY]; - mappings['insertPrevSuggestion'] = ['insertPrevSuggestion', MONACO_CONVERSION_IDENTITY]; - mappings['selectNextPageSuggestion'] = ['selectNextPageSuggestion', MONACO_CONVERSION_IDENTITY]; - mappings['selectNextSuggestion'] = ['selectNextSuggestion', MONACO_CONVERSION_IDENTITY]; - mappings['selectPrevPageSuggestion'] = ['selectPrevPageSuggestion', MONACO_CONVERSION_IDENTITY]; - mappings['selectPrevSuggestion'] = ['selectPrevSuggestion', MONACO_CONVERSION_IDENTITY]; - mappings['toggleSuggestionDetails'] = ['toggleSuggestionDetails', MONACO_CONVERSION_IDENTITY]; - mappings['toggleSuggestionFocus'] = ['toggleSuggestionFocus', MONACO_CONVERSION_IDENTITY]; - mappings['acceptRenameInput'] = ['acceptRenameInput', MONACO_CONVERSION_IDENTITY]; - mappings['cancelRenameInput'] = ['cancelRenameInput', MONACO_CONVERSION_IDENTITY]; - mappings['closeAccessibilityHelp'] = ['closeAccessibilityHelp', MONACO_CONVERSION_IDENTITY]; - mappings['history.showNext'] = ['history.showNext', MONACO_CONVERSION_IDENTITY]; - mappings['history.showPrevious'] = ['history.showPrevious', MONACO_CONVERSION_IDENTITY]; - mappings['closeReferenceSearch'] = ['closeReferenceSearch', MONACO_CONVERSION_IDENTITY]; - mappings['goToNextReference'] = ['goToNextReference', MONACO_CONVERSION_IDENTITY]; - mappings['goToPreviousReference'] = ['goToPreviousReference', MONACO_CONVERSION_IDENTITY]; - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - export function map(id: string, args: any[] | undefined, toDo: (mappedId: string, mappedArgs: any[] | undefined) => T): T { - if (mappings[id]) { - return toDo(mappings[id][0], mappings[id][1](args)); - } else { - return toDo(id, args); - } - } - - export function mapped(id: string): boolean { - return !!mappings[id]; - } - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - type ConversionFunction = ((parameter: any) => any) | undefined; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - function createConversionFunction(...conversions: ConversionFunction[]): (args: any[] | undefined) => any[] | undefined { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - return function (args: any[] | undefined): any[] | undefined { - if (!args) { - return args; - } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - return args.map(function (arg: any, index: number): any { - if (index < conversions.length) { - const conversion = conversions[index]; - if (conversion) { - return conversion(arg); - } - } - return arg; - }); - }; - } - - function fromPositionToP(p: theia.Position): P { - return P.create(p.line, p.character); - } - - function fromRangeToR(r: theia.Range): R { - return R.create(fromPositionToP(r.start), fromPositionToP(r.end)); - } - - function fromLocationToL(l: theia.Location): L { - return L.create(l.uri.toString(), fromRangeToR(l.range)); - } - - // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/tslint/config - function monacoArgsConverter(args: any[]) { - // tslint:disable-next-line:typedef - return cloneAndChange(args, function (value) { - if (Position.isPosition(value)) { - return fromPosition(value); - } - if (Range.isRange(value)) { - return fromRange(value); - } - if (Location.isLocation(value)) { - return fromLocation(value); - } - if (!Array.isArray(value)) { - return value; - } - }); - } - -} - -function toArrayConversion(f: (a: T) => U): (a: T[]) => U[] { - // tslint:disable-next-line:typedef - return function (a: T[]) { - return a.map(f); - }; -} diff --git a/packages/plugin-ext/src/common/plugin-api-rpc-model.ts b/packages/plugin-ext/src/common/plugin-api-rpc-model.ts index 72392f6e3ae82..da5e5c2ead20a 100644 --- a/packages/plugin-ext/src/common/plugin-api-rpc-model.ts +++ b/packages/plugin-ext/src/common/plugin-api-rpc-model.ts @@ -519,3 +519,25 @@ export interface CallHierarchyReference { callerDefinition: CallHierarchyDefinition, references: Range[] } + +export interface CallHierarchyItem { + _sessionId?: string; + _itemId?: string; + + kind: SymbolKind; + name: string; + detail?: string; + uri: UriComponents; + range: Range; + selectionRange: Range; +} + +export interface CallHierarchyIncomingCall { + from: CallHierarchyItem; + fromRanges: Range[]; +} + +export interface CallHierarchyOutgoingCall { + to: CallHierarchyItem; + fromRanges: Range[]; +} diff --git a/packages/plugin-ext/src/common/plugin-api-rpc.ts b/packages/plugin-ext/src/common/plugin-api-rpc.ts index 7d5c500590acf..b13260f4280eb 100644 --- a/packages/plugin-ext/src/common/plugin-api-rpc.ts +++ b/packages/plugin-ext/src/common/plugin-api-rpc.ts @@ -514,6 +514,8 @@ export interface TreeViewsMain { $unregisterTreeDataProvider(treeViewId: string): void; $refresh(treeViewId: string): void; $reveal(treeViewId: string, treeItemId: string): Promise; + $setMessage(treeViewId: string, message: string): void; + $setTitle(treeViewId: string, title: string): void; } export interface TreeViewsExt { diff --git a/packages/plugin-ext/src/main/browser/style/tree.css b/packages/plugin-ext/src/main/browser/style/tree.css index 1d4289aa42053..9df80b50dd494 100644 --- a/packages/plugin-ext/src/main/browser/style/tree.css +++ b/packages/plugin-ext/src/main/browser/style/tree.css @@ -38,3 +38,9 @@ align-items: center; height: 100%; } + +.theia-tree-view .theia-TreeContainer .theia-TreeViewInfo { + margin-top: 7px; + margin-bottom: 10px; + margin-left: 17px; +} diff --git a/packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts b/packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts index 5b5a8e0c6ef81..3f6f69231cba0 100644 --- a/packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts +++ b/packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts @@ -268,6 +268,23 @@ export class PluginViewRegistry implements FrontendApplicationContribution { } } })); + + toDispose.push(this.commands.registerCommand({ + id: `${view.id}.focus` + }, { + execute: async () => { + const widget = await this.openView(view.id); + if (widget) { + const data = this.views.get(view.id); + if (data) { + const [containerId] = data; + const identifier = this.toViewContainerIdentifier(containerId); + this.shell.activateWidget(identifier.id); + } + } + } + })); + return toDispose; } diff --git a/packages/plugin-ext/src/main/browser/view/plugin-view-widget.ts b/packages/plugin-ext/src/main/browser/view/plugin-view-widget.ts index 807bad6661bf3..3f22cd274108c 100644 --- a/packages/plugin-ext/src/main/browser/view/plugin-view-widget.ts +++ b/packages/plugin-ext/src/main/browser/view/plugin-view-widget.ts @@ -21,6 +21,7 @@ import { CommandRegistry } from '@theia/core/lib/common/command'; import { ViewContextKeyService } from './view-context-key-service'; import { StatefulWidget } from '@theia/core/lib/browser/shell/shell-layout-restorer'; import { Message } from '@phosphor/messaging'; +import { TreeViewWidget } from './tree-view-widget'; @injectable() export class PluginViewWidgetIdentifier { @@ -59,6 +60,7 @@ export class PluginViewWidget extends Panel implements StatefulWidget { const widget = this.widgets[0]; if (widget) { widget.activate(); + this.updateWidgetMessage(); } else { this.node.focus(); } @@ -67,12 +69,14 @@ export class PluginViewWidget extends Panel implements StatefulWidget { storeState(): PluginViewWidget.State { return { label: this.title.label, + message: this.message, widgets: this.widgets }; } restoreState(state: PluginViewWidget.State): void { this.title.label = state.label; + this.message = state.message; for (const widget of state.widgets) { this.addWidget(widget); } @@ -96,10 +100,39 @@ export class PluginViewWidget extends Panel implements StatefulWidget { } } + private _message: string | undefined; + get message(): string | undefined { + return this._message; + } + + set message(message: string | undefined) { + this._message = message; + this.updateWidgetMessage(); + } + + private updateWidgetMessage(): void { + const widget = this.widgets[0]; + if (widget) { + if (widget instanceof TreeViewWidget) { + widget.message = this._message; + } + } + } + + addWidget(widget: Widget): void { + super.addWidget(widget); + this.updateWidgetMessage(); + } + + insertWidget(index: number, widget: Widget): void { + super.insertWidget(index, widget); + this.updateWidgetMessage(); + } } export namespace PluginViewWidget { export interface State { label: string + message?: string; widgets: ReadonlyArray } } diff --git a/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx b/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx index 2f2d59e5530f0..f53f3e6c2ea2c 100644 --- a/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx +++ b/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx @@ -371,4 +371,25 @@ export class TreeViewWidget extends TreeWidget { } } } + + private _message: string | undefined; + get message(): string | undefined { + return this._message; + } + + set message(message: string | undefined) { + this._message = message; + this.update(); + } + + protected render(): React.ReactNode { + return React.createElement('div', this.createContainerAttributes(), this.renderSearchInfo(), this.renderTree(this.model)); + } + + protected renderSearchInfo(): React.ReactNode { + if (this._message) { + return
{this._message}
; + } + return undefined; + } } diff --git a/packages/plugin-ext/src/main/browser/view/tree-views-main.ts b/packages/plugin-ext/src/main/browser/view/tree-views-main.ts index 15f3eab001e35..ecac147c4d65a 100644 --- a/packages/plugin-ext/src/main/browser/view/tree-views-main.ts +++ b/packages/plugin-ext/src/main/browser/view/tree-views-main.ts @@ -22,6 +22,7 @@ import { SelectableTreeNode, ExpandableTreeNode, CompositeTreeNode, WidgetManage import { ViewContextKeyService } from './view-context-key-service'; import { Disposable, DisposableCollection } from '@theia/core'; import { TreeViewWidget, TreeViewNode } from './tree-view-widget'; +import { PluginViewWidget } from './plugin-view-widget'; export class TreeViewsMainImpl implements TreeViewsMain, Disposable { @@ -108,6 +109,20 @@ export class TreeViewsMainImpl implements TreeViewsMain, Disposable { } } + async $setMessage(treeViewId: string, message: string): Promise { + const viewPanel = await this.viewRegistry.getView(treeViewId); + if (viewPanel instanceof PluginViewWidget) { + viewPanel.message = message; + } + } + + async $setTitle(treeViewId: string, title: string): Promise { + const viewPanel = await this.viewRegistry.getView(treeViewId); + if (viewPanel) { + viewPanel.title.label = title; + } + } + protected handleTreeEvents(treeViewId: string, treeViewWidget: TreeViewWidget): void { this.toDispose.push(treeViewWidget.model.onExpansionChanged(event => { this.proxy.$setExpanded(treeViewId, event.id, event.expanded); diff --git a/packages/plugin-ext/src/plugin/command-registry.ts b/packages/plugin-ext/src/plugin/command-registry.ts index 1c78066051e20..cc19a98b0d5e4 100644 --- a/packages/plugin-ext/src/plugin/command-registry.ts +++ b/packages/plugin-ext/src/plugin/command-registry.ts @@ -24,7 +24,7 @@ import { CommandRegistryExt, PLUGIN_RPC_CONTEXT as Ext, CommandRegistryMain } fr import { RPCProtocol } from '../common/rpc-protocol'; import { Disposable } from './types-impl'; import { DisposableCollection } from '@theia/core'; -import { KnownCommands } from '../common/known-commands'; +import { KnownCommands } from './known-commands'; // eslint-disable-next-line @typescript-eslint/no-explicit-any export type Handler = (...args: any[]) => T | PromiseLike; @@ -100,8 +100,19 @@ export class CommandRegistryImpl implements CommandRegistryExt { return this.executeLocalCommand(id, ...args); } else if (KnownCommands.mapped(id)) { // Using the KnownCommand exclusions, convert the commands manually - return KnownCommands.map(id, args, (mappedId: string, mappedArgs: any[] | undefined) => - this.proxy.$executeCommand(mappedId, ...mappedArgs)); + return KnownCommands.map(id, args, (mappedId: string, mappedArgs: any[] | undefined, mappedResult: KnownCommands.ConversionFunction) => { + const mr: KnownCommands.ConversionFunction = mappedResult; + return this.proxy.$executeCommand(mappedId, ...mappedArgs).then((result: any) => { + if (!result) { + return undefined; + } + if (!mr) { + return result; + } + return mr(result); + }); + } + ); } else { return this.proxy.$executeCommand(id, ...args); } diff --git a/packages/plugin-ext/src/plugin/known-commands.spec.ts b/packages/plugin-ext/src/plugin/known-commands.spec.ts index fb7d1ffcde44e..f26c10c4a021c 100644 --- a/packages/plugin-ext/src/plugin/known-commands.spec.ts +++ b/packages/plugin-ext/src/plugin/known-commands.spec.ts @@ -15,7 +15,7 @@ ********************************************************************************/ import * as assert from 'assert'; -import { KnownCommands } from '../common/known-commands'; +import { KnownCommands } from './known-commands'; import URI from 'vscode-uri'; import { Position } from './types-impl'; import { fromPosition } from './type-converters'; diff --git a/packages/plugin-ext/src/plugin/known-commands.ts b/packages/plugin-ext/src/plugin/known-commands.ts new file mode 100644 index 0000000000000..361475362d427 --- /dev/null +++ b/packages/plugin-ext/src/plugin/known-commands.ts @@ -0,0 +1,389 @@ +/******************************************************************************** + * Copyright (C) 2019 Red Hat, Inc. and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the Eclipse + * Public License v. 2.0 are satisfied: GNU General Public License, version 2 + * with the GNU Classpath Exception which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + ********************************************************************************/ + +import { Range as R, Position as P, Location as L } from 'vscode-languageserver-types'; +import URI from 'vscode-uri'; +import * as theia from '@theia/plugin'; +import { cloneAndChange } from '../common/objects'; +import { Position, Range, Location, CallHierarchyItem } from './types-impl'; +import { + fromPosition, fromRange, fromLocation, + isModelLocation, toLocation, + isModelCallHierarchyItem, fromCallHierarchyItem, toCallHierarchyItem, + isModelCallHierarchyIncomingCall, toCallHierarchyIncomingCall, + isModelCallHierarchyOutgoingCall, toCallHierarchyOutgoingCall +} from './type-converters'; + +// Here is a mapping of VSCode commands to monaco commands with their conversions +export namespace KnownCommands { + + /** + * Commands that you want to apply custom conversions to rather than pass through the automatic args converter. + * Would be useful in the case where theia provides some command and you need to provide custom conversions + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const mappings: { [id: string]: [string, (args: any[] | undefined) => any[] | undefined, ((results: any[] | undefined) => any[] | undefined)?] } = {}; + mappings['editor.action.showReferences'] = ['textEditor.commands.showReferences', createConversionFunction( + (uri: URI) => uri.toString(), + fromPositionToP, + toArrayConversion(fromLocationToL)), + createConversionFunction()]; + + /** + * Mapping of all editor.action commands to their conversion function. + * executeCommand inside of the plugin command registry will automatically convert + * incoming arguments from vscode api types to monaco types + */ + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const CONVERT_VSCODE_TO_MONACO = (args: any[] | undefined) => { + if (!args) { + return args; + } + const argStack: ConversionFunction[] = []; + args.forEach(_ => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + argStack.push((arg: any) => vscodeToMonacoArgsConverter(arg)); + }); + if (args) { + return createConversionFunction(...argStack)(args); + } + }; + + mappings['editor.action.select.all'] = ['editor.action.select.all', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.toggleHighContrast'] = ['editor.action.toggleHighContrast', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.moveCarretLeftAction'] = ['editor.action.moveCarretLeftAction', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.moveCarretRightAction'] = ['editor.action.moveCarretRightAction', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.transposeLetters'] = ['editor.action.transposeLetters', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.clipboardCopyWithSyntaxHighlightingAction'] = ['editor.action.clipboardCopyWithSyntaxHighlightingAction', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.commentLine'] = ['editor.action.commentLine', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.addCommentLine'] = ['editor.action.addCommentLine', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.removeCommentLine'] = ['editor.action.removeCommentLine', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.blockComment'] = ['editor.action.blockComment', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.showContextMenu'] = ['editor.action.showContextMenu', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorUndo'] = ['cursorUndo', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.unfold'] = ['editor.unfold', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.unfoldRecursively'] = ['editor.unfoldRecursively', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.fold'] = ['editor.fold', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.foldRecursively'] = ['editor.foldRecursively', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.foldAll'] = ['editor.foldAll', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.unfoldAll'] = ['editor.unfoldAll', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.foldAllBlockComments'] = ['editor.foldAllBlockComments', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.foldAllMarkerRegions'] = ['editor.foldAllMarkerRegions', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.unfoldAllMarkerRegions'] = ['editor.unfoldAllMarkerRegions', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.foldLevel1'] = ['editor.foldLevel1', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.foldLevel2'] = ['editor.foldLevel2', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.foldLevel3'] = ['editor.foldLevel3', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.foldLevel4'] = ['editor.foldLevel4', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.foldLevel5'] = ['editor.foldLevel5', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.foldLevel6'] = ['editor.foldLevel6', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.foldLevel7'] = ['editor.foldLevel7', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.fontZoomIn'] = ['editor.action.fontZoomIn', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.fontZoomOut'] = ['editor.action.fontZoomOut', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.fontZoomReset'] = ['editor.action.fontZoomReset', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.formatDocument'] = ['editor.action.formatDocument', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.formatSelection'] = ['editor.action.formatSelection', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.copyLinesUpAction'] = ['editor.action.copyLinesUpAction', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.copyLinesDownAction'] = ['editor.action.copyLinesDownAction', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.moveLinesUpAction'] = ['editor.action.moveLinesUpAction', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.moveLinesDownAction'] = ['editor.action.moveLinesDownAction', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.sortLinesAscending'] = ['editor.action.sortLinesAscending', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.sortLinesDescending'] = ['editor.action.sortLinesDescending', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.trimTrailingWhitespace'] = ['editor.action.trimTrailingWhitespace', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.deleteLines'] = ['editor.action.deleteLines', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.indentLines'] = ['editor.action.indentLines', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.outdentLines'] = ['editor.action.outdentLines', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.insertLineBefore'] = ['editor.action.insertLineBefore', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.insertLineAfter'] = ['editor.action.insertLineAfter', CONVERT_VSCODE_TO_MONACO]; + mappings['deleteAllLeft'] = ['deleteAllLeft', CONVERT_VSCODE_TO_MONACO]; + mappings['deleteAllRight'] = ['deleteAllRight', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.joinLines'] = ['editor.action.joinLines', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.transpose'] = ['editor.action.transpose', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.transformToUppercase'] = ['editor.action.transformToUppercase', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.transformToLowercase'] = ['editor.action.transformToLowercase', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.transformToTitlecase'] = ['editor.action.transformToTitlecase', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.smartSelect.expand'] = ['editor.action.smartSelect.expand', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.smartSelect.shrink'] = ['editor.action.smartSelect.shrink', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.forceRetokenize'] = ['editor.action.forceRetokenize', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.toggleTabFocusMode'] = ['editor.action.toggleTabFocusMode', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.gotoLine'] = ['editor.action.gotoLine', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.quickOutline'] = ['editor.action.quickOutline', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.inPlaceReplace.up'] = ['editor.action.inPlaceReplace.up', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.inPlaceReplace.down'] = ['editor.action.inPlaceReplace.down', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.diffReview.next'] = ['editor.action.diffReview.next', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.diffReview.prev'] = ['editor.action.diffReview.prev', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.selectToBracket'] = ['editor.action.selectToBracket', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.jumpToBracket'] = ['editor.action.jumpToBracket', CONVERT_VSCODE_TO_MONACO]; + mappings['actions.findWithSelection'] = ['actions.findWithSelection', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.nextMatchFindAction'] = ['editor.action.nextMatchFindAction', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.previousMatchFindAction'] = ['editor.action.previousMatchFindAction', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.nextSelectionMatchFindAction'] = ['editor.action.nextSelectionMatchFindAction', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.previousSelectionMatchFindAction'] = ['editor.action.previousSelectionMatchFindAction', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.openLink'] = ['editor.action.openLink', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.quickFix'] = ['editor.action.quickFix', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.refactor'] = ['editor.action.refactor', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.sourceAction'] = ['editor.action.sourceAction', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.organizeImports'] = ['editor.action.organizeImports', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.autoFix'] = ['editor.action.autoFix', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.fixAll'] = ['editor.action.fixAll', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.rename'] = ['editor.action.rename', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.insertCursorAbove'] = ['editor.action.insertCursorAbove', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.insertCursorBelow'] = ['editor.action.insertCursorBelow', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.insertCursorAtEndOfEachLineSelected'] = ['editor.action.insertCursorAtEndOfEachLineSelected', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.addSelectionToNextFindMatch'] = ['editor.action.addSelectionToNextFindMatch', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.addSelectionToPreviousFindMatch'] = ['editor.action.addSelectionToPreviousFindMatch', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.moveSelectionToNextFindMatch'] = ['editor.action.moveSelectionToNextFindMatch', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.moveSelectionToPreviousFindMatch'] = ['editor.action.moveSelectionToPreviousFindMatch', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.selectHighlights'] = ['editor.action.selectHighlights', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.changeAll'] = ['editor.action.changeAll', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.addCursorsToBottom'] = ['editor.action.addCursorsToBottom', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.addCursorsToTop'] = ['editor.action.addCursorsToTop', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.triggerParameterHints'] = ['editor.action.triggerParameterHints', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.wordHighlight.next'] = ['editor.action.wordHighlight.next', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.wordHighlight.prev'] = ['editor.action.wordHighlight.prev', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.wordHighlight.trigger'] = ['editor.action.wordHighlight.trigger', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.showAccessibilityHelp'] = ['editor.action.showAccessibilityHelp', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.inspectTokens'] = ['editor.action.inspectTokens', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.marker.next'] = ['editor.action.marker.next', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.marker.prev'] = ['editor.action.marker.prev', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.marker.nextInFiles'] = ['editor.action.marker.nextInFiles', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.marker.prevInFiles'] = ['editor.action.marker.prevInFiles', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.showHover'] = ['editor.action.showHover', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.revealDefinition'] = ['editor.action.revealDefinition', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.revealDefinitionAside'] = ['editor.action.revealDefinitionAside', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.peekDefinition'] = ['editor.action.peekDefinition', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.revealDeclaration'] = ['editor.action.revealDeclaration', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.peekDeclaration'] = ['editor.action.peekDeclaration', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.goToImplementation'] = ['editor.action.goToImplementation', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.peekImplementation'] = ['editor.action.peekImplementation', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.goToTypeDefinition'] = ['editor.action.goToTypeDefinition', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.peekTypeDefinition'] = ['editor.action.peekTypeDefinition', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.referenceSearch.trigger'] = ['editor.action.referenceSearch.trigger', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.triggerSuggest'] = ['editor.action.triggerSuggest', CONVERT_VSCODE_TO_MONACO]; + mappings['closeReferenceSearchEditor'] = ['closeReferenceSearchEditor', CONVERT_VSCODE_TO_MONACO]; + mappings['cancelSelection'] = ['cancelSelection', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorBottom'] = ['cursorBottom', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorBottomSelect'] = ['cursorBottomSelect', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorDown'] = ['cursorDown', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorDownSelect'] = ['cursorDownSelect', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorEnd'] = ['cursorEnd', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorEndSelect'] = ['cursorEndSelect', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorHome'] = ['cursorHome', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorHomeSelect'] = ['cursorHomeSelect', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorLeft'] = ['cursorLeft', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorLeftSelect'] = ['cursorLeftSelect', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorPageDown'] = ['cursorPageDown', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorPageDownSelect'] = ['cursorPageDownSelect', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorPageUp'] = ['cursorPageUp', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorPageUpSelect'] = ['cursorPageUpSelect', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorRight'] = ['cursorRight', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorRightSelect'] = ['cursorRightSelect', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorTop'] = ['cursorTop', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorTopSelect'] = ['cursorTopSelect', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorUp'] = ['cursorUp', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorUpSelect'] = ['cursorUpSelect', CONVERT_VSCODE_TO_MONACO]; + mappings['deleteLeft'] = ['deleteLeft', CONVERT_VSCODE_TO_MONACO]; + mappings['deleteRight'] = ['deleteRight', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.selectAll'] = ['editor.action.selectAll', CONVERT_VSCODE_TO_MONACO]; + mappings['expandLineSelection'] = ['expandLineSelection', CONVERT_VSCODE_TO_MONACO]; + mappings['outdent'] = ['outdent', CONVERT_VSCODE_TO_MONACO]; + mappings['scrollLineDown'] = ['scrollLineDown', CONVERT_VSCODE_TO_MONACO]; + mappings['scrollLineUp'] = ['scrollLineUp', CONVERT_VSCODE_TO_MONACO]; + mappings['scrollPageDown'] = ['scrollPageDown', CONVERT_VSCODE_TO_MONACO]; + mappings['scrollPageUp'] = ['scrollPageUp', CONVERT_VSCODE_TO_MONACO]; + mappings['tab'] = ['tab', CONVERT_VSCODE_TO_MONACO]; + mappings['removeSecondaryCursors'] = ['removeSecondaryCursors', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorWordRight'] = ['cursorWordEndRight', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorWordEndRight'] = ['cursorWordEndRight', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorWordEndRightSelect'] = ['cursorWordEndRightSelect', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorWordLeft'] = ['cursorWordStartLeft', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorWordStartLeft'] = ['cursorWordStartLeft', CONVERT_VSCODE_TO_MONACO]; + mappings['cursorWordStartLeftSelect'] = ['cursorWordStartLeftSelect', CONVERT_VSCODE_TO_MONACO]; + mappings['deleteWordLeft'] = ['deleteWordLeft', CONVERT_VSCODE_TO_MONACO]; + mappings['deleteWordRight'] = ['deleteWordRight', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.cancelOperation'] = ['editor.cancelOperation', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.gotoNextSymbolFromResult'] = ['editor.gotoNextSymbolFromResult', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.gotoNextSymbolFromResult.cancel'] = ['editor.gotoNextSymbolFromResult.cancel', CONVERT_VSCODE_TO_MONACO]; + mappings['openReferenceToSide'] = ['openReferenceToSide', CONVERT_VSCODE_TO_MONACO]; + mappings['toggleExplainMode'] = ['toggleExplainMode', CONVERT_VSCODE_TO_MONACO]; + mappings['closeFindWidget'] = ['closeFindWidget', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.replaceAll'] = ['editor.action.replaceAll', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.replaceOne'] = ['editor.action.replaceOne', CONVERT_VSCODE_TO_MONACO]; + mappings['editor.action.selectAllMatches'] = ['editor.action.selectAllMatches', CONVERT_VSCODE_TO_MONACO]; + mappings['toggleFindCaseSensitive'] = ['toggleFindCaseSensitive', CONVERT_VSCODE_TO_MONACO]; + mappings['toggleFindInSelection'] = ['toggleFindInSelection', CONVERT_VSCODE_TO_MONACO]; + mappings['toggleFindRegex'] = ['toggleFindRegex', CONVERT_VSCODE_TO_MONACO]; + mappings['toggleFindWholeWord'] = ['toggleFindWholeWord', CONVERT_VSCODE_TO_MONACO]; + mappings['jumpToNextSnippetPlaceholder'] = ['jumpToNextSnippetPlaceholder', CONVERT_VSCODE_TO_MONACO]; + mappings['jumpToPrevSnippetPlaceholder'] = ['jumpToPrevSnippetPlaceholder', CONVERT_VSCODE_TO_MONACO]; + mappings['leaveEditorMessage'] = ['leaveEditorMessage', CONVERT_VSCODE_TO_MONACO]; + mappings['leaveSnippet'] = ['leaveSnippet', CONVERT_VSCODE_TO_MONACO]; + mappings['closeMarkersNavigation'] = ['closeMarkersNavigation', CONVERT_VSCODE_TO_MONACO]; + mappings['goToNextReferenceFromEmbeddedEditor'] = ['goToNextReferenceFromEmbeddedEditor', CONVERT_VSCODE_TO_MONACO]; + mappings['goToPreviousReferenceFromEmbeddedEditor'] = ['goToPreviousReferenceFromEmbeddedEditor', CONVERT_VSCODE_TO_MONACO]; + mappings['closeParameterHints'] = ['closeParameterHints', CONVERT_VSCODE_TO_MONACO]; + mappings['showNextParameterHint'] = ['showNextParameterHint', CONVERT_VSCODE_TO_MONACO]; + mappings['showPrevParameterHint'] = ['showPrevParameterHint', CONVERT_VSCODE_TO_MONACO]; + mappings['acceptSelectedSuggestion'] = ['acceptSelectedSuggestion', CONVERT_VSCODE_TO_MONACO]; + mappings['acceptSelectedSuggestionOnEnter'] = ['acceptSelectedSuggestionOnEnter', CONVERT_VSCODE_TO_MONACO]; + mappings['hideSuggestWidget'] = ['hideSuggestWidget', CONVERT_VSCODE_TO_MONACO]; + mappings['insertBestCompletion'] = ['insertBestCompletion', CONVERT_VSCODE_TO_MONACO]; + mappings['insertNextSuggestion'] = ['insertNextSuggestion', CONVERT_VSCODE_TO_MONACO]; + mappings['insertPrevSuggestion'] = ['insertPrevSuggestion', CONVERT_VSCODE_TO_MONACO]; + mappings['selectNextPageSuggestion'] = ['selectNextPageSuggestion', CONVERT_VSCODE_TO_MONACO]; + mappings['selectNextSuggestion'] = ['selectNextSuggestion', CONVERT_VSCODE_TO_MONACO]; + mappings['selectPrevPageSuggestion'] = ['selectPrevPageSuggestion', CONVERT_VSCODE_TO_MONACO]; + mappings['selectPrevSuggestion'] = ['selectPrevSuggestion', CONVERT_VSCODE_TO_MONACO]; + mappings['toggleSuggestionDetails'] = ['toggleSuggestionDetails', CONVERT_VSCODE_TO_MONACO]; + mappings['toggleSuggestionFocus'] = ['toggleSuggestionFocus', CONVERT_VSCODE_TO_MONACO]; + mappings['acceptRenameInput'] = ['acceptRenameInput', CONVERT_VSCODE_TO_MONACO]; + mappings['cancelRenameInput'] = ['cancelRenameInput', CONVERT_VSCODE_TO_MONACO]; + mappings['closeAccessibilityHelp'] = ['closeAccessibilityHelp', CONVERT_VSCODE_TO_MONACO]; + mappings['history.showNext'] = ['history.showNext', CONVERT_VSCODE_TO_MONACO]; + mappings['history.showPrevious'] = ['history.showPrevious', CONVERT_VSCODE_TO_MONACO]; + mappings['closeReferenceSearch'] = ['closeReferenceSearch', CONVERT_VSCODE_TO_MONACO]; + mappings['goToNextReference'] = ['goToNextReference', CONVERT_VSCODE_TO_MONACO]; + mappings['goToPreviousReference'] = ['goToPreviousReference', CONVERT_VSCODE_TO_MONACO]; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const CONVERT_MONACO_TO_VSCODE = (args: any | undefined) => { + if (!args) { + return args; + } + if (!Array.isArray(args)) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return monacoToVscodeArgsConverter(args); + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const argsArray: any[] = args; + const argStack: ConversionFunction[] = []; + argsArray.forEach(_ => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + argStack.push((arg: any) => monacoToVscodeArgsConverter(arg)); + }); + if (argsArray) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return createConversionFunction(...argStack)(argsArray); + } + }; + + // 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.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]; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + export function map(id: string, args: any[] | undefined, toDo: (mappedId: string, mappedArgs: any[] | undefined, mappedResult: ConversionFunction | undefined) => T): T { + if (mappings[id]) { + return toDo(mappings[id][0], mappings[id][1](args), mappings[id][2] ? (result => mappings[id][2]!(result)) : undefined); + } else { + return toDo(id, args, undefined); + } + } + + export function mapped(id: string): boolean { + return !!mappings[id]; + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + export type ConversionFunction = ((parameter: any) => any) | undefined; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function createConversionFunction(...conversions: ConversionFunction[]): (args: any[] | undefined) => any[] | undefined { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return function (args: any[] | undefined): any[] | undefined { + if (!args) { + return args; + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return args.map(function (arg: any, index: number): any { + if (index < conversions.length) { + const conversion = conversions[index]; + if (conversion) { + return conversion(arg); + } + } + return arg; + }); + }; + } + + function fromPositionToP(p: theia.Position): P { + return P.create(p.line, p.character); + } + + function fromRangeToR(r: theia.Range): R { + return R.create(fromPositionToP(r.start), fromPositionToP(r.end)); + } + + function fromLocationToL(l: theia.Location): L { + return L.create(l.uri.toString(), fromRangeToR(l.range)); + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/tslint/config + function vscodeToMonacoArgsConverter(args: any[]) { + // tslint:disable-next-line:typedef + return cloneAndChange(args, function (value) { + if (Position.isPosition(value)) { + return fromPosition(value); + } + if (Range.isRange(value)) { + return fromRange(value); + } + if (Location.isLocation(value)) { + return fromLocation(value); + } + if (CallHierarchyItem.isCallHierarchyItem(value)) { + return fromCallHierarchyItem(value); + } + if (!Array.isArray(value)) { + return value; + } + }); + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/tslint/config + function monacoToVscodeArgsConverter(args: any[]) { + // tslint:disable-next-line:typedef + return cloneAndChange(args, function (value) { + if (isModelLocation(value)) { + return toLocation(value); + } + if (isModelCallHierarchyItem(value)) { + return toCallHierarchyItem(value); + } + if (isModelCallHierarchyIncomingCall(value)) { + return toCallHierarchyIncomingCall(value); + } + if (isModelCallHierarchyOutgoingCall(value)) { + return toCallHierarchyOutgoingCall(value); + } + if (!Array.isArray(value)) { + return value; + } + + }); + } +} + +function toArrayConversion(f: (a: T) => U): (a: T[]) => U[] { + // tslint:disable-next-line:typedef + return function (a: T[]) { + return a.map(f); + }; +} diff --git a/packages/plugin-ext/src/plugin/tree/tree-views.ts b/packages/plugin-ext/src/plugin/tree/tree-views.ts index 84cb45a238e69..c74c8cc152a1d 100644 --- a/packages/plugin-ext/src/plugin/tree/tree-views.ts +++ b/packages/plugin-ext/src/plugin/tree/tree-views.ts @@ -88,6 +88,18 @@ export class TreeViewsExtImpl implements TreeViewsExt { get onDidChangeVisibility() { return treeView.onDidChangeVisibility; }, + get message(): string { + return treeView.message; + }, + set message(message: string) { + treeView.message = message; + }, + get title(): string { + return treeView.title; + }, + set title(title: string) { + treeView.title = title; + }, // tslint:enable:typedef reveal: (element: T, selectionOptions: { select?: boolean }): Thenable => treeView.reveal(element, selectionOptions), @@ -204,6 +216,26 @@ class TreeViewExtImpl implements Disposable { } } + private _message: string = ''; + get message(): string { + return this._message; + } + + set message(message: string) { + this._message = message; + this.proxy.$setMessage(this.treeViewId, this._message); + } + + private _title: string = ''; + get title(): string { + return this._title; + } + + set title(title: string) { + this._title = title; + this.proxy.$setTitle(this.treeViewId, title); + } + getTreeItem(treeItemId: string): T | undefined { const element = this.nodes.get(treeItemId); return element && element.value; diff --git a/packages/plugin-ext/src/plugin/type-converters.ts b/packages/plugin-ext/src/plugin/type-converters.ts index 9d4203e68012f..2ef3ce37018c2 100644 --- a/packages/plugin-ext/src/plugin/type-converters.ts +++ b/packages/plugin-ext/src/plugin/type-converters.ts @@ -27,6 +27,7 @@ import { LanguageFilter, LanguageSelector, RelativePattern } from '@theia/langua import { isMarkdownString, MarkdownString } from './markdown-string'; import { Item } from './quick-open'; import * as types from './types-impl'; +import { UriComponents } from '../common/uri-components'; const SIDE_GROUP = -2; const ACTIVE_GROUP = -1; @@ -585,6 +586,98 @@ export function toDocumentSymbol(symbol: model.DocumentSymbol): theia.DocumentSy }; } +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function isModelLocation(thing: any): thing is model.Location { + if (!thing) { + return false; + } + return isModelRange((thing).range) && + isUriComponents((thing).uri); +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function isModelRange(thing: any): thing is model.Range { + if (!thing) { + return false; + } + return (('startLineNumber' in thing) && typeof thing.startLineNumber === 'number') && + (('startColumn' in thing) && typeof thing.startColumn === 'number') && + (('endLineNumber' in thing) && typeof thing.endLineNumber === 'number') && + (('endColumn' in thing) && typeof thing.endColumn === 'number'); +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function isUriComponents(thing: any): thing is UriComponents { + if (!thing) { + return false; + } + return (('scheme' in thing) && typeof thing.scheme === 'string') && + (('path' in thing) && typeof thing.path === 'string') && + (('query' in thing) && typeof thing.query === 'string') && + (('fragment' in thing) && typeof thing.fragment === 'string'); +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function isModelCallHierarchyItem(thing: any): thing is model.CallHierarchyItem { + if (!thing) { + return false; + } + return false; +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function isModelCallHierarchyIncomingCall(thing: any): thing is model.CallHierarchyIncomingCall { + if (!thing) { + return false; + } + return false; +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function isModelCallHierarchyOutgoingCall(thing: any): thing is model.CallHierarchyOutgoingCall { + if (!thing) { + return false; + } + return false; +} + +export function toLocation(value: model.Location): types.Location { + return new types.Location(URI.revive(value.uri), toRange(value.range)); +} + +export function fromCallHierarchyItem(item: theia.CallHierarchyItem): model.CallHierarchyItem { + return { + kind: SymbolKind.fromSymbolKind(item.kind), + name: item.name, + detail: item.detail, + uri: item.uri, + range: fromRange(item.range), + selectionRange: fromRange(item.selectionRange) + }; +} + +export function toCallHierarchyItem(value: model.CallHierarchyItem): types.CallHierarchyItem { + return new types.CallHierarchyItem( + SymbolKind.toSymbolKind(value.kind), + value.name, + value.detail ? value.detail : '', + URI.revive(value.uri), + toRange(value.range), + toRange(value.selectionRange)); +} + +export function toCallHierarchyIncomingCall(value: model.CallHierarchyIncomingCall): types.CallHierarchyIncomingCall { + return new types.CallHierarchyIncomingCall( + toCallHierarchyItem(value.from), + value.fromRanges && value.fromRanges.map(toRange)); +} + +export function toCallHierarchyOutgoingCall(value: model.CallHierarchyOutgoingCall): types.CallHierarchyOutgoingCall { + return new types.CallHierarchyOutgoingCall( + toCallHierarchyItem(value.to), + value.fromRanges && value.fromRanges.map(toRange)); +} + export function toWorkspaceFolder(folder: model.WorkspaceFolder): theia.WorkspaceFolder { return { uri: URI.revive(folder.uri), diff --git a/packages/plugin-ext/src/plugin/types-impl.ts b/packages/plugin-ext/src/plugin/types-impl.ts index b194c6b86021a..5fac26747c0d6 100644 --- a/packages/plugin-ext/src/plugin/types-impl.ts +++ b/packages/plugin-ext/src/plugin/types-impl.ts @@ -2012,6 +2012,9 @@ export enum WebviewPanelTargetArea { Bottom = 'bottom' } export class CallHierarchyItem { + _sessionId?: string; + _itemId?: string; + kind: SymbolKind; name: string; detail?: string; @@ -2027,6 +2030,20 @@ export class CallHierarchyItem { this.range = range; this.selectionRange = selectionRange; } + + static isCallHierarchyItem(thing: {}): thing is theia.CallHierarchyItem { + if (thing instanceof CallHierarchyItem) { + return true; + } + if (!thing) { + return false; + } + return typeof (thing).kind === 'number' && + typeof (thing).name === 'string' && + URI.isUri((thing).uri) && + Range.isRange((thing).range) && + Range.isRange((thing).selectionRange); + } } export class CallHierarchyIncomingCall { @@ -2039,6 +2056,7 @@ export class CallHierarchyIncomingCall { this.from = item; } } + export class CallHierarchyOutgoingCall { to: theia.CallHierarchyItem; diff --git a/packages/plugin/src/theia.d.ts b/packages/plugin/src/theia.d.ts index ac60cf43f6172..42c0f524b2c4b 100644 --- a/packages/plugin/src/theia.d.ts +++ b/packages/plugin/src/theia.d.ts @@ -3903,6 +3903,18 @@ declare module '@theia/plugin' { */ readonly onDidChangeVisibility: Event; + /** + * An optional human-readable message that will be rendered in the view. + * Setting the message to null, undefined, or empty string will remove the message from the view. + */ + message?: string; + + /** + * The tree view title is initially taken from the extension package.json + * Changes to the title property will be properly reflected in the UI in the title of the view. + */ + title?: string; + /** * Reveal an element. By default revealed element is selected. *