@@ -7,17 +7,31 @@ import { Disposable } from 'vscode-jsonrpc';
77import { ExecuteCommandRequest } from 'vscode-languageclient' ;
88import { ALSSourceDirDescription , ExtensionState } from './ExtensionState' ;
99import { startVisualize } from './alsVisualizer' ;
10+ import {
11+ CMD_BUILD_AND_DEBUG_GNATEMULATOR ,
12+ CMD_BUILD_AND_DEBUG_MAIN ,
13+ CMD_BUILD_AND_RUN_GNATEMULATOR ,
14+ CMD_BUILD_AND_RUN_MAIN ,
15+ CMD_GPR_PROJECT_ARGS ,
16+ CMD_RESTART_LANG_SERVERS ,
17+ CMD_SHOW_ADA_LS_OUTPUT ,
18+ CMD_SHOW_EXTENSION_LOGS ,
19+ CMD_SHOW_GPR_LS_OUTPUT ,
20+ CMD_SPARK_ASK_OPTIONS ,
21+ CMD_SPARK_CURRENT_GNATPROVE_OPTIONS ,
22+ CMD_SPARK_LIMIT_REGION_ARG ,
23+ CMD_SPARK_LIMIT_SUBP_ARG ,
24+ CMD_SPARK_PROVE_SUBP ,
25+ } from './constants' ;
1026import { AdaConfig , getOrAskForProgram , initializeConfig } from './debugConfigProvider' ;
1127import { adaExtState , logger , mainOutputChannel } from './extension' ;
1228import { loadGnatCoverageReport } from './gnattest' ;
1329import { findAdaMain , getProjectFileRelPath , getSymbols } from './helpers' ;
14- import { askSPARKOptions } from './sparkOptionsPicker' ;
30+ import { registerSPARKTaskWrappers } from './sparkCommands' ;
31+ import { askSPARKOptions , getLastSPARKOptions } from './sparkOptionsPicker' ;
1532import {
1633 DEFAULT_PROBLEM_MATCHERS ,
1734 SimpleTaskDef ,
18- TASK_PROVE_FILE_PLAIN_NAME ,
19- TASK_PROVE_LINE_PLAIN_NAME ,
20- TASK_PROVE_REGION_PLAIN_NAME ,
2135 TASK_PROVE_SUPB_PLAIN_NAME ,
2236 TASK_TYPE_SPARK ,
2337 findBuildAndRunTask ,
@@ -33,89 +47,6 @@ import {
3347import { Hierarchy } from './visualizerTypes' ;
3448import { createHelloWorldProject , walkthroughStartDebugging } from './walkthrough' ;
3549
36- /**
37- * Identifier for a hidden command used for building and running a project main.
38- * The command accepts a parameter which is the URI of the main source file.
39- * It is triggered by CodeLenses provided by the extension.
40- *
41- * @see {@link buildAndRunSpecifiedMain }
42- */
43- export const CMD_BUILD_AND_RUN_MAIN = 'ada.buildAndRunMain' ;
44-
45- /**
46- * Identifier for a hidden command used for building and debugging a project main.
47- * The command accepts a parameter which is the URI of the main source file.
48- * It is triggered by CodeLenses provided by the extension.
49- *
50- * @see {@link buildAndDebugSpecifiedMain }
51- */
52- export const CMD_BUILD_AND_DEBUG_MAIN = 'ada.buildAndDebugMain' ;
53-
54- /**
55- * Identifier for a hidden command used for building and running a project main,
56- * using GNATemulator.
57- * The command accepts a parameter which is the URI of the main source file.
58- * It is triggered by CodeLenses provided by the extension.
59- *
60- * @see {@link buildAndRunMainWithGNATemulator }
61- */
62- export const CMD_BUILD_AND_RUN_GNATEMULATOR = 'ada.buildAndRunGNATemulator' ;
63-
64- /**
65- * Identifier for a hidden command used for building and debugging a project main,
66- * using GNATemulator.
67- * The command accepts a parameter which is the URI of the main source file.
68- * It is triggered by CodeLenses provided by the extension.
69- *
70- * @see {@link buildAndDebugSpecifiedMain }
71- */
72- export const CMD_BUILD_AND_DEBUG_GNATEMULATOR = 'ada.buildAndDebugGNATemulator' ;
73-
74- /**
75- * Identifier for a hidden command that returns an array of strings constituting
76- * the -P and -X project and scenario arguments.
77- */
78- export const CMD_GPR_PROJECT_ARGS = 'ada.gprProjectArgs' ;
79-
80- /**
81- * Identifier for a hidden command that returns a string referencing the current
82- * project. That string is either `"$\{config:ada.projectFile\}"` if that
83- * setting is configured, or otherwise the full path to the project file
84- * returned from a query to the
85- */
86- export const CMD_GET_PROJECT_FILE = 'ada.getProjectFile' ;
87-
88- export const CMD_SPARK_LIMIT_SUBP_ARG = 'ada.spark.limitSubpArg' ;
89- export const CMD_SPARK_LIMIT_REGION_ARG = 'ada.spark.limitRegionArg' ;
90- export const CMD_SPARK_PROVE_SUBP = 'ada.spark.proveSubprogram' ;
91- const CMD_SPARK_ASK_OPTIONS = 'ada.spark.askSPARKOptions' ;
92-
93- /**
94- * Identifier for the command that shows the extension's output in the Output panel.
95- */
96- export const CMD_SHOW_EXTENSION_LOGS = 'ada.showExtensionOutput' ;
97-
98- /**
99- * Identifier for the command that shows the output of the ALS for Ada in the Output panel.
100- */
101- export const CMD_SHOW_ADA_LS_OUTPUT = 'ada.showAdaLSOutput' ;
102-
103- /**
104- * Identifier for the command that shows the output of the ALS for GPR in the Output panel.
105- */
106- export const CMD_SHOW_GPR_LS_OUTPUT = 'ada.showGprLSOutput' ;
107-
108- /**
109- * Identifier for the command that reloads the currently loaded project on server-side.
110- */
111- export const CMD_RELOAD_PROJECT = 'als-reload-project' ;
112-
113- /**
114- * Identifier for the command that restarts all the language servers spawned by the extension
115- * (Ada and GPR).
116- */
117- export const CMD_RESTART_LANG_SERVERS = 'ada.restartLanguageServers' ;
118-
11950export function registerCommands ( context : vscode . ExtensionContext , clients : ExtensionState ) {
12051 context . subscriptions . push (
12152 vscode . commands . registerCommand ( CMD_RESTART_LANG_SERVERS , restartLanguageServers ) ,
@@ -235,9 +166,6 @@ export function registerCommands(context: vscode.ExtensionContext, clients: Exte
235166 context . subscriptions . push (
236167 vscode . commands . registerCommand ( CMD_GPR_PROJECT_ARGS , gprProjectArgs ) ,
237168 ) ;
238- context . subscriptions . push (
239- vscode . commands . registerCommand ( CMD_GET_PROJECT_FILE , getProjectFromConfigOrALS ) ,
240- ) ;
241169 context . subscriptions . push (
242170 vscode . commands . registerCommand ( CMD_SPARK_LIMIT_SUBP_ARG , sparkLimitSubpArg ) ,
243171 ) ;
@@ -249,6 +177,9 @@ export function registerCommands(context: vscode.ExtensionContext, clients: Exte
249177 ) ;
250178
251179 context . subscriptions . push ( commands . registerCommand ( CMD_SPARK_ASK_OPTIONS , askSPARKOptions ) ) ;
180+ context . subscriptions . push (
181+ commands . registerCommand ( CMD_SPARK_CURRENT_GNATPROVE_OPTIONS , getLastSPARKOptions ) ,
182+ ) ;
252183
253184 context . subscriptions . push (
254185 commands . registerCommand ( 'ada.loadGnatCovXMLReport' , loadGnatCovXMLReport ) ,
@@ -258,36 +189,7 @@ export function registerCommands(context: vscode.ExtensionContext, clients: Exte
258189 vscode . commands . registerCommand ( 'ada.issueReporter' , openReportIssue ) ,
259190 ) ;
260191
261- registerTaskWrappers ( context ) ;
262- }
263-
264- /**
265- * The following commands are wrappers around VS Code tasks that allow setting
266- * key shortcuts to the wrapped tasks. Technically it is possible to set
267- * shortcuts directly on the `workbench.action.tasks.runTask` command with the
268- * target task as a command argument, however in several places the UI doesn't
269- * take into consideration the command argument, and thus it becomes impossible
270- * to distinguish the different tasks, and worse, our shortcut becomes
271- * displayed for the vanilla `Run Task` command.
272- *
273- * To avoid all that, we provide these commands as wrappers.
274- */
275- function registerTaskWrappers ( context : vscode . ExtensionContext ) {
276- const sparkTaskWrappers : { [ cmdId : string ] : string } = {
277- 'ada.spark.tasks.proveFile' : `${ TASK_TYPE_SPARK } : ${ TASK_PROVE_FILE_PLAIN_NAME } ` ,
278- 'ada.spark.tasks.proveSubprogram' : `${ TASK_TYPE_SPARK } : ${ TASK_PROVE_SUPB_PLAIN_NAME } ` ,
279- // eslint-disable-next-line max-len
280- 'ada.spark.tasks.proveSelectedRegion' : `${ TASK_TYPE_SPARK } : ${ TASK_PROVE_REGION_PLAIN_NAME } ` ,
281- 'ada.spark.tasks.proveLine' : `${ TASK_TYPE_SPARK } : ${ TASK_PROVE_LINE_PLAIN_NAME } ` ,
282- } ;
283- for ( const cmdId of Object . keys ( sparkTaskWrappers ) ) {
284- const taskId = sparkTaskWrappers [ cmdId ] ;
285- context . subscriptions . push (
286- commands . registerCommand ( cmdId , ( ) =>
287- commands . executeCommand ( 'workbench.action.tasks.runTask' , taskId ) ,
288- ) ,
289- ) ;
290- }
192+ registerSPARKTaskWrappers ( context ) ;
291193}
292194
293195/**
@@ -890,7 +792,6 @@ async function buildAndDebugSpecifiedMainWithGNATemulator(main: vscode.Uri): Pro
890792 */
891793export async function gprProjectArgs ( ) : Promise < string [ ] > {
892794 const scenarioArgs = gprScenarioArgs ( ) ;
893-
894795 return [ '-P' , await getProjectFromConfigOrALS ( ) ] . concat ( scenarioArgs ) ;
895796}
896797
@@ -959,7 +860,7 @@ export async function sparkLimitSubpArg(): Promise<string[]> {
959860 * zero-based while the `gnatprove` convention is one-based. This function does
960861 * the conversion.
961862 */
962- function getLimitSubpArg ( filename : string , range : vscode . Range ) {
863+ function getLimitSubpArg ( filename : string , range : vscode . Range ) : string {
963864 return `--limit-subp=${ filename } :${ range . start . line + 1 } ` ;
964865}
965866
@@ -1088,8 +989,8 @@ async function sparkProveSubprogram(
1088989 ) ;
1089990
1090991 /**
1091- * Replace the subp-region argument based on the parameter given to the
1092- * command.
992+ * Replace the subp-region command argument with the --limit-subp argument
993+ * pointing to the place where this command was triggered .
1093994 */
1094995 const taskDef = newTask . definition as SimpleTaskDef ;
1095996 assert ( taskDef . args ) ;
@@ -1103,17 +1004,6 @@ async function sparkProveSubprogram(
11031004 * with the same name in the task history.
11041005 */
11051006 newTask . name = `${ task . name } - ${ fileBasename } :${ range . start . line + 1 } ` ;
1106-
1107- /**
1108- * Add a command to ask the User for options. We do this instead of
1109- * pre-evaluating the options so that all invocations on the same
1110- * subprogram have the same set of (unevaluated) arguments, which means
1111- * that only one task shows up in the task history for each subprogram.
1112- * If we pre-evaluated the options, then each different set of User
1113- * choices would yield a different entry in the task history which is
1114- * noisy.
1115- */
1116- taskDef . args . splice ( regionArgIdx + 1 , 0 , `\${command:${ CMD_SPARK_ASK_OPTIONS } }` ) ;
11171007 } else {
11181008 throw Error (
11191009 `Task '${ getConventionalTaskLabel ( task ) } ' is missing a '${ regionArg } ' argument` ,
@@ -1126,6 +1016,11 @@ async function sparkProveSubprogram(
11261016 const resolvedTask = await adaExtState . getSparkTaskProvider ( ) ?. resolveTask ( newTask ) ;
11271017 assert ( resolvedTask ) ;
11281018
1019+ /**
1020+ * Ask for GNATprove options
1021+ */
1022+ await commands . executeCommand ( CMD_SPARK_ASK_OPTIONS ) ;
1023+
11291024 /**
11301025 * Execute the task.
11311026 */
0 commit comments