1616----------------------------------------------------------------------------*/
1717
1818import assert from 'assert' ;
19+ import { basename } from 'path' ;
1920import * as vscode from 'vscode' ;
2021import { CMD_GPR_PROJECT_ARGS } from './commands' ;
2122import { 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 ( / ^ a l r ( \. e x e ) ? $ / ) != null ;
1086+ }
0 commit comments