Skip to content

Commit

Permalink
Implemented more vscode.executeXXX commands
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Pinkney <[email protected]>
  • Loading branch information
JPinkney committed Apr 15, 2020
1 parent e2dfc1a commit f691918
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 14 deletions.
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 @@ -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<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 @@ -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<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

0 comments on commit f691918

Please sign in to comment.