@@ -3,10 +3,10 @@ import * as vscode from 'vscode';
33
44export class BazelTaskProvider implements vscode . TaskProvider {
55
6- static BazelType = 'bazel' ;
7- private bazelPromise : Thenable < vscode . Task [ ] > | undefined = undefined ;
6+ static BazelType = 'bazel' ;
7+ private bazelPromise : Thenable < vscode . Task [ ] > | undefined = undefined ;
88
9- public provideTasks ( ) : Thenable < vscode . Task [ ] > | undefined {
9+ public provideTasks ( ) : Thenable < vscode . Task [ ] > | undefined {
1010 if ( ! this . bazelPromise ) {
1111 this . bazelPromise = getBazelTasks ( ) ;
1212 }
@@ -18,7 +18,7 @@ export class BazelTaskProvider implements vscode.TaskProvider {
1818 if ( task ) {
1919 // resolveTask requires that the same definition object be used.
2020 const definition : BazelTaskDefinition = < any > _task . definition ;
21- return new vscode . Task ( definition , _task . scope ?? vscode . TaskScope . Workspace , definition . task , 'bazel' , new vscode . ShellExecution ( `bazel ${ definition . task } ` ) ) ;
21+ return new vscode . Task ( definition , _task . scope ?? vscode . TaskScope . Workspace , definition . name , definition . type , new vscode . ShellExecution ( `${ definition . task } ` ) ) ;
2222 }
2323 return undefined ;
2424 }
@@ -30,15 +30,54 @@ interface BazelTaskDefinition extends vscode.TaskDefinition {
3030}
3131
3232async function getBazelTasks ( ) : Promise < vscode . Task [ ] > {
33- const result : vscode . Task [ ] = [ ] ;
3433
35- const kind : BazelTaskDefinition = {
36- type : 'bazel' ,
37- } ;
34+ const tasksDefenitions : BazelTaskDefinition [ ] = [ ] ;
3835
39- result . push ( new vscode . Task ( kind , vscode . TaskScope . Workspace , 'Build' , 'bazel' , new vscode . ShellExecution ( `bazel build //...` ) ) ) ;
40- result . push ( new vscode . Task ( kind , vscode . TaskScope . Workspace , 'Test' , 'bazel' , new vscode . ShellExecution ( `bazel test //...` ) ) ) ;
41- result . push ( new vscode . Task ( kind , vscode . TaskScope . Workspace , 'Dependencies' , 'bazel' , new vscode . ShellExecution ( `bazel query --notool_deps --noimplicit_deps \"deps(//...)\" --output graph` ) ) ) ;
36+ tasksDefenitions . push (
37+ {
38+ type : 'bazel' ,
39+ name : 'Build' ,
40+ task : 'bazel build //...'
41+ }
42+ ) ;
43+
44+ tasksDefenitions . push (
45+ {
46+ type : 'bazel' ,
47+ name : 'Test' ,
48+ task : 'bazel test //...'
49+ }
50+ ) ;
51+
52+ tasksDefenitions . push (
53+ {
54+ type : 'bazel' ,
55+ name : 'Dependencies' ,
56+ task : 'bazel query --notool_deps --noimplicit_deps \"deps(//...)\" --output graph'
57+ }
58+ ) ;
59+
60+ tasksDefenitions . push (
61+ {
62+ type : 'bazel' ,
63+ name : 'Formatting' ,
64+ task : 'buildifier -r . && echo \"Formatted\"'
65+ }
66+ ) ;
67+
68+ tasksDefenitions . push (
69+ {
70+ type : 'bazel' ,
71+ name : 'Unused deps' ,
72+ task : 'unused_deps //...'
73+ }
74+ ) ;
75+
76+ const result : vscode . Task [ ] = [ ] ;
77+
78+ tasksDefenitions . forEach ( function ( value ) {
79+ result . push ( new vscode . Task ( value , vscode . TaskScope . Workspace , `${ value . name } ` , `${ value . type } ` , new vscode . ShellExecution ( `${ value . task } ` ) ) ) ;
80+ } ) ;
4281
43- return result ;
82+ return result ;
4483}
0 commit comments