1
1
2
2
import * as vscode from 'vscode' ;
3
- import { isTypeScriptDocument , isEnabledForJavaScriptDocument } from './utils' ;
3
+ import { isEnabledForJavaScriptDocument , isTypeScriptDocument } from './utils' ;
4
4
5
5
function executeCodeActionProvider ( uri : vscode . Uri , range : vscode . Range ) {
6
6
return vscode . commands . executeCommand < vscode . CodeAction [ ] > ( 'vscode.executeCodeActionProvider' , uri , range ) ;
7
7
}
8
8
9
-
10
9
async function getTsLintFixAllCodeAction ( document : vscode . TextDocument ) : Promise < vscode . CodeAction | undefined > {
11
10
const diagnostics = vscode . languages
12
11
. getDiagnostics ( document . uri )
13
- . filter ( diagnostic => diagnostic . source === 'tslint' ) ;
12
+ . filter ( ( diagnostic ) => diagnostic . source === 'tslint' ) ;
14
13
15
14
for ( const diagnostic of diagnostics ) {
16
15
const codeActions = await executeCodeActionProvider ( document . uri , diagnostic . range ) ;
17
16
if ( codeActions ) {
18
- const fixAll = codeActions . filter ( action => action . title === 'Fix all auto-fixable tslint failures' ) ;
17
+ const fixAll = codeActions . filter ( ( action ) => action . title === 'Fix all auto-fixable tslint failures' ) ;
19
18
if ( fixAll . length > 0 ) {
20
19
return fixAll [ 0 ] ;
21
20
}
@@ -24,19 +23,18 @@ async function getTsLintFixAllCodeAction(document: vscode.TextDocument): Promise
24
23
return undefined ;
25
24
}
26
25
27
-
28
26
const fixAllCodeActionKind = vscode . CodeActionKind . SourceFixAll . append ( 'tslint' ) ;
29
27
30
28
export class FixAllProvider implements vscode . CodeActionProvider {
31
29
public static metadata : vscode . CodeActionProviderMetadata = {
32
30
providedCodeActionKinds : [ fixAllCodeActionKind ] ,
33
31
} ;
34
32
35
- async provideCodeActions (
33
+ public async provideCodeActions (
36
34
document : vscode . TextDocument ,
37
35
_range : vscode . Range | vscode . Selection ,
38
36
context : vscode . CodeActionContext ,
39
- _token : vscode . CancellationToken
37
+ _token : vscode . CancellationToken ,
40
38
) : Promise < vscode . CodeAction [ ] > {
41
39
if ( ! context . only ) {
42
40
return [ ] ;
0 commit comments