Skip to content

Commit a7b2201

Browse files
committed
Add comments and fix GNAT SAS task command line
1 parent 5dde5d3 commit a7b2201

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

integration/vscode/ada/src/taskProviders.ts

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
----------------------------------------------------------------------------*/
1717

1818
import assert from 'assert';
19+
import { basename } from 'path';
1920
import * as vscode from 'vscode';
2021
import { CMD_GPR_PROJECT_ARGS } from './commands';
2122
import { adaExtState } from './extension';
@@ -120,6 +121,11 @@ const predefinedTasks: PredefinedTask[] = [
120121
command: 'gnatsas',
121122
args: ['analyze', '${command:ada.gprProjectArgs}'],
122123
},
124+
/**
125+
* Analysis results are not printed on stdio so no need to parse them
126+
* with a problem matcher. Results should be viewed with the
127+
* `gnatsas report` task below
128+
*/
123129
problemMatchers: '',
124130
},
125131
{
@@ -129,15 +135,24 @@ const predefinedTasks: PredefinedTask[] = [
129135
command: 'gnatsas',
130136
args: ['analyze', '${command:ada.gprProjectArgs}', '--file=${fileBasename}'],
131137
},
138+
/**
139+
* Analysis results are not printed on stdio so no need to parse them
140+
* with a problem matcher. Results should be viewed with the
141+
* `gnatsas report` task below
142+
*/
132143
problemMatchers: '',
133144
},
134145
{
135146
label: 'Create a report after a GNAT SAS analysis',
136147
taskDef: {
137148
type: TASK_TYPE_ADA,
138149
command: 'gnatsas',
139-
args: ['report', 'sarif', '${command:ada.gprProjectArgs}'],
150+
args: ['report', 'sarif', '${command:ada.gprProjectArgs}', '-o', 'report.sarif'],
140151
},
152+
/**
153+
* Analysis results are not printed on stdio so no need to parse them
154+
* with a problem matcher.
155+
*/
141156
problemMatchers: '',
142157
},
143158
{
@@ -149,6 +164,10 @@ const predefinedTasks: PredefinedTask[] = [
149164
'Create a report after a GNAT SAS analysis',
150165
],
151166
},
167+
/**
168+
* Analysis results are not printed on stdio so no need to parse them
169+
* with a problem matcher.
170+
*/
152171
problemMatchers: '',
153172
},
154173
{
@@ -1011,7 +1030,7 @@ function updateToAlire(taskDef: SimpleTaskDef): SimpleTaskDef {
10111030
/**
10121031
* Only process shell command tasks, if they are not already using ALIRE
10131032
*/
1014-
if (taskDef.command && taskDef.command != 'alr' && taskDef.command != 'alr.exe') {
1033+
if (taskDef.command && !isAlire(taskDef.command)) {
10151034
/**
10161035
* Create a copy of the task definition to modify its properties
10171036
*/
@@ -1020,7 +1039,8 @@ function updateToAlire(taskDef: SimpleTaskDef): SimpleTaskDef {
10201039
const args = taskDef.args?.concat() ?? [];
10211040

10221041
/**
1023-
* Change command to alire
1042+
* Change command to alire. No need to use `alr.exe` on Windows, just
1043+
* `alr` works.
10241044
*/
10251045
newTaskDef.command = 'alr';
10261046

@@ -1052,3 +1072,15 @@ function updateToAlire(taskDef: SimpleTaskDef): SimpleTaskDef {
10521072

10531073
return taskDef;
10541074
}
1075+
1076+
/**
1077+
*
1078+
* @param command - a string or {@link vscode.ShellQuotedString} from a task definition
1079+
* @returns true if the command points to ALIRE, i.e. if it's `alr` or `alr.exe`
1080+
* or a path to those executables.
1081+
*/
1082+
function isAlire(command: string | vscode.ShellQuotedString): boolean {
1083+
const value = typeof command == 'string' ? command : command.value;
1084+
const commandBasename = basename(value);
1085+
return commandBasename.match(/^alr(\.exe)?$/) != null;
1086+
}

integration/vscode/ada/test/suite/general/tasks.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ada: Build current project - gprbuild -P ${projectPath} -cargs:ada -gnatef
5656
ada: Check current file - gprbuild -q -f -c -u -gnatc -P ${projectPath} \${fileBasename} -cargs:ada -gnatef
5757
ada: Analyze the project with GNAT SAS - gnatsas analyze -P ${projectPath}
5858
ada: Analyze the current file with GNAT SAS - gnatsas analyze -P ${projectPath} --file=\${fileBasename}
59-
ada: Create a report after a GNAT SAS analysis - gnatsas report sarif -P ${projectPath}
59+
ada: Create a report after a GNAT SAS analysis - gnatsas report sarif -P ${projectPath} -o report.sarif
6060
ada: Generate documentation from the project - gnatdoc -P ${projectPath}
6161
ada: Create/update test skeletons for the project - gnattest -P ${projectPath}
6262
ada: Build main - src/main1.adb - gprbuild -P ${projectPath} src/main1.adb -cargs:ada -gnatef

0 commit comments

Comments
 (0)