Skip to content

Commit

Permalink
Merge remote branch 'origin/master' into edge
Browse files Browse the repository at this point in the history
  • Loading branch information
automatic-merge committed Jun 3, 2024
2 parents a4580d8 + 6ef03e2 commit d5d3171
Show file tree
Hide file tree
Showing 52 changed files with 2,185 additions and 2,098 deletions.
23 changes: 16 additions & 7 deletions .vscode/settings.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@
// Allow GitLab-specific Yaml tags in .gitlab-ci.yml
"yaml.customTags": ["!reference sequence"],
"triggerTaskOnSave.tasks": {
"ada: Compile current file": ["*.adb"],
"ada: Check current file": ["*.ads"]
// To work with automatically provided tasks, they
// must be provided without the `ada: ` prefix.
"Compile current file": ["*.adb"],
"Check current file": ["*.ads"]
},
"triggerTaskOnSave.restart": true,
"files.watcherExclude": {
Expand All @@ -89,16 +91,23 @@
"**/.hg/store/**": true,
".obj/": true
},
"extension-test-runner.extractSettings": {
"suite": ["describe", "suite"],
"test": ["it", "test"],
"extractWith": "syntax"
},
// The Extension Test Runner extension loads VS Code Mocha tests into the GUI
// by evaluating the JS test sources. If that fails, the following snippet
// switches it to a syntactic extraction which might will likely miss
// dynamically defined tests but might crashes in test loading.
// "extension-test-runner.extractSettings": {
// "suite": ["describe", "suite"],
// "test": ["it", "test"],
// "extractWith": "syntax"
// },
"extension-test-runner.debugOptions": {
"outFiles": [
"${workspaceFolder}/integration/vscode/ada/out/**/*.js",
"!**/node_modules/**"
],
"env": {
"MOCHA_TIMEOUT": "0"
},
"preLaunchTask": "npm: watch - integration/vscode/ada"
}
}
10 changes: 0 additions & 10 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@
"problemMatcher": ["$ada"],
"group": "test"
},
{
"type": "ada",
"configuration": {
"kind": "checkFile",
"projectFile": "${config:ada.projectFile}"
},
"problemMatcher": ["$ada"],
"group": "build",
"label": "ada: Check current file"
},
{
"type": "npm",
"script": "watch",
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TESTER=$(ROOTDIR)/.obj/tester/tester-run$(EXE)
MOCHA_ALS_UPDATE=

GPRBUILD_EXTRA=
GPRBUILD_FLAGS=-m -j4 $(GPRBUILD_EXTRA)
GPRBUILD_FLAGS=-m -j0 $(GPRBUILD_EXTRA)
GPRBUILD=gprbuild $(GPRBUILD_FLAGS) -XSUPERPROJECT=
GPRCLEAN_EXTRA=
GPRCLEAN=gprclean -XSUPERPROJECT= $(GPRCLEAN_EXTRA)
Expand Down
74 changes: 66 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ extension at
- [Refactoring](#refactoring)
- [Tasks](#tasks)
- [Task Customization](#task-customization)
- [Tasks for Project Mains](#tasks-for-project-mains)
- [ALIRE Support](#alire-support)
- [Commands and Shortcuts](#commands-and-shortcuts)
- [Ada: Go to other file](#ada-go-to-other-file)
- [Ada: Add subprogram box](#ada-add-subprogram-box)
Expand Down Expand Up @@ -190,6 +192,10 @@ The extension provides the following auto-detected tasks
* `spark: Prove selected region` - launch `gnatprove` on the selected region in the current editor
* `spark: Prove line` - launch `gnatprove` on the cursor line in the current editor
* `spark: Clean project for proof` - launch `gnatprove` on the current GPR project to clean proof artefacts
* `ada: Analyze the project with GNAT SAS`
* `ada: Analyze the current file with GNAT SAS`
* `ada: Create a report after a GNAT SAS analysis`
* `ada: Analyze the project with GNAT SAS and produce a report`

You can bind keyboard shortcuts to them by adding to the `keybindings.json` file:

Expand All @@ -205,27 +211,78 @@ You can bind keyboard shortcuts to them by adding to the `keybindings.json` file
#### Task Customization

You can [customize auto-detected tasks](https://code.visualstudio.com/docs/editor/tasks#_customizing-autodetected-tasks)
by providing extra tool command line options via the `args` property of the `configuration` object in the `tasks.json`:
by providing extra tool command line options via the `args` property of the object in the `tasks.json`:

```json
{
"version": "2.0.0",
"tasks": [
{
"type": "ada",
"configuration": {
"kind": "buildProject",
"projectFile": "${config:ada.projectFile}",
"args": ["-gargs", "-vh"]
"command": "gprbuild",
"args": [
"${command:ada.gprProjectArgs}",
"-cargs:ada",
"-gnatef",
"-gargs",
"-vh"
],
"problemMatcher": ["$ada"],
"group": "build",
"label": "ada: Build current project"
}
]
}
```

You can also customize the working directory of the task or the environment variables via the `options` property:

```json
{
"version": "2.0.0",
"tasks": [
{
"type": "ada",
"command": "gprbuild",
"args": [
"${command:ada.gprProjectArgs}",
"-cargs:ada",
"-gnatef"
],
"options": {
"cwd": "${workspaceFolder}/my/subdir",
"env": {
"MY_ENV_VAR": "value"
}
},
"problemMatcher": ["$ada"],
"group": "build",
"label": "ada: Build current project with custom options"
"label": "ada: Build current project"
}
]
}
```

#### Tasks for Project Mains

If your GPR project defines main programs via the project attribute `Main`, additional tasks are automatically provided for each defined main.
For example, if the project defines a `main1.adb` and `main2.adb` located under the `src/` source directory, the following tasks will be available:

* `ada: Build main - src/main1.adb`
* `ada: Run main - src/main1.adb`
* `ada: Build and run main - src/main1.adb`
* `ada: Build main - src/main2.adb`
* `ada: Run main - src/main2.adb`
* `ada: Build and run main - src/main2.adb`

#### ALIRE Support

When the workspace is an ALIRE project (i.e. it contains an `alire.toml` file), tasks automatically use standard ALIRE commands.

For example, the `ada: Build current project` task uses the command `alr build` and the `ada: Clean current project` task uses the command `alr clean`.

All other tasks use `alr exec -- ...` to execute the command in the environment provided by ALIRE.

### Commands and Shortcuts

The extension contributes commands and a few default key bindings.
Expand Down Expand Up @@ -259,12 +316,13 @@ The VS Code extension has a few limitations and some differences compared to [GN
* **Indentation/formatting**: it does not support automatic indentation when adding a newline and range/document
formatting might no succeed on incomplete/illegal code.

* **Tooling support**: we currently provide minimal support for *SPARK* (see *Prove/Examine* tasks in the [Auto-detected tasks](#auto-detected-tasks) section), but there is no support for tools such as *CodePeer*, *GNATcheck*, *GNATtest* or *GNATcoverage*.
* **Tooling support**: we currently provide support for some *SPARK*, *GNATtest* and *GNAT SAS* [Tasks](#tasks), but there is no support for tools such as *GNATcheck* or *GNATcoverage* yet.

* **Alire support**: if the root folder contains an `alire.toml` file and
there is `alr` executable in the `PATH`, then the language server fetches
the project's search path, environment variables and the project's file
name from the crate description.
name from the crate description. [Tasks](#tasks) are also automatically
invoked with ALIRE in this case.

* **Project support**: there is no `Scenario` view: users should configure scenarios via the *ada.scenarioVariables* setting (see the settings list available [here](doc/settings.md)). Saving the settings file after changing the values will automatically reload the project and update the
predefined tasks to take into account the new scenario values.
Expand Down
15 changes: 5 additions & 10 deletions integration/vscode/ada/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,14 @@
},
"project": "tsconfig.json"
},
"plugins": [
"@typescript-eslint/eslint-plugin",
"eslint-plugin-tsdoc"
],
"plugins": ["@typescript-eslint/eslint-plugin", "eslint-plugin-tsdoc"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:prettier/recommended"
],
"ignorePatterns": [
"out",
"**/*.d.ts"
],
"ignorePatterns": ["out", "**/*.d.ts"],
"rules": {
"tsdoc/syntax": "warn",
"max-len": [
Expand All @@ -37,6 +31,7 @@
"code": 100,
"ignoreUrls": true
}
]
],
"@typescript-eslint/switch-exhaustiveness-check": "error"
}
}
}
42 changes: 39 additions & 3 deletions integration/vscode/ada/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,28 @@
"taskDefinitions": [
{
"type": "ada",
"required": [
"configuration"
],
"when": "shellExecutionSupported",
"properties": {
"command": {
"description": "The name of the command to call.",
"type": "string"
},
"args": {
"description": "The arguments to pass to the command.",
"type": "array",
"items": {
"type": "string"
}
},
"compound": {
"description": "List of task names to be executed sequentially.",
"type": "array",
"items": {
"type": "string"
}
},
"configuration": {
"deprecationMessage": "The task property 'configuration' is deprecated. Instead, use the properties 'command' and 'args' to configure the task.",
"type": "object",
"required": [
"kind"
Expand Down Expand Up @@ -613,7 +630,26 @@
},
{
"type": "spark",
"when": "shellExecutionSupported",
"properties": {
"command": {
"description": "The name of the command to call.",
"type": "string"
},
"args": {
"description": "The arguments to pass to the command.",
"type": "array",
"items": {
"type": "string"
}
},
"compound": {
"description": "List of task names to be executed sequentially.",
"type": "array",
"items": {
"type": "string"
}
},
"configuration": {
"type": "object",
"required": [
Expand Down
12 changes: 11 additions & 1 deletion integration/vscode/ada/src/ExtensionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,20 @@ export class ExtensionState {
public readonly testData: Map<vscode.TestItem, object> = new Map();

/**
* The following fields are caches for ALS requests
* The following fields are caches for ALS requests or costly properties.
*/
cachedProjectFile: string | undefined;
cachedObjectDir: string | undefined;
cachedMains: string[] | undefined;
cachedExecutables: string[] | undefined;
cachedAlireTomls: vscode.Uri[] | undefined;

public clearALSCache() {
this.cachedProjectFile = undefined;
this.cachedObjectDir = undefined;
this.cachedMains = undefined;
this.cachedExecutables = undefined;
this.cachedAlireTomls = undefined;
}

constructor(context: vscode.ExtensionContext) {
Expand Down Expand Up @@ -205,4 +207,12 @@ export class ExtensionState {

return this.cachedExecutables;
}

public async getAlireTomls(): Promise<vscode.Uri[]> {
if (!this.cachedAlireTomls) {
this.cachedAlireTomls = await vscode.workspace.findFiles('alire.toml');
}

return this.cachedAlireTomls;
}
}
Loading

0 comments on commit d5d3171

Please sign in to comment.