@@ -14,26 +14,25 @@ import { LanguageMiddlewareFeature } from '../omnisharp/LanguageMiddlewareFeatur
14
14
import { buildEditForResponse } from '../omnisharp/fileOperationsResponseEditBuilder' ;
15
15
16
16
export default class CodeActionProvider extends AbstractProvider implements vscode . CodeActionProvider {
17
-
18
17
private _commandId : string ;
19
18
20
19
constructor ( server : OmniSharpServer , private optionProvider : OptionProvider , languageMiddlewareFeature : LanguageMiddlewareFeature ) {
21
20
super ( server , languageMiddlewareFeature ) ;
22
21
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 ) ;
24
23
this . addDisposables ( new CompositeDisposable ( registerCommandDisposable ) ) ;
25
24
}
26
25
27
26
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 ( ) ;
29
28
if ( options . disableCodeActions ) {
30
29
return ;
31
30
}
32
31
33
- let line = range . start . line ;
34
- let column = range . start . character ;
32
+ const line = range . start . line ;
33
+ const column = range . start . character ;
35
34
36
- let request : protocol . V2 . GetCodeActionsRequest = {
35
+ const request : protocol . V2 . GetCodeActionsRequest = {
37
36
FileName : document . fileName ,
38
37
Line : line ,
39
38
Column : column ,
@@ -51,9 +50,9 @@ export default class CodeActionProvider extends AbstractProvider implements vsco
51
50
}
52
51
53
52
try {
54
- let response = await serverUtils . getCodeActions ( this . _server , request , token ) ;
53
+ const response = await serverUtils . getCodeActions ( this . _server , request , token ) ;
55
54
return response . CodeActions . map ( codeAction => {
56
- let runRequest : protocol . V2 . RunCodeActionRequest = {
55
+ const runRequest : protocol . V2 . RunCodeActionRequest = {
57
56
...request ,
58
57
Identifier : codeAction . Identifier ,
59
58
WantsTextChanges : true ,
@@ -70,20 +69,19 @@ export default class CodeActionProvider extends AbstractProvider implements vsco
70
69
} ,
71
70
} ;
72
71
} ) ;
73
- }
74
- catch ( error ) {
72
+ } catch ( error ) {
75
73
return Promise . reject ( `Problem invoking 'GetCodeActions' on OmniSharp server: ${ error } ` ) ;
76
74
}
77
75
}
78
76
79
77
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 ) ;
82
80
if ( response ) {
83
81
return buildEditForResponse ( response . Changes , this . _languageMiddlewareFeature , token ) ;
84
82
}
85
- } , async ( error ) => {
83
+ } catch ( error ) {
86
84
return Promise . reject ( `Problem invoking 'RunCodeAction' on OmniSharp server: ${ error } ` ) ;
87
- } ) ;
85
+ }
88
86
}
89
87
}
0 commit comments