Skip to content

Commit 893923e

Browse files
BoulangerAdrienBoulanger
authored andcommitted
Improve settings related to diagnostics
Add setting to control "gpr file diagnostics" Automatically refresh all the diagnostics when changing the settings. Add a test. For eng/ide/ada_language_server#1455
1 parent 4e4473b commit 893923e

18 files changed

+136
-38
lines changed

doc/settings.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ Settings understood by the Ada Language Server itself, independently from the LS
108108
* [rootDir](#rootdir)
109109
* [enableDiagnostics](#enableddiagnostics)
110110
* [adaFileDiagnostics](#adafilediagnostics)
111+
* [gprFileDiagnostics](#gprfilediagnostics)
111112
* [projectDiagnostics](#projectdiagnostics)
112113
* [alireDiagnostics](#alirediagnostics)
113114
* [enableIndexing](#enableindexing)
@@ -236,6 +237,17 @@ The value is a boolean.
236237
'adaFileDiagnostics': false
237238
```
238239

240+
### gprFileDiagnostics
241+
242+
You can explicitly deactivate the emission of diagnostics related to the
243+
edition of gpr Files via the `gprFileDiagnostics` key. By default,
244+
diagnostics are enabled.
245+
The value is a boolean.
246+
247+
```javascript
248+
'gprFileDiagnostics': false
249+
```
250+
239251
### projectDiagnostics
240252

241253
You can explicitly deactivate the emission of diagnostics when loading a

integration/vscode/ada/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@
426426
"scope": "window",
427427
"type": "boolean",
428428
"default": null,
429-
"description": "Controls whether or not the Ada Language Server should emit project diagnostics into the VS Code Problems view."
429+
"description": "Controls whether or not the Ada Language Server should emit diagnostics related to project loading into the VS Code Problems view."
430430
},
431431
"ada.alireDiagnostics": {
432432
"scope": "window",
@@ -438,7 +438,13 @@
438438
"scope": "window",
439439
"type": "boolean",
440440
"default": null,
441-
"description": "Controls whether or not the Ada Language Server should emit diagnostics related to Ada files into the VS Code Problems view."
441+
"description": "Controls whether or not the Ada Language Server should emit diagnostics related to the edition of Ada files into the VS Code Problems view."
442+
},
443+
"ada.gprFileDiagnostics": {
444+
"scope": "window",
445+
"type": "boolean",
446+
"default": null,
447+
"description": "Controls whether or not the Ada Language Server should emit diagnostics related to the edition of GPR files into the VS Code Problems view."
442448
}
443449
}
444450
},

integration/vscode/ada/schemas/als-settings-schema.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@
8888
"adaFileDiagnostics": {
8989
"type": "boolean",
9090
"default": true,
91-
"description": "Controls whether or not the Ada Language Server should emit diagnostics related to Ada Files into the VS Code Problems view."
91+
"description": "Controls whether or not the Ada Language Server should emit diagnostics related to the edition of Ada Files into the VS Code Problems view."
92+
},
93+
"gprFileDiagnostics": {
94+
"type": "boolean",
95+
"default": true,
96+
"description": "Controls whether or not the Ada Language Server should emit diagnostics related to the edition of GPR Files into the VS Code Problems view."
9297
},
9398
"foldComments": {
9499
"type": "boolean",

liblsp_3_16/source/lsp-client_notification_receivers.ads

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
with LSP.Types;
2121
with LSP.Messages;
22+
with VSS.Strings;
2223

2324
package LSP.Client_Notification_Receivers is
2425

@@ -28,18 +29,21 @@ package LSP.Client_Notification_Receivers is
2829
-- Receiver of notification on LSP client side
2930

3031
procedure On_Show_Message
31-
(Self : access Client_Notification_Receiver;
32-
Params : LSP.Messages.ShowMessageParams) is abstract;
32+
(Self : access Client_Notification_Receiver;
33+
Params : LSP.Messages.ShowMessageParams;
34+
Language : VSS.Strings.Virtual_String) is abstract;
3335
-- Process window/showMessage notification
3436

3537
procedure On_Log_Message
3638
(Self : access Client_Notification_Receiver;
37-
Params : LSP.Messages.LogMessageParams) is abstract;
39+
Params : LSP.Messages.LogMessageParams;
40+
Language : VSS.Strings.Virtual_String) is abstract;
3841
-- Process window/logMessage notification
3942

4043
procedure On_Publish_Diagnostics
41-
(Self : access Client_Notification_Receiver;
42-
Params : LSP.Messages.PublishDiagnosticsParams) is abstract;
44+
(Self : access Client_Notification_Receiver;
45+
Params : LSP.Messages.PublishDiagnosticsParams;
46+
Language : VSS.Strings.Virtual_String) is abstract;
4347
-- Process textDocument/publishDiagnostics notification
4448

4549
function Get_Progress_Type

liblsp_3_16/source/lsp-messages-client_notifications.adb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,38 @@ package body LSP.Messages.Client_Notifications is
2222
-----------
2323

2424
overriding procedure Visit
25-
(Self : LogMessage_Notification;
26-
Reciver : access Client_Notification_Receiver'Class)
25+
(Self : LogMessage_Notification;
26+
Receiver : access Client_Notification_Receiver'Class)
2727
is
2828
begin
29-
Reciver.On_Log_Message (Self.params);
29+
Receiver.On_Log_Message
30+
(Self.params, VSS.Strings.Empty_Virtual_String);
3031
end Visit;
3132

3233
-----------
3334
-- Visit --
3435
-----------
3536

3637
overriding procedure Visit
37-
(Self : ShowMessage_Notification;
38-
Reciver : access Client_Notification_Receiver'Class)
38+
(Self : ShowMessage_Notification;
39+
Receiver : access Client_Notification_Receiver'Class)
3940
is
4041
begin
41-
Reciver.On_Show_Message (Self.params);
42+
Receiver.On_Show_Message
43+
(Self.params, VSS.Strings.Empty_Virtual_String);
4244
end Visit;
4345

4446
-----------
4547
-- Visit --
4648
-----------
4749

4850
overriding procedure Visit
49-
(Self : PublishDiagnostics_Notification;
50-
Reciver : access Client_Notification_Receiver'Class)
51+
(Self : PublishDiagnostics_Notification;
52+
Receiver : access Client_Notification_Receiver'Class)
5153
is
5254
begin
53-
Reciver.On_Publish_Diagnostics (Self.params);
55+
Receiver.On_Publish_Diagnostics
56+
(Self.params, VSS.Strings.Empty_Virtual_String);
5457
end Visit;
5558

5659
-----------

liblsp_3_16/source/lsp-messages-client_notifications.ads

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ package LSP.Messages.Client_Notifications is
2727

2828
procedure Visit
2929
(Self : Client_Notification;
30-
Reciver : access Client_Notification_Receiver'Class) is abstract;
30+
Receiver : access Client_Notification_Receiver'Class) is abstract;
3131

3232
package LogMessages is new LSP.Generic_Notifications
3333
(Client_Notification,
@@ -39,7 +39,7 @@ package LSP.Messages.Client_Notifications is
3939

4040
overriding procedure Visit
4141
(Self : LogMessage_Notification;
42-
Reciver : access Client_Notification_Receiver'Class);
42+
Receiver : access Client_Notification_Receiver'Class);
4343

4444
package ShowMessages is new LSP.Generic_Notifications
4545
(Client_Notification,
@@ -51,7 +51,7 @@ package LSP.Messages.Client_Notifications is
5151

5252
overriding procedure Visit
5353
(Self : ShowMessage_Notification;
54-
Reciver : access Client_Notification_Receiver'Class);
54+
Receiver : access Client_Notification_Receiver'Class);
5555

5656
package PublishDiagnostics is new LSP.Generic_Notifications
5757
(Client_Notification,
@@ -63,7 +63,7 @@ package LSP.Messages.Client_Notifications is
6363

6464
overriding procedure Visit
6565
(Self : PublishDiagnostics_Notification;
66-
Reciver : access Client_Notification_Receiver'Class);
66+
Receiver : access Client_Notification_Receiver'Class);
6767

6868
package Progress_Params is new LSP.Generic_Notifications
6969
(Client_Notification,

source/ada/lsp-ada_configurations.adb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@ package body LSP.Ada_Configurations is
345345
then
346346
Self.Ada_File_Diagnostics_Enabled := JSON (Index).Boolean_Value;
347347

348+
elsif Check_Variable
349+
(Name, JSON (Index).Kind, "gprFileDiagnostics", Boolean_Value)
350+
then
351+
Self.GPR_File_Diagnostics_Enabled := JSON (Index).Boolean_Value;
352+
348353
elsif Check_Variable
349354
(Name, JSON (Index).Kind, "enableIndexing", Boolean_Value)
350355
then

source/ada/lsp-ada_configurations.ads

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,17 @@ package LSP.Ada_Configurations is
9090

9191
function Ada_File_Diagnostics_Enabled
9292
(Self : Configuration'Class) return Boolean;
93-
-- Whether to publish file related diagnostics
93+
-- Whether to publish ada file related diagnostics
94+
95+
function GPR_File_Diagnostics_Enabled
96+
(Self : Configuration'Class) return Boolean;
97+
-- Wheter to publish gpr file related diagnostics. This is used by the
98+
-- GLS only and is different from Project_Diagnostics_Enabled.
9499

95100
function Project_Diagnostics_Enabled
96101
(Self : Configuration'Class) return Boolean;
97-
-- Whether to publish project related diagnostics
102+
-- Whether to publish project related diagnostics. This is used by the
103+
-- ALS only.
98104

99105
function Alire_Diagnostics_Enabled
100106
(Self : Configuration'Class) return Boolean;
@@ -167,6 +173,7 @@ private
167173
Named_Notation_Threshold : Natural := 3;
168174
Log_Threshold : Natural := 10;
169175
Ada_File_Diagnostics_Enabled : Boolean := True;
176+
GPR_File_Diagnostics_Enabled : Boolean := True;
170177
Project_Diagnostics_Enabled : Boolean := True;
171178
Alire_Diagnostics_Enabled : Boolean := True;
172179
Indexing_Enabled : Boolean := True;
@@ -216,6 +223,11 @@ private
216223
return Boolean is
217224
(Self.Ada_File_Diagnostics_Enabled);
218225

226+
function GPR_File_Diagnostics_Enabled
227+
(Self : Configuration'Class)
228+
return Boolean is
229+
(Self.GPR_File_Diagnostics_Enabled);
230+
219231
function Project_Diagnostics_Enabled
220232
(Self : Configuration'Class)
221233
return Boolean is (Self.Project_Diagnostics_Enabled);

source/ada/lsp-ada_did_change_configurations.adb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ package body LSP.Ada_Did_Change_Configurations is
6464
Self.Parent.Context.Reload_Project;
6565
end if;
6666

67+
Self.Parent.Context.Refresh_Diagnostics;
6768
exception
6869
when E : others =>
6970
Self.Parent.Context.Trace_Exception (E);

source/ada/lsp-ada_handlers.adb

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3687,7 +3687,7 @@ package body LSP.Ada_Handlers is
36873687
LSP.Structures.Empty;
36883688
Force : Boolean := False)
36893689
is
3690-
Changed : Boolean;
3690+
Changed : Boolean := False;
36913691
Diag : LSP.Structures.PublishDiagnosticsParams;
36923692
begin
36933693
if Self.Configuration.Ada_File_Diagnostics_Enabled then
@@ -3696,13 +3696,12 @@ package body LSP.Ada_Handlers is
36963696
Changed => Changed,
36973697
Errors => Diag.diagnostics,
36983698
Force => Force);
3699+
end if;
36993700

3701+
if Force or else Changed or else not Other_Diagnostics.Is_Empty then
3702+
Diag.uri := Document.URI;
37003703
Diag.diagnostics.Append_Vector (Other_Diagnostics);
3701-
3702-
if Changed or else not Other_Diagnostics.Is_Empty then
3703-
Diag.uri := Document.URI;
3704-
Self.Sender.On_PublishDiagnostics_Notification (Diag);
3705-
end if;
3704+
Self.Sender.On_PublishDiagnostics_Notification (Diag);
37063705
end if;
37073706
end Publish_Diagnostics;
37083707

@@ -3761,6 +3760,21 @@ package body LSP.Ada_Handlers is
37613760
end if;
37623761
end Publish_Diagnostics;
37633762

3763+
-------------------------
3764+
-- Refresh_Diagnostics --
3765+
-------------------------
3766+
3767+
overriding procedure Refresh_Diagnostics (Self : in out Message_Handler) is
3768+
begin
3769+
for Document of Self.Open_Documents loop
3770+
Self.Publish_Diagnostics
3771+
(Document => LSP.Ada_Documents.Document_Access (Document),
3772+
Force => True);
3773+
end loop;
3774+
3775+
Self.Publish_Diagnostics (Force => True);
3776+
end Refresh_Diagnostics;
3777+
37643778
--------------------
37653779
-- Reload_Project --
37663780
--------------------

0 commit comments

Comments
 (0)