Skip to content

Commit 1f8b89a

Browse files
committed
Merge branch 'topic/vscode-spark' into 'master'
Use GNATprove option picker with all SPARK tasks See merge request eng/ide/ada_language_server!2105
2 parents 66a3fc6 + 5669bf4 commit 1f8b89a

File tree

14 files changed

+332
-205
lines changed

14 files changed

+332
-205
lines changed

integration/vscode/ada/package.json

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,30 +1183,66 @@
11831183
"icon": "$(run)",
11841184
"when": "ADA_PROJECT_CONTEXT"
11851185
},
1186+
{
1187+
"command": "ada.spark.tasks.cleanProject",
1188+
"title": "Clean project for proof",
1189+
"category": "SPARK",
1190+
"when": "ADA_PROJECT_CONTEXT"
1191+
},
1192+
{
1193+
"command": "ada.spark.tasks.examineProject",
1194+
"title": "Examine project",
1195+
"category": "SPARK",
1196+
"when": "ADA_PROJECT_CONTEXT"
1197+
},
1198+
{
1199+
"command": "ada.spark.tasks.examineFile",
1200+
"title": "Examine file",
1201+
"category": "SPARK",
1202+
"when": "editorLangId == ada && editorTextFocus"
1203+
},
1204+
{
1205+
"command": "ada.spark.tasks.examineSubprogram",
1206+
"title": "Examine subprogram",
1207+
"category": "SPARK",
1208+
"when": "editorLangId == ada && editorTextFocus"
1209+
},
1210+
{
1211+
"command": "ada.spark.tasks.proveProject",
1212+
"title": "Prove project",
1213+
"category": "SPARK",
1214+
"when": "ADA_PROJECT_CONTEXT"
1215+
},
11861216
{
11871217
"command": "ada.spark.tasks.proveFile",
1188-
"title": "Prove file (task wrapper)",
1218+
"title": "Prove file",
11891219
"category": "SPARK",
11901220
"when": "editorLangId == ada && editorTextFocus"
11911221
},
11921222
{
11931223
"command": "ada.spark.tasks.proveSubprogram",
1194-
"title": "Prove subprogram (task wrapper)",
1224+
"title": "Prove subprogram",
11951225
"category": "SPARK",
11961226
"when": "editorLangId == ada && editorTextFocus"
11971227
},
11981228
{
11991229
"command": "ada.spark.tasks.proveSelectedRegion",
1200-
"title": "Prove selected region (task wrapper)",
1230+
"title": "Prove selected region",
12011231
"category": "SPARK",
12021232
"when": "editorLangId == ada && editorTextFocus"
12031233
},
12041234
{
12051235
"command": "ada.spark.tasks.proveLine",
1206-
"title": "Prove line (task wrapper)",
1236+
"title": "Prove line",
12071237
"category": "SPARK",
12081238
"when": "editorLangId == ada && editorTextFocus"
12091239
},
1240+
{
1241+
"command": "ada.spark.askGNATproveOptions",
1242+
"title": "Select GNATprove options...",
1243+
"category": "SPARK",
1244+
"when": "ADA_PROJECT_CONTEXT"
1245+
},
12101246
{
12111247
"command": "ada.loadGnatCovXMLReport",
12121248
"category": "Ada",
@@ -1529,7 +1565,7 @@
15291565
"ws": "$ws"
15301566
},
15311567
"scripts": {
1532-
"check-licenses": "npx license-checker-rseidelsohn --summary --onlyAllow \"0BSD;Apache-2.0;BSD-2-Clause;BSD-3-Clause;BlueOak-1.0.0;CC0-1.0;GPL-3.0;GPL-3.0-or-later;ISC;MIT;Python-2.0;Zlib;EPL-2.0\" --excludePackages \"@vscode/vsce-sign-linux-x64;@vscode/vsce-sign-win32-x64;@vscode/vsce-sign\"",
1568+
"check-licenses": "npx license-checker-rseidelsohn --production --summary --onlyAllow \"MIT;ISC;CC-BY-4.0;GPL-3.0;BSD-3-Clause;EPL-2.0\"",
15331569
"vscode:prepublish": "npm run compile && npm run esbuild-base -- --minify --sourcemap",
15341570
"esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=out/src/extension.js --external:vscode --format=cjs --platform=node",
15351571
"compile": "node ./node_modules/typescript/bin/tsc && npm run compile-webview",

integration/vscode/ada/src/AdaCodeLensProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
CMD_BUILD_AND_RUN_GNATEMULATOR,
1818
CMD_BUILD_AND_RUN_MAIN,
1919
CMD_SPARK_PROVE_SUBP,
20-
} from './commands';
20+
} from './constants';
2121
import { envHasExec, getSymbols } from './helpers';
2222
import { adaExtState } from './extension';
2323

integration/vscode/ada/src/ExtensionState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
CMD_SHOW_ADA_LS_OUTPUT,
1515
CMD_SHOW_EXTENSION_LOGS,
1616
CMD_SHOW_GPR_LS_OUTPUT,
17-
} from './commands';
17+
} from './constants';
1818
import { AdaInitialDebugConfigProvider, initializeDebugging } from './debugConfigProvider';
1919
import { logger } from './extension';
2020
import { GnatTaskProvider } from './gnatTaskProvider';

integration/vscode/ada/src/alsExecuteCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {
4040
ReplaceTypeCommandArgs,
4141
} from './refactoring/alsReplaceTypeCommand';
4242
import { adaExtState } from './extension';
43-
import { CMD_RELOAD_PROJECT } from './commands';
43+
import { CMD_RELOAD_PROJECT } from './constants';
4444

4545
/**
4646
* Type alias for a function that intercepts a command and executes it by return a promise that

integration/vscode/ada/src/commands.ts

Lines changed: 30 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,31 @@ import { Disposable } from 'vscode-jsonrpc';
77
import { ExecuteCommandRequest } from 'vscode-languageclient';
88
import { ALSSourceDirDescription, ExtensionState } from './ExtensionState';
99
import { 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';
1026
import { AdaConfig, getOrAskForProgram, initializeConfig } from './debugConfigProvider';
1127
import { adaExtState, logger, mainOutputChannel } from './extension';
1228
import { loadGnatCoverageReport } from './gnattest';
1329
import { findAdaMain, getProjectFileRelPath, getSymbols } from './helpers';
14-
import { askSPARKOptions } from './sparkOptionsPicker';
30+
import { registerSPARKTaskWrappers } from './sparkCommands';
31+
import { askSPARKOptions, getLastSPARKOptions } from './sparkOptionsPicker';
1532
import {
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 {
3347
import { Hierarchy } from './visualizerTypes';
3448
import { 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-
11950
export 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
*/
891793
export 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

Comments
 (0)