You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Settings understood by the Ada Language Server itself, independently from the LSP client:
101
102
@@ -147,6 +148,28 @@ On the server side this option does not trigger any additional logging.
147
148
148
149
An equivalent setting `gpr.trace.server` exists for tracing the communcation between VS Code and the GPR language server.
149
150
151
+
### metricThresholds
152
+
153
+
Configurable thresholds for metrics provided by `gnatmetric`. Each key is a metric name (e.g., `cyclomatic_complexity`, `code_lines`), and the value is an object with optional `warn` and `error` numeric thresholds.
154
+
Metric names can be retrieved from the XML metric files generated by `gnatmetric`, which by default are located under the project's object directory (`.metrics.xml` files).
155
+
156
+
Below is an example configuration for setting metric thresholds to highlight subprograms with high cyclomatic complexity:
157
+
158
+
```json
159
+
{
160
+
"ada.metricThresholds":
161
+
{
162
+
"cyclomatic_complexity":
163
+
{
164
+
"warn": 10,
165
+
"error": 20
166
+
}
167
+
}
168
+
}
169
+
```
170
+
171
+
If not set, no thresholds will be applied.
172
+
150
173
### projectFile
151
174
152
175
You can configure the GNAT Project File via the `projectFile` key.
Copy file name to clipboardExpand all lines: doc/vscode-ug.md
+15-2Lines changed: 15 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@ This extension **does not include a compiler nor additional tools**. Nonetheless
27
27
|| Code Coverage | ✅ |
28
28
|**GNAT SAS**|||
29
29
|| Static Analysis | ✅ |
30
+
|| Metrics | ✅ |
30
31
|**SPARK**|||
31
32
|| Formal Proof | ✅ |
32
33
@@ -314,6 +315,18 @@ The GNATtest integration in VS Code also supports running tests in coverage mode
314
315
315
316
Integrating the steps of source instrumentation and test harness build into the test execution workflow allows for a quick feedback loop: run a test, observe results and coverage, edit the test or the tested code, repeat... In this context invoking the VS Code commands `Test: Rerun Last Run` and `Test: Rerun Last Run with Coverage` with their respective keyboard shortcuts can be valuable.
316
317
318
+
## GNAT Metrics Support
319
+
320
+
The extension provides a predefined task called `Compute metrics for current file`, which runs `gnatmetric` and displays file metrics directly in the editor using CodeLenses.
By default, the displayed metrics include code complexity and lines of code. You can customize which metrics are shown by adjusting the command-line options for `gnatmetric` in the task configuration.
325
+
326
+
You can configure thresholds for specific metrics to highlight when they are exceeded via the `ada.metricThresholds`[VS Code setting](./settings.md#metricthresholds). The extension will display warning or error diagnostics for each violation, and the corresponding CodeLenses will show warning or error icons as appropriate.
This section provides some guidance to work on cross or embedded projects. It assumes
@@ -489,15 +502,15 @@ The VS Code extension has a few limitations and some differences compared to [GN
489
502
***Indentation/formatting**: it does not support automatic indentation when adding a newline and range/document
490
503
formatting might no succeed on incomplete/illegal code.
491
504
492
-
***Tooling support**: we currently provide support for some _SPARK_, _GNATtest_, _GNATcoverage_, _GNAT SAS_ and _GNATemulator_[Tasks](#tasks), but some workflows may not be supported yet.
505
+
***Tooling support**: we currently provide support for some _SPARK_, _GNATtest_, _GNATcoverage_, _GNAT SAS_, _GNATmetric_ and _GNATemulator_[Tasks](#tasks), but some workflows may not be supported yet.
493
506
494
507
***Alire support**: if the root folder contains an `alire.toml` file and
495
508
there is `alr` executable in the `PATH`, then the language server fetches
496
509
the project's search path, environment variables and the project's file
497
510
name from the crate description. [Tasks](#tasks) are also automatically
498
511
invoked with Alire in this case.
499
512
500
-
***Project support**: there is no `Scenario` view: users should configure scenarios via the _ada.scenarioVariables* setting (see the settings list available [here](./settings.md)). Saving the settings file after changing the values will automatically reload the project and update the
513
+
***Project support**: there is no `Scenario` view: users should configure scenarios via the `ada.scenarioVariables` setting (see the settings list available [here](./settings.md)). Saving the settings file after changing the values will automatically reload the project and update the
501
514
predefined tasks to take into account the new scenario values.
502
515
503
516
Source directories from imported projects should be added in a [workspace file](https://code.visualstudio.com/docs/editor/workspaces#_multiroot-workspaces). If you already have a workspace file, the extension will propose you to automatically add all the source directories coming from imported projects to your workspace automatically at startup.
Copy file name to clipboardExpand all lines: integration/vscode/ada/package.json
+7-1Lines changed: 7 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -564,6 +564,12 @@
564
564
],
565
565
"default": null,
566
566
"markdownDescription": "Enable editing Ada comments to update references to an entity when it is being renamed.\n\nIf not set in VS Code, this setting takes its value from the [`.als.json`](https://github.com/AdaCore/ada_language_server/blob/master/doc/settings.md) file at the root of the workspace, if that file exists. Otherwise it defaults to `false`."
567
+
},
568
+
"ada.metricThresholds": {
569
+
"scope": "window",
570
+
"type": "object",
571
+
"default": null,
572
+
"markdownDescription": "Configurable thresholds for metrics provided by `gnatmetric`. Each key is a metric name (e.g., `cyclomatic_complexity`, `code_lines`), and the value is an object with optional 'warn' and 'error' numeric thresholds.\nMetric names can be retrieved from the XML metric files generated by `gnatmetric`, which by default are located under the project's object directory (`.metrics.xml` files).\n\nIf not set, no thresholds will be applied."
Copy file name to clipboardExpand all lines: integration/vscode/ada/schemas/als-settings-schema.json
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -139,6 +139,12 @@
139
139
"type": "integer",
140
140
"default": 10,
141
141
"description": "Controls the maximum number of trace files preserved in the ALS log directory (which defaults to `~/.als`). When this threshold is reached, old trace files get deleted automatically. The default number of preserved trace files is `10`."
142
+
},
143
+
"metricThresholds": {
144
+
"scope": "window",
145
+
"type": "object",
146
+
"default": null,
147
+
"markdownDescription": "Configurable thresholds for metrics provided by `gnatmetric`. Each key is a metric name (e.g., `cyclomatic_complexity`, `code_lines`), and the value is an object with optional 'warn' and 'error' numeric thresholds.\nMetric names can be retrieved from the XML metric files generated by `gnatmetric`, which by default are located under the project's object directory (`.metrics.xml` files).\n\nIf not set, no thresholds will be applied."
0 commit comments