Skip to content

Commit 4cba019

Browse files
BoulangerBoulanger
authored andcommitted
Replace trace by a setting to control project diagnostics emission
For eng/ide/ada_language_server#1423 For eng/ide/ada_language_server#1427
1 parent 908cf43 commit 4cba019

File tree

5 files changed

+48
-21
lines changed

5 files changed

+48
-21
lines changed

doc/settings.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Ada Language Server understands these settings:
5959
* [relocateBuildTree](#relocatebuildtree)
6060
* [rootDir](#rootdir)
6161
* [enableDiagnostics](#enablediagnostics)
62+
* [projectDiagnostics](#projectdiagnostics)
6263
* [enableIndexing](#enableindexing)
6364
* [renameInComments](#renameincomments)
6465
* [namedNotationThreshold](#namednotationthreshold)
@@ -143,6 +144,16 @@ The value is a boolean.
143144
'enableDiagnostics': false
144145
```
145146

147+
## projectDiagnostics
148+
149+
This setting needs `enableDiagnostics` enabled and can be disabled to remove
150+
project related diagnotics.
151+
The value is a boolean.
152+
153+
```javascript
154+
'enableDiagnostics': false
155+
```
156+
146157
## enableIndexing
147158

148159
By default, the server indexes the source files after loading a project,

integration/vscode/ada/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,12 @@
297297
},
298298
"order": 1
299299
},
300+
"ada.projectDiagnostics": {
301+
"scope": "window",
302+
"type": "boolean",
303+
"default": true,
304+
"description": "Controls whether or not the Ada Language Server should emit project diagnostics into the VS Code Problems view.\n\nNote: this setting is ignored if `ada.enableDiagnostics` is disabled and a workspace reload is necessary to refresh the diagnostics after modifying this setting."
305+
},
300306
"ada.defaultCharset": {
301307
"scope": "window",
302308
"type": "string",

source/ada/lsp-ada_configurations.adb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ package body LSP.Ada_Configurations is
244244
then
245245
Set (Self.Project_File, JSON (Index).String_Value);
246246

247+
elsif Name = "projectDiagnostics"
248+
and then JSON (Index).Kind = Boolean_Value
249+
then
250+
Self.Project_Diagnostics_Enabled := JSON (Index).Boolean_Value;
251+
247252
elsif Name = "scenarioVariables"
248253
and then JSON (Index).Kind = Start_Object
249254
then

source/ada/lsp-ada_configurations.ads

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ package LSP.Ada_Configurations is
6969
function Diagnostics_Enabled (Self : Configuration'Class) return Boolean;
7070
-- Whether to publish diagnostics
7171

72+
function Project_Diagnostics_Enabled
73+
(Self : Configuration'Class) return Boolean;
74+
-- Whether to publish project related diagnostics
75+
7276
function Indexing_Enabled (Self : Configuration'Class) return Boolean;
7377
-- Whether to index sources in the background. This should be True
7478
-- for normal use, and can be disabled for debug or testing purposes.
@@ -128,21 +132,22 @@ private
128132
use type VSS.Strings.Virtual_String;
129133

130134
type Configuration is tagged record
131-
Project_File : VSS.Strings.Virtual_String;
132-
Charset : VSS.Strings.Virtual_String;
133-
Relocate_Build_Tree : VSS.Strings.Virtual_String;
134-
Relocate_Root : VSS.Strings.Virtual_String;
135-
Named_Notation_Threshold : Natural := 3;
136-
Log_Threshold : Natural := 10;
137-
Diagnostics_Enabled : Boolean := True;
138-
Indexing_Enabled : Boolean := True;
139-
Rename_In_Comments : Boolean := False;
140-
Folding_Comments : Boolean := True;
141-
Use_Completion_Snippets : Boolean := True;
142-
Use_Gnatformat : Boolean := False;
143-
Indent_Only : Boolean := True;
144-
Follow_Symlinks : Boolean := True;
145-
Insert_With_Clauses : Boolean := True;
135+
Project_File : VSS.Strings.Virtual_String;
136+
Charset : VSS.Strings.Virtual_String;
137+
Relocate_Build_Tree : VSS.Strings.Virtual_String;
138+
Relocate_Root : VSS.Strings.Virtual_String;
139+
Named_Notation_Threshold : Natural := 3;
140+
Log_Threshold : Natural := 10;
141+
Diagnostics_Enabled : Boolean := True;
142+
Project_Diagnostics_Enabled : Boolean := True;
143+
Indexing_Enabled : Boolean := True;
144+
Rename_In_Comments : Boolean := False;
145+
Folding_Comments : Boolean := True;
146+
Use_Completion_Snippets : Boolean := True;
147+
Use_Gnatformat : Boolean := False;
148+
Indent_Only : Boolean := True;
149+
Follow_Symlinks : Boolean := True;
150+
Insert_With_Clauses : Boolean := True;
146151

147152
Documentation_Style : GNATdoc.Comments.Options.Documentation_Style
148153
:= GNATdoc.Comments.Options.GNAT;
@@ -176,6 +181,10 @@ private
176181
function Diagnostics_Enabled (Self : Configuration'Class) return Boolean is
177182
(Self.Diagnostics_Enabled);
178183

184+
function Project_Diagnostics_Enabled
185+
(Self : Configuration'Class)
186+
return Boolean is (Self.Project_Diagnostics_Enabled);
187+
179188
function Indexing_Enabled (Self : Configuration'Class) return Boolean is
180189
(Self.Indexing_Enabled);
181190

source/ada/lsp-ada_handlers-project_diagnostics.adb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@
1515
-- of the license. --
1616
------------------------------------------------------------------------------
1717

18-
with GNATCOLL.Traces; use GNATCOLL.Traces;
19-
2018
package body LSP.Ada_Handlers.Project_Diagnostics is
2119

22-
Me : constant Trace_Handle := Create ("ALS.PROJECT.DIAGNOSTICS", On);
23-
2420
--------------------
2521
-- Get_Diagnostic --
2622
--------------------
@@ -30,7 +26,7 @@ package body LSP.Ada_Handlers.Project_Diagnostics is
3026
Context : LSP.Ada_Contexts.Context;
3127
Errors : out LSP.Structures.Diagnostic_Vector) is
3228
begin
33-
if Me.Active then
29+
if Self.Handler.Configuration.Project_Diagnostics_Enabled then
3430
Self.Last_Status := Self.Handler.Project_Status;
3531

3632
Self.Handler.Tracer.Trace ("Diag: " & Self.Last_Status'Image);
@@ -54,7 +50,7 @@ package body LSP.Ada_Handlers.Project_Diagnostics is
5450
is
5551
pragma Unreferenced (Context);
5652
begin
57-
if Me.Active then
53+
if Self.Handler.Configuration.Project_Diagnostics_Enabled then
5854
return LSP.Ada_Project_Loading.Has_New_Diagnostics
5955
(Self.Last_Status,
6056
Self.Handler.Project_Status);

0 commit comments

Comments
 (0)