Skip to content

Commit 5848fd0

Browse files
author
automatic-merge
committed
Merge remote branch 'origin/master' into edge
2 parents 14c2984 + ed22d66 commit 5848fd0

File tree

32 files changed

+904
-246
lines changed

32 files changed

+904
-246
lines changed

.gitlab-ci.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ als-cov:
114114
115115
- target_subdir=$target_subdir/ada-coverage
116116
- publish-pages $CI_PROJECT_DIR/coverage/dhtml/ --target-subdir $target_subdir --expires 30
117-
- >
118-
echo "Coverage report: https://pages.gitlab.adacore-it.com/$CI_PROJECT_PATH/$target_subdir/index.html"
119117
coverage: '/^Stmt Coverage:\s+(\d+\.\d+\%) \(\d+ \/ \d+\)$/'
120118
artifacts:
121119
when: always # Upload on errors too
@@ -152,8 +150,6 @@ vscode-extension:
152150
fi
153151
- target_subdir=$target_subdir/ts-coverage
154152
- publish-pages $CI_PROJECT_DIR/coverage/ --target-subdir $target_subdir --expires 30
155-
- >
156-
echo "Coverage report: https://pages.gitlab.adacore-it.com/$CI_PROJECT_PATH/$target_subdir/index.html"
157153

158154
# Compute coverage percentage
159155
- line_rate=$(cat $CI_PROJECT_DIR/coverage/cobertura-coverage.xml | grep -o 'line-rate="\([^"]\+\)"' | head -1 | grep -o '[0-9.]\+')

.mypy.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[mypy]
2+
mypy_path = $MYPY_CONFIG_FILE_DIR/testsuite

.pre-commit-config.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@ repos:
2222
hooks:
2323
- id: mypy
2424
files: '\.py$'
25-
# exclude: "^tests/.+$"
25+
args:
26+
# These flags make mypy associate different module names to `test.py`
27+
# files from different test directories.
28+
- --explicit-package-bases
29+
- --namespace-packages
2630
additional_dependencies:
2731
- pytest-lsp
32+
- e3-testsuite
33+
- psutil
34+
- types-psutil
35+
36+
- repo: local
37+
hooks:
38+
# This hook checks that Python test directories are valid module names so
39+
# that mypy will accept to analyse multiple test.py in different
40+
# directories.
41+
- id: py-filenames
42+
name: Python test.py paths
43+
entry: Python path components should be valid modules names (e.g. no '.' or whitespace). This is for mypy to accept dealing with test.py files in different directories.
44+
language: fail
45+
files: 'testsuite.*[^A-Za-z0-9_\/].*test\.py$'

.vscode/settings.json.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"editor.autoIndent": "none",
1717
"editor.formatOnType": true,
1818
"editor.tabSize": 3,
19-
"editor.detectIndentation": false
19+
"editor.detectIndentation": false,
20+
"showNotificationsOnErrors": true
2021
},
2122
"python.analysis.extraPaths": ["testsuite"],
2223
"python.analysis.packageIndexDepths": [

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
section below it for the last release. -->
55
## \<next>
66

7+
* Add a setting `ada.showNotificationsOnErrors` to control whether VS Code should display error notifications for failing LSP requests.
8+
79
## 26.0.202411173
810

911
* Create commands for opening the project file and the log file

doc/settings.md

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ prefixing each setting name with `ada.`, e.g.
7575

7676
## Settings
7777

78-
Ada Language Server understands these settings:
78+
Settings taken into account only from the Ada & SPARK VS Code extension:
79+
80+
* [showNotificationsOnErrors](#shownotificationsonerrors)
81+
* [trace.server](#traceserver)
82+
83+
Settings understood by the Ada Language Server itself, independently from the LSP client:
7984

8085
* [projectFile](#projectfile)
8186
* [scenarioVariables](#scenariovariables)
@@ -97,6 +102,29 @@ Ada Language Server understands these settings:
97102

98103
----
99104

105+
### showNotificationsOnErrors
106+
107+
Controls whether VS Code should display error notifications for failing LSP requests.
108+
109+
This is disabled by default to avoid distractions while coding, and can be enabled if the User wishes to troubleshoot an unexpected behavior in the Ada & SPARK language support in VS Code.
110+
Note that regardless of this setting, errors are always logged to the VS Code output channels `Ada Language Server` and `GPR Language Server`. This setting only controls whether a corresponding visual notification is emitted in the UI.
111+
112+
### trace.server
113+
114+
This option controls the tracing of the communication between VS Code and the Ada
115+
language server. It causes the client to trace each message sent and received
116+
to/from the Ada language server in the `Ada Language Server` Output view.
117+
118+
The possible values are:
119+
120+
* `off`: no tracing.
121+
* `messages`: brief traces are emitted for each request sent and each response received.
122+
* `verbose`: verbose traces are emitted for each request sent and each response received, including the message content.
123+
124+
On the server side this option does not trigger any additional logging.
125+
126+
An equivalent setting `gpr.trace.server` exists for tracing the communcation between VS Code and the GPR language server.
127+
100128
### projectFile
101129

102130
You can configure the GNAT Project File via the `projectFile` key.
@@ -291,22 +319,6 @@ For more information about documentation styles see GNATdoc User's Manual.
291319
'documentationStyle': 'gnat'
292320
```
293321

294-
### trace.server
295-
296-
This option controls the tracing of the communication between VS Code and the Ada
297-
language server. It causes the client to trace each message sent and received
298-
to/from the Ada language server in the `Ada Language Server` Output view.
299-
300-
The possible values are:
301-
302-
* `off`: no tracing.
303-
* `messages`: brief traces are emitted for each request sent and each response received.
304-
* `verbose`: verbose traces are emitted for each request sent and each response received, including the message content.
305-
306-
On the server side this option does not trigger any additional logging.
307-
308-
An equivalent setting `gpr.trace.server` exists for tracing the communcation between VS Code and the GPR language server.
309-
310322
### onTypeFormatting.indentOnly
311323

312324
This option controls if the `textDocument/onTypeFormatting` request only indents a new line, or if
@@ -318,3 +330,4 @@ it additionally tries to format the previous node. By default, this option is en
318330
This option controls the formatting provider for the `textDocument/formatting`,
319331
`textDocument/rangeFormatting` and `textDocument/onTypeFormatting` request. By default, this option
320332
is enabled and ALS uses GNATformat as its formatting provider. If disabled, GNATpp is used instead.
333+

integration/vscode/ada/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,11 @@
348348
"title": "UI",
349349
"order": 2,
350350
"properties": {
351+
"ada.showNotificationsOnErrors": {
352+
"markdownDescription": "Whether to show error notifications for failing LSP requests.",
353+
"default": false,
354+
"type": "boolean"
355+
},
351356
"ada.documentationStyle": {
352357
"scope": "window",
353358
"type": "string",

integration/vscode/ada/src/clients.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
11
import { existsSync } from 'fs';
22
import * as vscode from 'vscode';
3-
import { LanguageClient, LanguageClientOptions, ServerOptions } from 'vscode-languageclient/node';
3+
import {
4+
LanguageClient,
5+
LanguageClientOptions,
6+
MessageSignature,
7+
ServerOptions,
8+
} from 'vscode-languageclient/node';
49
import { logger } from './extension';
510
import { logErrorAndThrow, setTerminalEnvironment } from './helpers';
611

12+
class AdaLanguageClient extends LanguageClient {
13+
/**
14+
* Override this function to avoid displaying popup notifications on LSP errors when
15+
* the 'showNotificationsOnErrors' setting is disabled.
16+
*/
17+
override handleFailedRequest<T>(
18+
type: MessageSignature,
19+
token: vscode.CancellationToken | undefined,
20+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
21+
error: any,
22+
defaultValue: T,
23+
showNotification?: boolean | undefined,
24+
): T {
25+
const showError = vscode.workspace.getConfiguration('ada').get('showNotificationsOnErrors');
26+
if (!showError) {
27+
showNotification = false;
28+
}
29+
30+
return super.handleFailedRequest(type, token, error, defaultValue, showNotification);
31+
}
32+
}
733
export function createClient(
834
context: vscode.ExtensionContext,
935
id: string,
@@ -93,5 +119,5 @@ export function createClient(
93119
initializationOptions: () => ({ ada: vscode.workspace.getConfiguration('ada') }),
94120
};
95121
// Create the language client
96-
return new LanguageClient(id, name, serverOptions, clientOptions);
122+
return new AdaLanguageClient(id, name, serverOptions, clientOptions);
97123
}

source/ada/lsp-ada_configurations.adb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,11 @@ package body LSP.Ada_Configurations is
361361
and then JSON (Index).Kind = Boolean_Value
362362
then
363363
Self.Use_Gnatformat := JSON (Index).Boolean_Value;
364+
365+
elsif Name = "showNotificationsOnErrors"
366+
then
367+
-- This is a VS Code only setting, treated at the VS Code extension's level
368+
null;
364369
end if;
365370

366371
Skip_Value (JSON, Index);

source/ada/lsp-ada_driver.adb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ with LSP.Server_Notifications.DidChange;
9696
with LSP.Server_Notifications.DidChangeConfiguration;
9797
with LSP.Server_Notifications.DidChangeWorkspaceFolders;
9898
with LSP.Server_Notifications.DidClose;
99+
with LSP.Server_Notifications.DidCreateFiles;
100+
with LSP.Server_Notifications.DidDeleteFiles;
99101
with LSP.Server_Notifications.DidOpen;
102+
with LSP.Server_Notifications.DidRenameFiles;
100103
with LSP.Server_Notifications.Exits;
101104
with LSP.Server_Requests.Declaration;
102105
with LSP.Server_Requests.Definition;
@@ -626,6 +629,18 @@ begin
626629
(LSP.Server_Notifications.DidClose.Notification'Tag,
627630
Ada_Fence_Message_Handler'Unchecked_Access);
628631

632+
Server.Register_Handler
633+
(LSP.Server_Notifications.DidCreateFiles.Notification'Tag,
634+
Ada_Fence_Message_Handler'Unchecked_Access);
635+
636+
Server.Register_Handler
637+
(LSP.Server_Notifications.DidRenameFiles.Notification'Tag,
638+
Ada_Fence_Message_Handler'Unchecked_Access);
639+
640+
Server.Register_Handler
641+
(LSP.Server_Notifications.DidDeleteFiles.Notification'Tag,
642+
Ada_Fence_Message_Handler'Unchecked_Access);
643+
629644
Server.Register_Handler
630645
(LSP.Server_Notifications.DidChangeWorkspaceFolders.Notification'Tag,
631646
Ada_Fence_Message_Handler'Unchecked_Access);

0 commit comments

Comments
 (0)