Skip to content

Commit 95de463

Browse files
committed
Merge branch 'topic/gnat_task' into 'master'
Extra arguments in vscode tasks Closes #1113 See merge request eng/ide/ada_language_server!1156
2 parents 04728fe + 82fb3cf commit 95de463

File tree

8 files changed

+358
-571
lines changed

8 files changed

+358
-571
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,28 @@ You can bind keyboard shortcuts to them by adding to the `keybindings.json` file
174174

175175
[A demo for auto-detected tasks](https://github.com/AdaCore/ada_language_server/wiki/auto_detected_tasks.mp4)
176176

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+
177199
### Commands and shortcuts
178200

179201
The extension contributes a few commands and corresponding key bindings.

integration/vscode/Code Samples/hello/.vscode/tasks.json

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,14 @@
44
"version": "2.0.0",
55
"tasks": [
66
{
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"
1611
],
17-
"problemMatcher": ["$ada"],
18-
"group": {
19-
"kind": "build",
20-
"isDefault": true
21-
}
12+
"group": "build",
13+
"label": "ada: Build project",
14+
"args": ["-gargs", "-q"]
2215
}
2316
]
2417
}

integration/vscode/ada/package.json

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616
"ms-vscode.cpptools"
1717
],
1818
"activationEvents": [
19-
"onLanguage:ada",
20-
"onLanguage:gpr",
21-
"onCommand:workbench.action.tasks.runTask",
22-
"onCommand:ada.otherFile"
19+
"onCommand:workbench.action.tasks.runTask"
2320
],
2421
"main": "./out/extension",
2522
"icon": "icons/ada.png",
@@ -374,46 +371,18 @@
374371
],
375372
"taskDefinitions": [
376373
{
377-
"type": "gprbuild",
374+
"type": "gnat",
378375
"required": [
379-
"projectFile"
376+
"taskKind"
380377
],
381378
"properties": {
382-
"projectFile": {
383-
"type": "string",
384-
"description": "The project file"
385-
},
386-
"checkFile": {
387-
"type": "boolean",
388-
"description": "Just check the current file only"
389-
}
390-
}
391-
},
392-
{
393-
"type": "gprclean",
394-
"required": [
395-
"projectFile"
396-
],
397-
"properties": {
398-
"projectFile": {
399-
"type": "string",
400-
"description": "The project file"
401-
}
402-
}
403-
},
404-
{
405-
"type": "gnatprove",
406-
"required": [
407-
"projectFile"
408-
],
409-
"properties": {
410-
"projectFile": {
379+
"taskKind": {
411380
"type": "string",
412-
"description": "The project file"
381+
"description": "Tool and action kind"
413382
},
414-
"taskKind": {
415-
"type": "integer",
416-
"description": "Check the current file only or whole project"
383+
"args": {
384+
"type": "array",
385+
"description": "Extra command arguments"
417386
}
418387
}
419388
}

integration/vscode/ada/src/cleanTaskProvider.ts

Lines changed: 0 additions & 100 deletions
This file was deleted.

integration/vscode/ada/src/extension.ts

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,13 @@ import {
2525
} from 'vscode-languageclient/node';
2626
import { platform } from 'os';
2727
import * as process from 'process';
28-
import GPRTaskProvider from './gprTaskProvider';
29-
import cleanTaskProvider from './cleanTaskProvider';
30-
import gnatproveTaskProvider from './gnatproveTaskProvider';
31-
import { getSubprogramSymbol } from './gnatproveTaskProvider';
28+
import GnatTaskProvider from './gnatTaskProvider';
29+
import { getSubprogramSymbol } from './gnatTaskProvider';
3230
import { alsCommandExecutor } from './alsExecuteCommand';
3331
import { ALSClientFeatures } from './alsClientFeatures';
3432

3533
let alsTaskProvider: vscode.Disposable[] = [
36-
vscode.tasks.registerTaskProvider(GPRTaskProvider.gprBuildType, new GPRTaskProvider()),
37-
vscode.tasks.registerTaskProvider(cleanTaskProvider.cleanTaskType, new cleanTaskProvider()),
38-
39-
vscode.tasks.registerTaskProvider(
40-
gnatproveTaskProvider.gnatproveType,
41-
new gnatproveTaskProvider()
42-
),
34+
vscode.tasks.registerTaskProvider(GnatTaskProvider.gnatType, new GnatTaskProvider()),
4335
];
4436

4537
/**
@@ -182,22 +174,17 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
182174
// React to changes in configuration to recompute predefined tasks if the user
183175
// changes scenario variables' values.
184176
function configChanged(e: vscode.ConfigurationChangeEvent) {
185-
if (e.affectsConfiguration('ada.scenarioVariables')) {
177+
if (
178+
e.affectsConfiguration('ada.scenarioVariables') ||
179+
e.affectsConfiguration('ada.projectFile')
180+
) {
186181
for (const item of alsTaskProvider) {
187182
item.dispose();
188183
}
189184
alsTaskProvider = [
190185
vscode.tasks.registerTaskProvider(
191-
GPRTaskProvider.gprBuildType,
192-
new GPRTaskProvider()
193-
),
194-
vscode.tasks.registerTaskProvider(
195-
cleanTaskProvider.cleanTaskType,
196-
new cleanTaskProvider()
197-
),
198-
vscode.tasks.registerTaskProvider(
199-
gnatproveTaskProvider.gnatproveType,
200-
new gnatproveTaskProvider()
186+
GnatTaskProvider.gnatType,
187+
new GnatTaskProvider()
201188
),
202189
];
203190
}

0 commit comments

Comments
 (0)