提交 966100d9 编写于 作者: J Johannes Rieken

Only accept WorkspaceEdit, #34664

上级 eb1f87c4
......@@ -106,7 +106,7 @@ export default class TypeScriptQuickFixProvider implements vscode.CodeActionProv
private getCommandForAction(action: Proto.CodeAction): vscode.CodeAction {
return {
title: action.description,
edits: getEditForCodeAction(this.client, action),
edit: getEditForCodeAction(this.client, action),
command: action.commands ? {
command: ApplyCodeActionCommand.ID,
arguments: [action],
......@@ -115,4 +115,4 @@ export default class TypeScriptQuickFixProvider implements vscode.CodeActionProv
diagnostics: []
};
}
}
\ No newline at end of file
}
......@@ -210,11 +210,11 @@ declare module 'vscode' {
title: string;
/**
* Optional edit that performs the code action.
* A workspace edit this code action performs.
*
* Either `command` or `edits` must be provided for a `CodeAction`.
* *Note* that either an [`edit`](CodeAction#edit) or a [`command`](CodeAction#command) must be supplied.
*/
edits?: TextEdit[] | WorkspaceEdit;
edit?: WorkspaceEdit;
/**
* Diagnostics that this code action resolves.
......@@ -222,9 +222,9 @@ declare module 'vscode' {
diagnostics?: Diagnostic[];
/**
* Optional command that performs the code action.
* A command this code action performs.
*
* Executed after `edits` if any edits are provided. Either `command` or `edits` must be provided for a `CodeAction`.
* *Note* that either an [`edit`](CodeAction#edit) or a [`command`](CodeAction#command) must be supplied.
*/
command?: Command;
......@@ -237,7 +237,7 @@ declare module 'vscode' {
* @param title The title of the code action.
* @param edits The edit of the code action.
*/
constructor(title: string, edits?: TextEdit[] | WorkspaceEdit);
constructor(title: string, edit?: WorkspaceEdit);
}
export interface CodeActionProvider {
......
......@@ -314,9 +314,7 @@ class CodeActionAdapter {
title: candidate.title,
command: candidate.command && this._commands.toInternal(candidate.command),
diagnostics: candidate.diagnostics && candidate.diagnostics.map(DiagnosticCollection.toMarkerData),
edits: Array.isArray(candidate.edits)
? TypeConverters.WorkspaceEdit.fromTextEdits(resource, candidate.edits)
: candidate.edits && TypeConverters.WorkspaceEdit.from(candidate.edits),
edits: candidate.edit && TypeConverters.WorkspaceEdit.from(candidate.edit),
});
}
}
......
......@@ -241,18 +241,6 @@ export namespace WorkspaceEdit {
return result;
}
export function fromTextEdits(uri: vscode.Uri, textEdits: vscode.TextEdit[]): modes.WorkspaceEdit {
const result: modes.WorkspaceEdit = { edits: [] };
for (let textEdit of textEdits) {
result.edits.push({
resource: uri,
newText: textEdit.newText,
range: fromRange(textEdit.range)
});
}
return result;
}
export function to(value: modes.WorkspaceEdit) {
const result = new types.WorkspaceEdit();
for (const edit of value.edits) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册