File tree Expand file tree Collapse file tree 4 files changed +38
-16
lines changed
Code Samples/hello/.vscode Expand file tree Collapse file tree 4 files changed +38
-16
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,28 @@ You can bind keyboard shortcuts to them by adding to the `keybindings.json` file
174
174
175
175
[ A demo for auto-detected tasks] ( https://github.com/AdaCore/ada_language_server/wiki/auto_detected_tasks.mp4 )
176
176
177
+ #### Task customization
178
+ You can [ customize autodetected tasks] ( https://code.visualstudio.com/docs/editor/tasks#_customizing-autodetected-tasks )
179
+ by providing extra tool command line options via ` args ` property in the ` tasks.json ` :
180
+
181
+ ``` json
182
+ {
183
+ "version" : " 2.0.0" ,
184
+ "tasks" : [
185
+ {
186
+ "type" : " gnat" ,
187
+ "taskKind" : " buildProject" ,
188
+ "problemMatcher" : [
189
+ " $ada"
190
+ ],
191
+ "group" : " build" ,
192
+ "label" : " ada: Build project" ,
193
+ "args" : [" -gargs" , " -vh" ]
194
+ }
195
+ ]
196
+ }
197
+ ```
198
+
177
199
### Commands and shortcuts
178
200
179
201
The extension contributes a few commands and corresponding key bindings.
Original file line number Diff line number Diff line change 4
4
"version" : " 2.0.0" ,
5
5
"tasks" : [
6
6
{
7
- "label" : " build" ,
8
- "type" : " shell" ,
9
- "command" : " gprbuild" ,
10
- "args" : [
11
- " -p" ,
12
- " -P" ,
13
- " ${config:ada.projectFile}" ,
14
- " -cargs" ,
15
- " -gnatef"
7
+ "type" : " gnat" ,
8
+ "taskKind" : " buildProject" ,
9
+ "problemMatcher" : [
10
+ " $ada"
16
11
],
17
- "problemMatcher" : [" $ada" ],
18
- "group" : {
19
- "kind" : " build" ,
20
- "isDefault" : true
21
- }
12
+ "group" : " build" ,
13
+ "label" : " ada: Build project" ,
14
+ "args" : [" -gargs" , " -q" ]
22
15
}
23
16
]
24
17
}
Original file line number Diff line number Diff line change 379
379
"taskKind" : {
380
380
"type" : " string" ,
381
381
"description" : " Tool and action kind"
382
+ },
383
+ "args" : {
384
+ "type" : " array" ,
385
+ "description" : " Extra command arguments"
382
386
}
383
387
}
384
388
}
Original file line number Diff line number Diff line change @@ -190,11 +190,14 @@ export default class GnatTaskProvider implements vscode.TaskProvider<vscode.Task
190
190
// Check if the task in our known task
191
191
if ( definition . taskKind in knownTaskKinds ) {
192
192
const item : TaskProperties = knownTaskKinds [ String ( definition . taskKind ) ] ;
193
+ const extraArgs : string [ ] = Array . isArray ( definition . args )
194
+ ? definition . args . map ( ( x ) => String ( x ) )
195
+ : [ ] ;
193
196
if ( item . extra ) {
194
197
// We have a callback, evaluate it to get an extra argument and
195
198
// wrap all args with getGnatArgs
196
199
return item . extra ( ) . then ( ( extra ) => {
197
- const args = getGnatArgs ( item . args . concat ( extra ? [ extra ] : [ ] ) ) ;
200
+ const args = getGnatArgs ( item . args . concat ( extraArgs , extra ? [ extra ] : [ ] ) ) ;
198
201
const shell = new vscode . ShellExecution ( item . tool , args ) ;
199
202
return new vscode . Task (
200
203
definition ,
@@ -206,7 +209,7 @@ export default class GnatTaskProvider implements vscode.TaskProvider<vscode.Task
206
209
) ;
207
210
} ) ;
208
211
} else {
209
- const shell = new vscode . ShellExecution ( item . tool , item . args ) ;
212
+ const shell = new vscode . ShellExecution ( item . tool , item . args . concat ( extraArgs ) ) ;
210
213
return new vscode . Task (
211
214
definition ,
212
215
vscode . TaskScope . Workspace , // scope
You can’t perform that action at this time.
0 commit comments