Skip to content

Commit 001b368

Browse files
BoulangerBoulanger
authored andcommitted
Show all warnings and errors
- Show them even if there is no file information attached - Remove defensive code, sending uri for non regular file is fine - Fix a_range conversion for sloc without source_reference Adapt tests. For eng/ide/ada_language_server#1423
1 parent 9c069b9 commit 001b368

File tree

12 files changed

+23
-23
lines changed

12 files changed

+23
-23
lines changed

source/ada/lsp-ada_project_loading.adb

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,24 @@ package body LSP.Ada_Project_Loading is
120120
(Project : Project_Status_Type)
121121
return LSP.Structures.Diagnostic_Vector
122122
is
123+
use GNATCOLL.VFS;
123124
use LSP.Structures;
124125

125126
Result : LSP.Structures.Diagnostic_Vector;
126127
Parent_Diagnostic : LSP.Structures.Diagnostic;
127128
GPR2_Messages : GPR2.Log.Object renames Project.GPR2_Messages;
128129
Project_File : GNATCOLL.VFS.Virtual_File renames
129130
Project.Project_File;
130-
URI : constant LSP.Structures.DocumentUri :=
131-
(if Project_File.Is_Regular_File
131+
Project_URI : constant LSP.Structures.DocumentUri :=
132+
(if Project_File /= No_File
132133
then
133134
(VSS.Strings.Conversions.To_Virtual_String
134135
(URIs.Conversions.From_File
135136
(Project_File.Display_Full_Name)) with null record)
136137
else "");
138+
Backup_Sloc : constant LSP.Structures.A_Range :=
139+
(start => (0, 0),
140+
an_end => (0, 0));
137141

138142
procedure Create_Project_Loading_Diagnostic;
139143
-- Create a parent diagnostic for the project loading status.
@@ -149,9 +153,6 @@ package body LSP.Ada_Project_Loading is
149153
---------------------------------------
150154

151155
procedure Create_Project_Loading_Diagnostic is
152-
Sloc : constant LSP.Structures.A_Range :=
153-
(start => (0, 0),
154-
an_end => (0, 0));
155156
begin
156157
-- Initialize the parent diagnostic.
157158
Parent_Diagnostic.a_range := ((0, 0), (0, 0));
@@ -164,8 +165,8 @@ package body LSP.Ada_Project_Loading is
164165
(LSP.Structures.DiagnosticRelatedInformation'
165166
(location =>
166167
LSP.Structures.Location'
167-
(uri => URI,
168-
a_range => Sloc,
168+
(uri => Project_URI,
169+
a_range => Backup_Sloc,
169170
others => <>),
170171
message =>
171172
Load_Status_Message (Project)));
@@ -185,8 +186,7 @@ package body LSP.Ada_Project_Loading is
185186
Sloc : constant GPR2.Source_Reference.Object :=
186187
GPR2.Message.Sloc (Msg);
187188
File : constant GPR2.Path_Name.Object :=
188-
(if Sloc.Is_Defined and then Sloc.Has_Source_Reference
189-
then
189+
(if Sloc.Is_Defined then
190190
GPR2.Path_Name.Create_File
191191
(GPR2.Filename_Type (Sloc.Filename))
192192
else
@@ -235,9 +235,8 @@ package body LSP.Ada_Project_Loading is
235235
Parent_Diagnostic.relatedInformation.Append
236236
(LSP.Structures.DiagnosticRelatedInformation'
237237
(location =>
238-
(uri => URI,
239-
a_range => (start => (0, 0),
240-
an_end => (0, 0)),
238+
(uri => Project_URI,
239+
a_range => Backup_Sloc,
241240
others => <>),
242241
message => VSS.Strings.Conversions.To_Virtual_String
243242
("The project was loaded, but no Ada runtime found. "

source/ada/lsp-utils.adb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ package body LSP.Utils is
614614
(line => Natural (Sloc.Line) - 1,
615615
character => Natural (Sloc.Column) - 1))
616616
else
617-
(start => (1, 1), an_end => (1, 1)));
617+
(start => (0, 0), an_end => (0, 0)));
618618

619619
------------
620620
-- To_URI --

testsuite/ada_lsp/project_configured_not_found/test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"relatedInformation": [
9191
{
9292
"location": {
93-
"uri": "",
93+
"uri": "$URI{foo_bar.gpr}",
9494
"range": {
9595
"start": {
9696
"line": 0,

testsuite/ada_lsp/project_diags.errors_to_not_found/test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
"relatedInformation": [
155155
{
156156
"location": {
157-
"uri": "",
157+
"uri": "$URI{no_project.gpr}",
158158
"range": {
159159
"start": {
160160
"line": 0,

testsuite/ada_lsp/project_diags.multiple_to_not_found/test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
"relatedInformation": [
139139
{
140140
"location": {
141-
"uri": "",
141+
"uri": "$URI{no_project.gpr}",
142142
"range": {
143143
"start": {
144144
"line": 0,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
project P is
2+
for Source_Dirs use ("..");
23
end P;

testsuite/ada_lsp/project_diags.no_project_to_not_found/test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
"relatedInformation": [
139139
{
140140
"location": {
141-
"uri": "",
141+
"uri": "$URI{no_project.gpr}",
142142
"range": {
143143
"start": {
144144
"line": 0,

testsuite/ada_lsp/project_diags.not_found_to_errors/test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"relatedInformation": [
8383
{
8484
"location": {
85-
"uri": "",
85+
"uri": "$URI{no_project.gpr}",
8686
"range": {
8787
"start": {
8888
"line": 0,

testsuite/ada_lsp/project_diags.not_found_to_not_found/test.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"relatedInformation": [
8383
{
8484
"location": {
85-
"uri": "",
85+
"uri": "$URI{no_project.gpr}",
8686
"range": {
8787
"start": {
8888
"line": 0,
@@ -155,7 +155,7 @@
155155
"relatedInformation": [
156156
{
157157
"location": {
158-
"uri": "",
158+
"uri": "$URI{no_project2.gpr}",
159159
"range": {
160160
"start": {
161161
"line": 0,

testsuite/ada_lsp/project_diags.not_found_to_valid/test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"relatedInformation": [
8383
{
8484
"location": {
85-
"uri": "",
85+
"uri": "$URI{no_project.gpr}",
8686
"range": {
8787
"start": {
8888
"line": 0,

0 commit comments

Comments
 (0)