Skip to content

Commit 38199ff

Browse files
Fix Constraint_Error when there is no project file
For eng/ide/ada_language_server#1211
1 parent f9b9c60 commit 38199ff

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-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

0 commit comments

Comments
 (0)