Skip to content

Commit abbdd3c

Browse files
Merge branch 'topic/project_diagnostics' into 'master'
Fix + test case for project diagnostics See merge request eng/ide/ada_language_server!1527
2 parents f9b9c60 + 045e11a commit abbdd3c

File tree

6 files changed

+259
-14
lines changed

6 files changed

+259
-14
lines changed

source/ada/lsp-ada_handlers-project_diagnostics.adb

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,7 @@ package body LSP.Ada_Handlers.Project_Diagnostics is
9090
---------------------------------------
9191

9292
procedure Create_Project_Loading_Diagnostic is
93-
Project_File : GNATCOLL.VFS.Virtual_File renames
94-
Self.Handler.Project_Status.Project_File;
95-
URI : constant LSP.Structures.DocumentUri :=
96-
Self.Handler.To_URI (Project_File.Display_Full_Name);
97-
Sloc : constant LSP.Structures.A_Range :=
93+
Sloc : constant LSP.Structures.A_Range :=
9894
(start => (0, 0),
9995
an_end => (0, 0));
10096
begin
@@ -112,15 +108,24 @@ package body LSP.Ada_Handlers.Project_Diagnostics is
112108
Parent_Diagnostic.message := Project_Loading_Status_Messages
113109
(Self.Last_Status);
114110
else
115-
Parent_Diagnostic.message := "Project Problems";
116-
Parent_Diagnostic.relatedInformation.Append
117-
(LSP .Structures.DiagnosticRelatedInformation'
118-
(location => LSP.Structures.Location'
119-
(uri => URI,
120-
a_range => Sloc,
121-
others => <>),
122-
message => Project_Loading_Status_Messages
123-
(Self.Last_Status)));
111+
declare
112+
Project_File : GNATCOLL.VFS.Virtual_File renames
113+
Self.Handler.Project_Status.Project_File;
114+
URI : constant LSP.Structures.DocumentUri :=
115+
Self.Handler.To_URI
116+
(Project_File.Display_Full_Name);
117+
begin
118+
Parent_Diagnostic.message := "Project Problems";
119+
Parent_Diagnostic.relatedInformation.Append
120+
(LSP.Structures.DiagnosticRelatedInformation'
121+
(location =>
122+
LSP.Structures.Location'
123+
(uri => URI, a_range => Sloc,
124+
others => <>),
125+
message =>
126+
Project_Loading_Status_Messages
127+
(Self.Last_Status)));
128+
end;
124129
end if;
125130
end Create_Project_Loading_Diagnostic;
126131

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
project A is
2+
end A;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
project B is
2+
end B;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
procedure Main is
2+
begin
3+
null;
4+
end Main;
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
[
2+
{
3+
"comment": [
4+
"Test the project diagnostics when we have several .gpr files in the ",
5+
"root directory, without having set the 'ada.projectFile' setting.",
6+
"It also checks that we propose a quickfix to set 'ada.projectFile'."
7+
]
8+
},
9+
{
10+
"start": {
11+
"cmd": ["${ALS}"]
12+
}
13+
},
14+
{
15+
"send": {
16+
"request": {
17+
"jsonrpc": "2.0",
18+
"id": 1,
19+
"method": "initialize",
20+
"params": {
21+
"rootUri": "$URI{.}",
22+
"capabilities": {}
23+
}
24+
},
25+
"wait": [
26+
{
27+
"id": 1,
28+
"result": {
29+
"capabilities": {
30+
"executeCommandProvider": {
31+
"commands": ["<HAS>", "als-refactor-add-parameters"]
32+
}
33+
}
34+
}
35+
}
36+
]
37+
}
38+
},
39+
{
40+
"send": {
41+
"request": {
42+
"jsonrpc": "2.0",
43+
"method": "initialized",
44+
"params": {}
45+
},
46+
"wait": []
47+
}
48+
},
49+
{
50+
"send": {
51+
"request": {
52+
"jsonrpc": "2.0",
53+
"method": "textDocument/didOpen",
54+
"params": {
55+
"textDocument": {
56+
"uri": "$URI{main.adb}",
57+
"languageId": "ada",
58+
"version": 1,
59+
"text": "procedure Main is\nbegin\n null;\nend Main;\n"
60+
}
61+
}
62+
},
63+
"wait": []
64+
}
65+
},
66+
{
67+
"send": {
68+
"request": {
69+
"jsonrpc": "2.0",
70+
"id": 2,
71+
"method": "workspace/executeCommand",
72+
"params": {
73+
"command": "als-source-dirs"
74+
}
75+
},
76+
"wait": [
77+
{
78+
"method": "textDocument/publishDiagnostics",
79+
"params": {
80+
"uri": "$URI{main.adb}",
81+
"diagnostics": [
82+
{
83+
"range": {
84+
"start": {
85+
"line": 0,
86+
"character": 0
87+
},
88+
"end": {
89+
"line": 0,
90+
"character": 0
91+
}
92+
},
93+
"severity": 1,
94+
"source": "project",
95+
"message": "No project was loaded, because more than one project file has been found in the root directory. Please change configuration to point a correct project file."
96+
}
97+
]
98+
}
99+
}
100+
]
101+
}
102+
},
103+
{
104+
"send": {
105+
"request": {
106+
"jsonrpc": "2.0",
107+
"id": 6,
108+
"method": "textDocument/codeAction",
109+
"params": {
110+
"textDocument": {
111+
"uri": "$URI{main.adb}"
112+
},
113+
"range": {
114+
"start": {
115+
"line": 0,
116+
"character": 0
117+
},
118+
"end": {
119+
"line": 0,
120+
"character": 0
121+
}
122+
},
123+
"context": {
124+
"diagnostics": [
125+
{
126+
"range": {
127+
"start": {
128+
"line": 0,
129+
"character": 0
130+
},
131+
"end": {
132+
"line": 0,
133+
"character": 0
134+
}
135+
},
136+
"message": "No project was loaded, because more than one project file has been found in the root directory. Please change configuration to point a correct project file.",
137+
"severity": 1,
138+
"source": "project"
139+
}
140+
],
141+
"triggerKind": 2
142+
}
143+
}
144+
},
145+
"wait": []
146+
}
147+
},
148+
{
149+
"send": {
150+
"request": {
151+
"jsonrpc": "2.0",
152+
"id": 13,
153+
"method": "textDocument/codeAction",
154+
"params": {
155+
"textDocument": {
156+
"uri": "$URI{main.adb}"
157+
},
158+
"range": {
159+
"start": {
160+
"line": 0,
161+
"character": 0
162+
},
163+
"end": {
164+
"line": 0,
165+
"character": 0
166+
}
167+
},
168+
"context": {
169+
"diagnostics": [
170+
{
171+
"range": {
172+
"start": {
173+
"line": 0,
174+
"character": 0
175+
},
176+
"end": {
177+
"line": 0,
178+
"character": 0
179+
}
180+
},
181+
"message": "No project was loaded, because more than one project file has been found in the root directory. Please change configuration to point a correct project file.",
182+
"severity": 1,
183+
"source": "project"
184+
}
185+
],
186+
"triggerKind": 2
187+
}
188+
}
189+
},
190+
"wait": [
191+
{
192+
"id": 13,
193+
"result": [
194+
{
195+
"title": "Open settings for ada.projectFile",
196+
"kind": "quickfix",
197+
"diagnostics": [
198+
{
199+
"range": {
200+
"start": {
201+
"line": 0,
202+
"character": 0
203+
},
204+
"end": {
205+
"line": 0,
206+
"character": 0
207+
}
208+
},
209+
"severity": 1,
210+
"source": "project",
211+
"message": "No project was loaded, because more than one project file has been found in the root directory. Please change configuration to point a correct project file."
212+
}
213+
],
214+
"isPreferred": true,
215+
"command": {
216+
"title": "Open settings for ada.projectFile",
217+
"command": "workbench.action.openSettings",
218+
"arguments": "ada.projectFile"
219+
}
220+
}
221+
]
222+
}
223+
]
224+
}
225+
},
226+
{
227+
"stop": {
228+
"exit_code": 0
229+
}
230+
}
231+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: 'project_config.multiple_project_diagnostics'

0 commit comments

Comments
 (0)