Skip to content

Commit e93d16b

Browse files
Merge branch 'topic/zboon' into 'master'
Add defensive code when root project is not defined See merge request eng/ide/ada_language_server!1745
2 parents 23a648d + 618f45d commit e93d16b

File tree

5 files changed

+152
-0
lines changed

5 files changed

+152
-0
lines changed

source/ada/lsp-ada_handlers.ads

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ private
428428
overriding function Project_Tree_Is_Aggregate (Self : Message_Handler)
429429
return Boolean is
430430
(Self.Project_Tree_Is_Defined
431+
and then Self.Project_Tree.Root_Project.Is_Defined
431432
and then Self.Project_Tree.Root_Project.Kind in GPR2.Aggregate_Kind);
432433

433434
overriding procedure Reload_Project (Self : in out Message_Handler);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Include a project that does not exist so that
2+
-- it fails to load in the ALS.
3+
with "unexisting";
4+
5+
project Default is
6+
end Default;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
with Ada.Text_IO;
2+
3+
procedure Main is
4+
begin
5+
Ada.Text_IO.Put_Line ("Hello");
6+
end Main;
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
[
2+
{
3+
"comment": [
4+
"This test checks that the textDocument/hover request does not crash ",
5+
"even when the project could not be loaded properly."
6+
]
7+
},
8+
{
9+
"start": {
10+
"cmd": ["${ALS}"]
11+
}
12+
},
13+
{
14+
"send": {
15+
"request": {
16+
"jsonrpc": "2.0",
17+
"id": 0,
18+
"method": "initialize",
19+
"params": {
20+
"processId": 1,
21+
"rootUri": "$URI{.}",
22+
"capabilities": {}
23+
}
24+
},
25+
"wait": [
26+
{
27+
"id": 0,
28+
"result": {
29+
"capabilities": {
30+
"textDocumentSync": 2
31+
}
32+
}
33+
}
34+
]
35+
}
36+
},
37+
{
38+
"send": {
39+
"request": {
40+
"jsonrpc": "2.0",
41+
"method": "initialized"
42+
},
43+
"wait": []
44+
}
45+
},
46+
{
47+
"send": {
48+
"request": {
49+
"jsonrpc": "2.0",
50+
"method": "workspace/didChangeConfiguration",
51+
"params": {
52+
"settings": {
53+
"ada": {
54+
"projectFile": "$URI{default.gpr}",
55+
"scenarioVariables": {},
56+
"defaultCharset": "ISO-8859-1",
57+
"enableDiagnostics": false,
58+
"followSymlinks": false,
59+
"documentationStyle": "gnat",
60+
"namedNotationThreshold": 3,
61+
"foldComments": false
62+
}
63+
}
64+
}
65+
},
66+
"wait": []
67+
}
68+
},
69+
{
70+
"send": {
71+
"request": {
72+
"jsonrpc": "2.0",
73+
"method": "textDocument/didOpen",
74+
"params": {
75+
"textDocument": {
76+
"uri": "$URI{main.adb}",
77+
"languageId": "Ada",
78+
"version": 0,
79+
"text": "with Ada.Text_IO;\n\nprocedure Main is\n\nbegin Ada.Text_IO.Put_Line (\"Hello\");\nend Main;\n"
80+
}
81+
}
82+
},
83+
"wait": []
84+
}
85+
},
86+
{
87+
"send": {
88+
"request": {
89+
"jsonrpc": "2.0",
90+
"id": 4,
91+
"method": "textDocument/hover",
92+
"params": {
93+
"textDocument": {
94+
"uri": "$URI{main.adb}"
95+
},
96+
"position": {
97+
"line": 0,
98+
"character": 12
99+
}
100+
}
101+
},
102+
"wait": [
103+
{
104+
"id": 4,
105+
"result": {
106+
"contents": [
107+
"<HAS>",
108+
{
109+
"language": "ada",
110+
"value": "package Ada.Text_IO"
111+
}
112+
]
113+
}
114+
}
115+
]
116+
}
117+
},
118+
{
119+
"send": {
120+
"request": {
121+
"jsonrpc": "2.0",
122+
"id": 7,
123+
"method": "shutdown"
124+
},
125+
"wait": [
126+
{
127+
"id": 7,
128+
"result": null
129+
}
130+
]
131+
}
132+
},
133+
{
134+
"stop": {
135+
"exit_code": 0
136+
}
137+
}
138+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: 'hover.no_root_project'

0 commit comments

Comments
 (0)