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

Implemented more vscode.executeXXX commands #7563

Merged
merged 1 commit into from
Apr 15, 2020
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
143 changes: 131 additions & 12 deletions packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<Location[]>('_executeDefinitionProvider', args);
})
}
);
commands.registerCommand(
{
id: 'vscode.executeDeclarationProvider'
},
{
execute: ((resource: URI, position: Position) => {
const args = {
resource: monaco.Uri.from(resource),
position: position
};
return commands.executeCommand<Location[]>('_executeDeclarationProvider', args);
})
}
);
commands.registerCommand(
{
id: 'vscode.executeTypeDefinitionProvider'
},
{
execute: ((resource: URI, position: Position) => {
const args = {
resource: monaco.Uri.from(resource),
position: position
};
return commands.executeCommand<Location[]>('_executeTypeDefinitionProvider', args);
})
}
);
commands.registerCommand(
{
id: 'vscode.executeImplementationProvider'
},
{
execute: ((resource: URI, position: Position) => {
const args = {
resource: monaco.Uri.from(resource),
position: position
};
return commands.executeCommand<Location[]>('_executeImplementationProvider', args);
})
}
);
commands.registerCommand(
{
id: 'vscode.executeHoverProvider'
},
{
execute: ((resource: URI, position: Position) => {
const args = {
resource: monaco.Uri.from(resource),
position: position
};
return commands.executeCommand<Hover[]>('_executeHoverProvider', args);
})
}
);
commands.registerCommand(
{
id: 'vscode.executeDocumentHighlights'
},
{
execute: ((resource: URI, position: Position) => {
const args = {
resource: monaco.Uri.from(resource),
position: position
};
return commands.executeCommand<DocumentHighlight[]>('_executeDocumentHighlights', args);
})
}
);
commands.registerCommand(
{
id: 'vscode.executeReferenceProvider'
},
{
execute: ((resource: URI, position: Position) => {
const args = {
resource: monaco.Uri.from(resource),
position: position
};
return commands.executeCommand<Location[]>('_executeReferenceProvider', args);
})
}
);
commands.registerCommand(
{
id: 'vscode.executeDocumentSymbolProvider'
Expand All @@ -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<Location[]>('_executeReferenceProvider', args);
return commands.executeCommand<TextEdit[]>('_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<Location[]>('_executeImplementationProvider', args);
return commands.executeCommand<TextEdit[]>('_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<TextEdit[]>('_executeFormatOnTypeProvider', args);
})
}
);
Expand Down
10 changes: 8 additions & 2 deletions packages/plugin-ext/src/plugin/known-commands.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down