@@ -50,6 +50,7 @@ with URIs;
5050
5151with VSS.Characters ;
5252with VSS.Characters.Latin ;
53+ with VSS.String_Vectors ;
5354with VSS.Strings ;
5455with VSS.Strings.Conversions ;
5556
@@ -118,8 +119,9 @@ package body LSP.Ada_Handlers.Project_Loading is
118119
119120 procedure Ensure_Project_Loaded (Self : in out Message_Handler'Class) is
120121 use type VSS.Strings.Virtual_String;
122+ use VSS.Strings.Conversions;
121123
122- GPRs_Found : Natural := 0 ;
124+ Candidates : VSS.String_Vectors.Virtual_String_Vector ;
123125 Project_File : VSS.Strings.Virtual_String :=
124126 Self.Configuration.Project_File;
125127 GPR_Configuration_File : VSS.Strings.Virtual_String :=
@@ -188,29 +190,30 @@ package body LSP.Ada_Handlers.Project_Loading is
188190 declare
189191 Files : GNATCOLL.VFS.File_Array_Access :=
190192 Self.Client.Root_Directory.Read_Dir (GNATCOLL.VFS.Files_Only);
191- Found : GNATCOLL.VFS.Virtual_File;
192193 begin
193194 for X of Files.all loop
194195 if X.Has_Suffix (" .gpr" ) then
195- GPRs_Found := GPRs_Found + 1 ;
196- exit when GPRs_Found > 1 ;
197- Found := X;
196+ Candidates.Append (LSP.Utils.To_Virtual_String (X));
198197 end if ;
199198 end loop ;
200199
201200 GNATCOLL.VFS.Unchecked_Free (Files);
202201
203- if GPRs_Found = 1 then
204- Project_File := LSP.Utils.To_Virtual_String (Found) ;
202+ if Candidates.Length = 1 then
203+ Project_File := Candidates.First_Element ;
205204
206205 -- Report how we found the project
207206 Self.Project_Status.Set_Project_Type
208207 (LSP.Ada_Project_Loading.Single_Project_Found);
209208
210209 Tracer.Trace_Text (" Found unique project: " & Project_File);
211210 else
212- Tracer.Trace
213- (" Found " & GPRs_Found'Image & " projects at the root" );
211+ Tracer.Trace_Text
212+ (" Found "
213+ & To_Virtual_String (Candidates.Length'Image)
214+ & " projects at the root:"
215+ & VSS.Characters.Latin.Line_Feed
216+ & Candidates.Join (VSS.Characters.Latin.Line_Feed));
214217 end if ;
215218 end ;
216219 end if ;
@@ -276,12 +279,12 @@ package body LSP.Ada_Handlers.Project_Loading is
276279 -- We didn't find a project file. Let's load an implicit project. We
277280 -- reach this point either because there are no GPR projects at the
278281 -- root, or there are more than one.
279- pragma Assert (GPRs_Found = 0 or GPRs_Found > 1 );
282+ pragma Assert (Candidates.Length = 0 or Candidates.Length > 1 );
280283
281284 Load_Implicit_Project
282285 (Self,
283- (if GPRs_Found = 0 then LSP.Ada_Project_Loading.No_Project
284- elsif GPRs_Found > 1
286+ (if Candidates.Length = 0 then LSP.Ada_Project_Loading.No_Project
287+ elsif Candidates.Length > 1
285288 then LSP.Ada_Project_Loading.Multiple_Projects
286289 else LSP.Ada_Project_Loading.Project_Not_Found));
287290 end if ;
0 commit comments