Skip to content

Commit ad4d590

Browse files
author
Philippe Gil
committed
Merge branch 'topic/1299-report-gpr2-exceptions-in-problems' into 'master'
Report GPR parser unexpected exceptions in diagnostics Closes #1299 See merge request eng/ide/ada_language_server!1501
2 parents 8fc659c + b709664 commit ad4d590

File tree

9 files changed

+246
-5
lines changed

9 files changed

+246
-5
lines changed

source/gpr/lsp-gpr_documents.adb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
-- of the license. --
1616
------------------------------------------------------------------------------
1717

18+
with Ada.Exceptions;
19+
1820
with GPR2.Message;
21+
with GPR2.Source_Reference;
1922

2023
package body LSP.GPR_Documents is
2124

@@ -171,12 +174,26 @@ package body LSP.GPR_Documents is
171174
Update_Diagnostics;
172175

173176
exception
177+
when GPR2.Project_Error | GPR2.Processing_Error =>
178+
179+
Update_Diagnostics;
180+
174181
when E : others =>
175182

176183
Self.Tracer.Trace_Exception (E);
177184

178-
Update_Diagnostics;
185+
Self.Tree.Log_Messages.Append
186+
(GPR2.Message.Create
187+
(Level => GPR2.Message.Error,
188+
Message => "GPR parser unexpected " &
189+
Ada.Exceptions.Exception_Name (E) & " " &
190+
Ada.Exceptions.Exception_Message (E),
191+
Sloc => GPR2.Source_Reference.Create
192+
(Filename => Self.File.Value,
193+
Line => 1,
194+
Column => 1)));
179195

196+
Update_Diagnostics;
180197
end Load;
181198

182199
-----------------------------

testsuite/gpr_lsp/gpr2_assertions/test.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@
8282
"params": {
8383
"uri": "$URI{prj.gpr}",
8484
"diagnostics": [
85+
{
86+
"range": {
87+
"start": {
88+
"line": 0,
89+
"character": 0
90+
},
91+
"end": {
92+
"line": 0,
93+
"character": 0
94+
}
95+
},
96+
"severity": 1,
97+
"message": "GPR parser unexpected ADA.ASSERTIONS.ASSERTION_ERROR DYNAMIC_PREDICATE failed at gpr2-message.adb:23"
98+
}
8599
]
86100
}
87101
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
with "";
2+
project Prj is
3+
for Source_List_File use "";
4+
for Excluded_Source_List_File use "";
5+
for Warning_Message use "";
6+
package Naming is
7+
for Body ("Ada") use "" ;
8+
for Implementation ("Ada") use "";
9+
for Spec ("Ada") use "";
10+
for Specification ("Ada") use "";
11+
end Naming;
12+
end Prj;
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
[
2+
{
3+
"comment": [
4+
"test gpr unexpected exception handling"
5+
]
6+
},
7+
{
8+
"start": {
9+
"cmd": [
10+
"${ALS}",
11+
"--language-gpr"
12+
]
13+
}
14+
},
15+
{
16+
"send": {
17+
"request": {
18+
"params": {
19+
"processId": 30612,
20+
"capabilities": {
21+
"workspace": {
22+
"applyEdit": false
23+
}
24+
},
25+
"rootUri": "$URI{.}"
26+
},
27+
"jsonrpc": "2.0",
28+
"id": 1,
29+
"method": "initialize"
30+
},
31+
"wait": [
32+
{
33+
"jsonrpc": "2.0",
34+
"id": 1,
35+
"result": {
36+
"capabilities": {
37+
"textDocumentSync": {
38+
"openClose": true,
39+
"change": 1
40+
},
41+
"completionProvider": {
42+
"triggerCharacters": [
43+
" "
44+
],
45+
"resolveProvider": true
46+
},
47+
"hoverProvider": true,
48+
"definitionProvider": true,
49+
"documentSymbolProvider": {}
50+
}
51+
}
52+
}
53+
]
54+
}
55+
},
56+
{
57+
"send": {
58+
"request": {
59+
"jsonrpc": "2.0",
60+
"method": "initialized"
61+
},
62+
"wait": []
63+
}
64+
},
65+
{
66+
"send": {
67+
"request": {
68+
"params": {
69+
"textDocument": {
70+
"text": "with \"\";\nproject Prj is\n for Source_List_File use \"\";\n for Excluded_Source_List_File use \"\";\n for Warning_Message use \"\";\n package Naming is\n for Body (\"Ada\") use \"\" ;\n for Implementation (\"Ada\") use \"\";\n for Spec (\"Ada\") use \"\";\n for Specification (\"Ada\") use \"\";\n end Naming;\nend Prj;",
71+
"version": 0,
72+
"uri": "$URI{prj.gpr}",
73+
"languageId": "Gpr"
74+
}
75+
},
76+
"jsonrpc": "2.0",
77+
"method": "textDocument/didOpen"
78+
},
79+
"wait": [
80+
{
81+
"jsonrpc": "2.0",
82+
"method": "textDocument/publishDiagnostics",
83+
"params": {
84+
"uri": "$URI{prj.gpr}",
85+
"diagnostics": [
86+
{
87+
"range": {
88+
"start": {
89+
"line": 0,
90+
"character": 0
91+
},
92+
"end": {
93+
"line": 0,
94+
"character": 0
95+
}
96+
},
97+
"severity": 1,
98+
"message": "GPR parser unexpected ADA.ASSERTIONS.ASSERTION_ERROR DYNAMIC_PREDICATE failed at gpr2-project-parser.adb:83"
99+
}
100+
]
101+
}
102+
}
103+
]
104+
}
105+
},
106+
{
107+
"send": {
108+
"request": {
109+
"jsonrpc": "2.0",
110+
"id": "shutdown",
111+
"method": "shutdown",
112+
"params": null
113+
},
114+
"wait": [
115+
{
116+
"id": "shutdown",
117+
"result": null
118+
}
119+
]
120+
}
121+
},
122+
{
123+
"send": {
124+
"request": {
125+
"jsonrpc": "2.0",
126+
"method": "exit"
127+
},
128+
"wait": []
129+
}
130+
},
131+
{
132+
"stop": {
133+
"exit_code": 0
134+
}
135+
}
136+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: 'gpr2 parsing assertions error handling'

testsuite/gpr_lsp/import_using_space_string/windows/test.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,22 @@
104104
"method": "textDocument/publishDiagnostics",
105105
"params": {
106106
"uri": "$URI{prj.gpr}",
107-
"diagnostics": []
107+
"diagnostics": [
108+
{
109+
"range": {
110+
"start": {
111+
"line": 0,
112+
"character": 0
113+
},
114+
"end": {
115+
"line": 0,
116+
"character": 0
117+
}
118+
},
119+
"severity": 1,
120+
"message": "GPR parser unexpected ADA.IO_EXCEPTIONS.NAME_ERROR invalid path name \" \""
121+
}
122+
]
108123
}
109124
}
110125
]

testsuite/gpr_lsp/imported_project_errors_handling/test.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,22 @@
8181
"method": "textDocument/publishDiagnostics",
8282
"params": {
8383
"uri": "$URI{prj.gpr}",
84-
"diagnostics": []
84+
"diagnostics": [
85+
{
86+
"range": {
87+
"start": {
88+
"line": 0,
89+
"character": 0
90+
},
91+
"end": {
92+
"line": 0,
93+
"character": 0
94+
}
95+
},
96+
"severity": 1,
97+
"message": "GPR parser unexpected ADA.ASSERTIONS.ASSERTION_ERROR DYNAMIC_PREDICATE failed at gpr2-project-parser.adb:83"
98+
}
99+
]
85100
}
86101
}
87102
]

testsuite/gpr_lsp/invalid_file_name_support/windows/test.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,23 @@
104104
"method": "textDocument/publishDiagnostics",
105105
"params": {
106106
"uri": "$URI{prj.gpr}",
107-
"diagnostics": []
107+
"diagnostics": [
108+
{
109+
"range": {
110+
"start": {
111+
"line": 0,
112+
"character": 0
113+
},
114+
"end": {
115+
"line": 0,
116+
"character": 0
117+
}
118+
},
119+
"severity": 1,
120+
121+
"message": "GPR parser unexpected ADA.IO_EXCEPTIONS.NAME_ERROR invalid path name \" \""
122+
}
123+
]
108124
}
109125
}
110126
]

testsuite/gpr_lsp/no_symbol_with_empty_name/test.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,22 @@
8686
"method": "textDocument/publishDiagnostics",
8787
"params": {
8888
"uri": "$URI{p.gpr}",
89-
"diagnostics": []
89+
"diagnostics": [
90+
{
91+
"range": {
92+
"start": {
93+
"line": 0,
94+
"character": 0
95+
},
96+
"end": {
97+
"line": 0,
98+
"character": 0
99+
}
100+
},
101+
"severity": 1,
102+
"message": "GPR parser unexpected ADA.ASSERTIONS.ASSERTION_ERROR DYNAMIC_PREDICATE failed at gpr2-project-parser.adb:83"
103+
}
104+
]
90105
}
91106
}
92107
]

0 commit comments

Comments
 (0)