Skip to content

Commit ee50f58

Browse files
committed
Constify
And other minor formatting changes
1 parent db6023f commit ee50f58

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/features/codeActionProvider.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,25 @@ import { LanguageMiddlewareFeature } from '../omnisharp/LanguageMiddlewareFeatur
1414
import { buildEditForResponse } from '../omnisharp/fileOperationsResponseEditBuilder';
1515

1616
export default class CodeActionProvider extends AbstractProvider implements vscode.CodeActionProvider {
17-
1817
private _commandId: string;
1918

2019
constructor(server: OmniSharpServer, private optionProvider: OptionProvider, languageMiddlewareFeature: LanguageMiddlewareFeature) {
2120
super(server, languageMiddlewareFeature);
2221
this._commandId = 'omnisharp.runCodeAction';
23-
let registerCommandDisposable = vscode.commands.registerCommand(this._commandId, this._runCodeAction, this);
22+
const registerCommandDisposable = vscode.commands.registerCommand(this._commandId, this._runCodeAction, this);
2423
this.addDisposables(new CompositeDisposable(registerCommandDisposable));
2524
}
2625

2726
public async provideCodeActions(document: vscode.TextDocument, range: vscode.Range | vscode.Selection, context: vscode.CodeActionContext, token: vscode.CancellationToken): Promise<vscode.CodeAction[]> {
28-
let options = this.optionProvider.GetLatestOptions();
27+
const options = this.optionProvider.GetLatestOptions();
2928
if (options.disableCodeActions) {
3029
return;
3130
}
3231

33-
let line = range.start.line;
34-
let column = range.start.character;
32+
const line = range.start.line;
33+
const column = range.start.character;
3534

36-
let request: protocol.V2.GetCodeActionsRequest = {
35+
const request: protocol.V2.GetCodeActionsRequest = {
3736
FileName: document.fileName,
3837
Line: line,
3938
Column: column,
@@ -51,9 +50,9 @@ export default class CodeActionProvider extends AbstractProvider implements vsco
5150
}
5251

5352
try {
54-
let response = await serverUtils.getCodeActions(this._server, request, token);
53+
const response = await serverUtils.getCodeActions(this._server, request, token);
5554
return response.CodeActions.map(codeAction => {
56-
let runRequest: protocol.V2.RunCodeActionRequest = {
55+
const runRequest: protocol.V2.RunCodeActionRequest = {
5756
...request,
5857
Identifier: codeAction.Identifier,
5958
WantsTextChanges: true,
@@ -70,20 +69,19 @@ export default class CodeActionProvider extends AbstractProvider implements vsco
7069
},
7170
};
7271
});
73-
}
74-
catch (error) {
72+
} catch (error) {
7573
return Promise.reject(`Problem invoking 'GetCodeActions' on OmniSharp server: ${error}`);
7674
}
7775
}
7876

7977
private async _runCodeAction(req: protocol.V2.RunCodeActionRequest, token: vscode.CancellationToken): Promise<boolean | string | {}> {
80-
81-
return serverUtils.runCodeAction(this._server, req).then(async response => {
78+
try {
79+
const response = await serverUtils.runCodeAction(this._server, req);
8280
if (response) {
8381
return buildEditForResponse(response.Changes, this._languageMiddlewareFeature, token);
8482
}
85-
}, async (error) => {
83+
} catch (error) {
8684
return Promise.reject(`Problem invoking 'RunCodeAction' on OmniSharp server: ${error}`);
87-
});
85+
}
8886
}
8987
}

0 commit comments

Comments
 (0)