Skip to content

Commit

Permalink
Add 3 vscode command implementations (#14093)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonah-iden authored Aug 29, 2024
1 parent ed84a10 commit 82b4ae2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ import * as monaco from '@theia/monaco-editor-core';
import { VSCodeExtensionUri } from '../common/plugin-vscode-uri';
import { CodeEditorWidgetUtil } from '@theia/plugin-ext/lib/main/browser/menus/vscode-theia-menu-mappings';
import { OutlineViewContribution } from '@theia/outline-view/lib/browser/outline-view-contribution';
import { Range } from '@theia/plugin';
import { MonacoLanguages } from '@theia/monaco/lib/browser/monaco-languages';

export namespace VscodeCommands {

Expand Down Expand Up @@ -189,6 +191,8 @@ export class PluginVscodeCommandsContribution implements CommandContribution {
protected readonly messageService: MessageService;
@inject(OutlineViewContribution)
protected outlineViewContribution: OutlineViewContribution;
@inject(MonacoLanguages)
protected monacoLanguages: MonacoLanguages;

private async openWith(commandId: string, resource: URI, columnOrOptions?: ViewColumn | TextDocumentShowOptions, openerId?: string): Promise<boolean> {
if (!resource) {
Expand Down Expand Up @@ -655,6 +659,38 @@ export class PluginVscodeCommandsContribution implements CommandContribution {
commands.executeCommand<TextEdit[]>('_executeFormatOnTypeProvider', monaco.Uri.from(resource), position, ch, options))
}
);
commands.registerCommand(
{
id: 'vscode.executeFoldingRangeProvider'
},
{
execute: ((resource: URI, position: Position) =>
commands.executeCommand<TextEdit[]>('_executeFoldingRangeProvider', monaco.Uri.from(resource), position))
}
);
commands.registerCommand(
{
id: 'vscode.executeCodeActionProvider'
},
{
execute: ((resource: URI, range: Range, kind?: string, itemResolveCount?: number) =>
commands.executeCommand<TextEdit[]>('_executeCodeActionProvider', monaco.Uri.from(resource), range, kind, itemResolveCount))
}
);
commands.registerCommand(
{
id: 'vscode.executeWorkspaceSymbolProvider'
},
{
execute: async (queryString: string) =>
(await Promise.all(
this.monacoLanguages.workspaceSymbolProviders
.map(async provider => provider.provideWorkspaceSymbols({ query: queryString }, new CancellationTokenSource().token))))
.flatMap(symbols => symbols)
.filter(symbols => !!symbols)
}
);

commands.registerCommand(
{
id: 'vscode.prepareCallHierarchy'
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-ext/src/plugin/known-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ export namespace KnownCommands {
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.executeCodeActionProvider'] = ['vscode.executeCodeActionProvider', 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];
Expand Down

0 comments on commit 82b4ae2

Please sign in to comment.