Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 3 more vscode command implementations #14093

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading