@@ -63,6 +63,9 @@ package body LSP.Ada_Handlers.Project_Loading is
63
63
GNATCOLL.Traces.Create (" ALS.RUNTIME_INDEXING" , GNATCOLL.Traces.On);
64
64
-- Trace to enable/disable runtime indexing. Useful for the testsuite.
65
65
66
+ Fallback_Msg : constant VSS.Strings.Virtual_String :=
67
+ " Falling back to other methods to load a project" ;
68
+
66
69
type GPR2_Reporter is new GPR2.Reporter.Object with record
67
70
Log : GPR2.Log.Object;
68
71
end record ;
@@ -136,8 +139,8 @@ package body LSP.Ada_Handlers.Project_Loading is
136
139
137
140
C : constant Context_Access := new Context (Self.Tracer);
138
141
139
- Reader : LSP.Ada_Handlers.File_Readers.LSP_File_Reader
140
- (Self'Unchecked_Access);
142
+ Reader :
143
+ LSP.Ada_Handlers.File_Readers.LSP_File_Reader (Self'Unchecked_Access);
141
144
142
145
Dirs : File_Sets.Set;
143
146
@@ -160,17 +163,17 @@ package body LSP.Ada_Handlers.Project_Loading is
160
163
Create_In_Memory_Project
161
164
(" fallback_context" , Dirs, Project_Tree, Success);
162
165
163
- pragma Assert
164
- (Success, " Can't create an empty project for the fallback context" );
166
+ pragma
167
+ Assert
168
+ (Success, " Can't create an empty project for the fallback context" );
165
169
166
170
-- Create a basic GPR2_Provider_And_Projects containing only the
167
171
-- implicit project and load it.
168
172
declare
169
173
Provider : Libadalang.Project_Provider.GPR2_Provider_And_Projects :=
170
174
(Provider =>
171
175
Libadalang.Project_Provider.Create_Project_Unit_Provider
172
- (Tree => Project_Tree,
173
- Project => Project_Tree.Root_Project),
176
+ (Tree => Project_Tree, Project => Project_Tree.Root_Project),
174
177
Projects => <>);
175
178
begin
176
179
Provider.Projects.Append (Project_Tree.Root_Project);
@@ -224,34 +227,54 @@ package body LSP.Ada_Handlers.Project_Loading is
224
227
(LSP.Ada_Project_Loading.Configured_Project);
225
228
226
229
elsif Is_Alire_Crate then
227
- Tracer.Trace (" Workspace is an Alire crate" );
228
-
229
- Tracer.Trace (" Performing minimal Alire sync" );
230
- LSP.Alire.Conservative_Alire_Sync
231
- (Self.Client.Root_Directory.Display_Full_Name, Alire_Error);
230
+ declare
232
231
233
- if not Alire_Error.Is_Empty then
234
- Tracer.Trace_Text (" Encountered errors: " & Alire_Error);
235
- Self.Project_Status.Set_Alire_Messages ([Alire_Error]);
236
- else
237
- Tracer.Trace (" Determining project from 'alr show' output" );
232
+ procedure Report_Alire_Errors ;
238
233
239
- LSP.Alire.Determine_Alire_Project
240
- (Root => Self.Client.Root_Directory.Display_Full_Name,
241
- Error => Alire_Error,
242
- Project => Project_File);
234
+ procedure Report_Alire_Errors is
235
+ begin
236
+ -- If the error is multi-line, use a separate line for the
237
+ -- fallback message. Otherwise, keep a single line.
238
+ if Alire_Error.Split_Lines.Length > 1 then
239
+ Alire_Error.Append (VSS.Characters.Latin.Line_Feed);
240
+ else
241
+ Alire_Error.Append (" : " );
242
+ end if ;
243
+ Alire_Error.Append (Fallback_Msg);
243
244
244
- if not Alire_Error.Is_Empty then
245
245
Tracer.Trace_Text (" Encountered errors: " & Alire_Error);
246
246
Self.Project_Status.Set_Alire_Messages ([Alire_Error]);
247
+ end Report_Alire_Errors ;
248
+
249
+ begin
250
+
251
+ Tracer.Trace (" Workspace is an Alire crate" );
252
+
253
+ Tracer.Trace (" Performing minimal Alire sync" );
254
+ LSP.Alire.Conservative_Alire_Sync
255
+ (Self.Client.Root_Directory.Display_Full_Name, Alire_Error);
256
+
257
+ if not Alire_Error.Is_Empty then
258
+ Report_Alire_Errors;
247
259
else
248
- -- Report how we found the project
249
- Self.Project_Status.Set_Project_Type
250
- (LSP.Ada_Project_Loading.Alire_Project);
251
- Self.Project_Status.Set_Alire_Messages ([]);
252
- end if ;
260
+ Tracer.Trace (" Determining project from 'alr show' output" );
253
261
254
- end if ;
262
+ LSP.Alire.Determine_Alire_Project
263
+ (Root => Self.Client.Root_Directory.Display_Full_Name,
264
+ Error => Alire_Error,
265
+ Project => Project_File);
266
+
267
+ if not Alire_Error.Is_Empty then
268
+ Report_Alire_Errors;
269
+ else
270
+ -- Report how we found the project
271
+ Self.Project_Status.Set_Project_Type
272
+ (LSP.Ada_Project_Loading.Alire_Project);
273
+ Self.Project_Status.Set_Alire_Messages ([]);
274
+ end if ;
275
+
276
+ end if ;
277
+ end ;
255
278
256
279
end if ;
257
280
@@ -354,7 +377,8 @@ package body LSP.Ada_Handlers.Project_Loading is
354
377
355
378
Load_Implicit_Project
356
379
(Self,
357
- (if Candidates.Length = 0 then LSP.Ada_Project_Loading.No_Project
380
+ (if Candidates.Length = 0
381
+ then LSP.Ada_Project_Loading.No_Project
358
382
elsif Candidates.Length > 1
359
383
then LSP.Ada_Project_Loading.Multiple_Projects
360
384
else LSP.Ada_Project_Loading.Project_Not_Found));
@@ -857,8 +881,7 @@ package body LSP.Ada_Handlers.Project_Loading is
857
881
is
858
882
Project : GPR2.Project.Tree.View_Builder.Object :=
859
883
GPR2.Project.Tree.View_Builder.Create
860
- (Project_Dir => GPR2.Path_Name.Create_Directory (" ." ),
861
- Name => Name);
884
+ (Project_Dir => GPR2.Path_Name.Create_Directory (" ." ), Name => Name);
862
885
Values : GPR2.Containers.Value_List;
863
886
Opts : GPR2.Options.Object;
864
887
Reporter : GPR2_Reporter;
0 commit comments