@@ -12,13 +12,13 @@ import {
1212 CMD_BUILD_AND_DEBUG_MAIN ,
1313 CMD_BUILD_AND_RUN_GNATEMULATOR ,
1414 CMD_BUILD_AND_RUN_MAIN ,
15- CMD_GET_PROJECT_FILE ,
1615 CMD_GPR_PROJECT_ARGS ,
1716 CMD_RESTART_LANG_SERVERS ,
1817 CMD_SHOW_ADA_LS_OUTPUT ,
1918 CMD_SHOW_EXTENSION_LOGS ,
2019 CMD_SHOW_GPR_LS_OUTPUT ,
2120 CMD_SPARK_ASK_OPTIONS ,
21+ CMD_SPARK_CURRENT_GNATPROVE_OPTIONS ,
2222 CMD_SPARK_LIMIT_REGION_ARG ,
2323 CMD_SPARK_LIMIT_SUBP_ARG ,
2424 CMD_SPARK_PROVE_SUBP ,
@@ -27,13 +27,11 @@ import { AdaConfig, getOrAskForProgram, initializeConfig } from './debugConfigPr
2727import { adaExtState , logger , mainOutputChannel } from './extension' ;
2828import { loadGnatCoverageReport } from './gnattest' ;
2929import { findAdaMain , getProjectFileRelPath , getSymbols } from './helpers' ;
30- import { askSPARKOptions } from './sparkOptionsPicker' ;
30+ import { registerSPARKTaskWrappers } from './sparkCommands' ;
31+ import { askSPARKOptions , getLastSPARKOptions } from './sparkOptionsPicker' ;
3132import {
3233 DEFAULT_PROBLEM_MATCHERS ,
3334 SimpleTaskDef ,
34- TASK_PROVE_FILE_PLAIN_NAME ,
35- TASK_PROVE_LINE_PLAIN_NAME ,
36- TASK_PROVE_REGION_PLAIN_NAME ,
3735 TASK_PROVE_SUPB_PLAIN_NAME ,
3836 TASK_TYPE_SPARK ,
3937 findBuildAndRunTask ,
@@ -168,9 +166,6 @@ export function registerCommands(context: vscode.ExtensionContext, clients: Exte
168166 context . subscriptions . push (
169167 vscode . commands . registerCommand ( CMD_GPR_PROJECT_ARGS , gprProjectArgs ) ,
170168 ) ;
171- context . subscriptions . push (
172- vscode . commands . registerCommand ( CMD_GET_PROJECT_FILE , getProjectFromConfigOrALS ) ,
173- ) ;
174169 context . subscriptions . push (
175170 vscode . commands . registerCommand ( CMD_SPARK_LIMIT_SUBP_ARG , sparkLimitSubpArg ) ,
176171 ) ;
@@ -182,6 +177,9 @@ export function registerCommands(context: vscode.ExtensionContext, clients: Exte
182177 ) ;
183178
184179 context . subscriptions . push ( commands . registerCommand ( CMD_SPARK_ASK_OPTIONS , askSPARKOptions ) ) ;
180+ context . subscriptions . push (
181+ commands . registerCommand ( CMD_SPARK_CURRENT_GNATPROVE_OPTIONS , getLastSPARKOptions ) ,
182+ ) ;
185183
186184 context . subscriptions . push (
187185 commands . registerCommand ( 'ada.loadGnatCovXMLReport' , loadGnatCovXMLReport ) ,
@@ -191,36 +189,7 @@ export function registerCommands(context: vscode.ExtensionContext, clients: Exte
191189 vscode . commands . registerCommand ( 'ada.issueReporter' , openReportIssue ) ,
192190 ) ;
193191
194- registerTaskWrappers ( context ) ;
195- }
196-
197- /**
198- * The following commands are wrappers around VS Code tasks that allow setting
199- * key shortcuts to the wrapped tasks. Technically it is possible to set
200- * shortcuts directly on the `workbench.action.tasks.runTask` command with the
201- * target task as a command argument, however in several places the UI doesn't
202- * take into consideration the command argument, and thus it becomes impossible
203- * to distinguish the different tasks, and worse, our shortcut becomes
204- * displayed for the vanilla `Run Task` command.
205- *
206- * To avoid all that, we provide these commands as wrappers.
207- */
208- function registerTaskWrappers ( context : vscode . ExtensionContext ) {
209- const sparkTaskWrappers : { [ cmdId : string ] : string } = {
210- 'ada.spark.tasks.proveFile' : `${ TASK_TYPE_SPARK } : ${ TASK_PROVE_FILE_PLAIN_NAME } ` ,
211- 'ada.spark.tasks.proveSubprogram' : `${ TASK_TYPE_SPARK } : ${ TASK_PROVE_SUPB_PLAIN_NAME } ` ,
212- // eslint-disable-next-line max-len
213- 'ada.spark.tasks.proveSelectedRegion' : `${ TASK_TYPE_SPARK } : ${ TASK_PROVE_REGION_PLAIN_NAME } ` ,
214- 'ada.spark.tasks.proveLine' : `${ TASK_TYPE_SPARK } : ${ TASK_PROVE_LINE_PLAIN_NAME } ` ,
215- } ;
216- for ( const cmdId of Object . keys ( sparkTaskWrappers ) ) {
217- const taskId = sparkTaskWrappers [ cmdId ] ;
218- context . subscriptions . push (
219- commands . registerCommand ( cmdId , ( ) =>
220- commands . executeCommand ( 'workbench.action.tasks.runTask' , taskId ) ,
221- ) ,
222- ) ;
223- }
192+ registerSPARKTaskWrappers ( context ) ;
224193}
225194
226195/**
@@ -823,7 +792,6 @@ async function buildAndDebugSpecifiedMainWithGNATemulator(main: vscode.Uri): Pro
823792 */
824793export async function gprProjectArgs ( ) : Promise < string [ ] > {
825794 const scenarioArgs = gprScenarioArgs ( ) ;
826-
827795 return [ '-P' , await getProjectFromConfigOrALS ( ) ] . concat ( scenarioArgs ) ;
828796}
829797
@@ -892,7 +860,7 @@ export async function sparkLimitSubpArg(): Promise<string[]> {
892860 * zero-based while the `gnatprove` convention is one-based. This function does
893861 * the conversion.
894862 */
895- function getLimitSubpArg ( filename : string , range : vscode . Range ) {
863+ function getLimitSubpArg ( filename : string , range : vscode . Range ) : string {
896864 return `--limit-subp=${ filename } :${ range . start . line + 1 } ` ;
897865}
898866
@@ -1021,8 +989,8 @@ async function sparkProveSubprogram(
1021989 ) ;
1022990
1023991 /**
1024- * Replace the subp-region argument based on the parameter given to the
1025- * command.
992+ * Replace the subp-region command argument with the --limit-subp argument
993+ * pointing to the place where this command was triggered .
1026994 */
1027995 const taskDef = newTask . definition as SimpleTaskDef ;
1028996 assert ( taskDef . args ) ;
@@ -1036,17 +1004,6 @@ async function sparkProveSubprogram(
10361004 * with the same name in the task history.
10371005 */
10381006 newTask . name = `${ task . name } - ${ fileBasename } :${ range . start . line + 1 } ` ;
1039-
1040- /**
1041- * Add a command to ask the User for options. We do this instead of
1042- * pre-evaluating the options so that all invocations on the same
1043- * subprogram have the same set of (unevaluated) arguments, which means
1044- * that only one task shows up in the task history for each subprogram.
1045- * If we pre-evaluated the options, then each different set of User
1046- * choices would yield a different entry in the task history which is
1047- * noisy.
1048- */
1049- taskDef . args . splice ( regionArgIdx + 1 , 0 , `\${command:${ CMD_SPARK_ASK_OPTIONS } }` ) ;
10501007 } else {
10511008 throw Error (
10521009 `Task '${ getConventionalTaskLabel ( task ) } ' is missing a '${ regionArg } ' argument` ,
@@ -1059,6 +1016,11 @@ async function sparkProveSubprogram(
10591016 const resolvedTask = await adaExtState . getSparkTaskProvider ( ) ?. resolveTask ( newTask ) ;
10601017 assert ( resolvedTask ) ;
10611018
1019+ /**
1020+ * Ask for GNATprove options
1021+ */
1022+ await commands . executeCommand ( CMD_SPARK_ASK_OPTIONS ) ;
1023+
10621024 /**
10631025 * Execute the task.
10641026 */
0 commit comments