Skip to content

Commit

Permalink
Provide CodeActionKind for code actions
Browse files Browse the repository at this point in the history
  • Loading branch information
333fred committed Aug 11, 2022
1 parent a675b5f commit 64ba64d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/features/codeActionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default class CodeActionProvider extends AbstractProvider implements vsco

return {
title: codeAction.Name,
kind: this.mapOmniSharpCodeActionKindToVSCodeCodeActionKind(codeAction.CodeActionKind),
command: {
title: codeAction.Name,
command: this._commandId,
Expand All @@ -74,6 +75,21 @@ export default class CodeActionProvider extends AbstractProvider implements vsco
}
}

private mapOmniSharpCodeActionKindToVSCodeCodeActionKind(kind: string): vscode.CodeActionKind {
switch (kind) {
case 'QuickFix':
return vscode.CodeActionKind.QuickFix;
case 'Refactor':
return vscode.CodeActionKind.Refactor;
case 'RefactorExtract':
return vscode.CodeActionKind.RefactorExtract;
case 'RefactorInline':
return vscode.CodeActionKind.RefactorInline;
default:
return vscode.CodeActionKind.Empty;
}
}

private async _runCodeAction(req: protocol.V2.RunCodeActionRequest, token: vscode.CancellationToken): Promise<boolean | string | {}> {
try {
const response = await serverUtils.runCodeAction(this._server, req);
Expand Down
1 change: 1 addition & 0 deletions src/omnisharp/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ export namespace V2 {
export interface OmniSharpCodeAction {
Identifier: string;
Name: string;
CodeActionKind?: string;
}

export interface GetCodeActionsResponse {
Expand Down

0 comments on commit 64ba64d

Please sign in to comment.