提交 597e6dc4 编写于 作者: M Matt Bierner

Take optional kind for `vscode.executeCodeActionProvider` command

This is required as some code actions providers will not return results unless code actions of a specific kind are requested
上级 36932d8b
......@@ -83,7 +83,7 @@ function codeActionsComparator(a: CodeAction, b: CodeAction): number {
}
registerLanguageCommand('_executeCodeActionProvider', function (accessor, args) {
const { resource, range } = args;
const { resource, range, kind } = args;
if (!(resource instanceof URI) || !Range.isIRange(range)) {
throw illegalArgument();
}
......@@ -96,6 +96,6 @@ registerLanguageCommand('_executeCodeActionProvider', function (accessor, args)
return getCodeActions(
model,
model.validateRange(range),
{ type: 'manual', filter: { includeSourceActions: true } },
{ type: 'manual', filter: { includeSourceActions: true, kind: kind ? new CodeActionKind(kind) : undefined } },
CancellationToken.None);
});
......@@ -134,7 +134,8 @@ export class ExtHostApiCommands {
description: 'Execute code action provider.',
args: [
{ name: 'uri', description: 'Uri of a text document', constraint: URI },
{ name: 'range', description: 'Range in a text document', constraint: types.Range }
{ name: 'range', description: 'Range in a text document', constraint: types.Range },
{ name: 'kind', description: '(optional) Code action kind to return code actions for', },
],
returns: 'A promise that resolves to an array of Command-instances.'
});
......@@ -478,10 +479,11 @@ export class ExtHostApiCommands {
});
}
private _executeCodeActionProvider(resource: URI, range: types.Range): Promise<(vscode.CodeAction | vscode.Command)[] | undefined> {
private _executeCodeActionProvider(resource: URI, range: types.Range, kind?: string): Promise<(vscode.CodeAction | vscode.Command)[] | undefined> {
const args = {
resource,
range: typeConverters.Range.from(range)
range: typeConverters.Range.from(range),
kind
};
return this._commands.executeCommand<CustomCodeAction[]>('_executeCodeActionProvider', args)
.then(tryMapWith(codeAction => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册