@@ -168,23 +168,26 @@ package body LSP.Ada_Handlers.Project_Loading is
168168 Tracer.Trace_Text (" Found ada.projectFile = " & Project_File);
169169
170170 if Project_File.Starts_With (" file://" ) then
171- Project_File := VSS.Strings.Conversions.To_Virtual_String
172- (URIs.Conversions.To_File
173- (VSS.Strings.Conversions.To_UTF_8_String (Project_File), True));
171+ Project_File :=
172+ VSS.Strings.Conversions.To_Virtual_String
173+ (URIs.Conversions.To_File
174+ (VSS.Strings.Conversions.To_UTF_8_String (Project_File),
175+ True));
174176 end if ;
175177
176178 -- Report how we found the project
177- Self.Project_Status.Set_Project_Type (LSP.Ada_Project_Loading.Configured_Project);
179+ Self.Project_Status.Set_Project_Type
180+ (LSP.Ada_Project_Loading.Configured_Project);
178181
179182 elsif Is_Alire_Crate then
180183 Tracer.Trace (" Workspace is an Alire crate" );
181184 Tracer.Trace (" Determining project from 'alr show' output" );
182185
183186 LSP.Alire.Determine_Alire_Project
184- (Root => Self.Client.Root_Directory.Display_Full_Name,
185- Has_Alire => Has_Alire,
186- Error => Alire_Errors,
187- Project => Project_File);
187+ (Root => Self.Client.Root_Directory.Display_Full_Name,
188+ Has_Alire => Has_Alire,
189+ Error => Alire_Errors,
190+ Project => Project_File);
188191
189192 if not Has_Alire then
190193 Tracer.Trace
@@ -196,7 +199,8 @@ package body LSP.Ada_Handlers.Project_Loading is
196199 Tracer.Trace_Text (" Encountered errors: " & Alire_Errors);
197200 else
198201 -- Report how we found the project
199- Self.Project_Status.Set_Project_Type (LSP.Ada_Project_Loading.Alire_Project);
202+ Self.Project_Status.Set_Project_Type
203+ (LSP.Ada_Project_Loading.Alire_Project);
200204 end if ;
201205 end if ;
202206
@@ -205,7 +209,7 @@ package body LSP.Ada_Handlers.Project_Loading is
205209 Tracer.Trace (" Looking for a unique project at the root" );
206210 declare
207211 Files : GNATCOLL.VFS.File_Array_Access :=
208- Self.Client.Root_Directory.Read_Dir (GNATCOLL.VFS.Files_Only);
212+ Self.Client.Root_Directory.Read_Dir (GNATCOLL.VFS.Files_Only);
209213 Found : GNATCOLL.VFS.Virtual_File;
210214 begin
211215 for X of Files.all loop
@@ -222,24 +226,32 @@ package body LSP.Ada_Handlers.Project_Loading is
222226 Project_File := LSP.Utils.To_Virtual_String (Found);
223227
224228 -- Report how we found the project
225- Self.Project_Status.Set_Project_Type (LSP.Ada_Project_Loading.Single_Project_Found);
229+ Self.Project_Status.Set_Project_Type
230+ (LSP.Ada_Project_Loading.Single_Project_Found);
226231
227232 Tracer.Trace_Text (" Found unique project: " & Project_File);
228233 else
229- Tracer.Trace (" Found " & GPRs_Found'Image & " projects at the root" );
234+ Tracer.Trace
235+ (" Found " & GPRs_Found'Image & " projects at the root" );
230236 end if ;
231237 end ;
232238 end if ;
233239
234240 -- At this stage we tried everything to find a project file. Now let's try to load.
235241 if not Project_File.Is_Empty then
236242 declare
237- Environment : GPR2.Environment.Object := GPR2.Environment.Process_Environment;
243+ Environment : GPR2.Environment.Object :=
244+ GPR2.Environment.Process_Environment;
238245
239246 Charset : constant VSS.Strings.Virtual_String :=
240- (if not Self.Configuration.Charset.Is_Empty then Self.Configuration.Charset
241- elsif Is_Alire_Crate then VSS.Strings.Virtual_String'(" utf-8" ) -- Alire projects tend to prefer utf-8
242- else " iso-8859-1" );
247+ (if not Self.Configuration.Charset.Is_Empty
248+ then Self.Configuration.Charset
249+ elsif Is_Alire_Crate
250+ then
251+ VSS.Strings.Virtual_String'
252+ (" utf-8" ) -- Alire projects tend to prefer utf-8
253+ else
254+ " iso-8859-1" );
243255
244256 Errors : VSS.Strings.Virtual_String;
245257 begin
@@ -248,16 +260,19 @@ package body LSP.Ada_Handlers.Project_Loading is
248260 Tracer.Trace (" Setting environment from 'alr printenv'" );
249261
250262 LSP.Alire.Setup_Alire_Env
251- (Root => Self.Client.Root_Directory.Display_Full_Name,
263+ (Root =>
264+ Self.Client.Root_Directory.Display_Full_Name,
252265 Has_Alire => Has_Alire,
253266 Error => Errors,
254267 Environment => Environment);
255268
256269 if not Errors.Is_Empty then
257- Tracer.Trace_Text (" Encountered errors with Alire:" & LF & Errors);
270+ Tracer.Trace_Text
271+ (" Encountered errors with Alire:" & LF & Errors);
258272 end if ;
259273 else
260- Tracer.Trace (" Alire environment is already set up. Not calling 'alr printenv'." );
274+ Tracer.Trace
275+ (" Alire environment is already set up. Not calling 'alr printenv'." );
261276 end if ;
262277 end if ;
263278
@@ -277,14 +292,19 @@ package body LSP.Ada_Handlers.Project_Loading is
277292 Load_Implicit_Project
278293 (Self,
279294 (if GPRs_Found = 0 then LSP.Ada_Project_Loading.No_Project
280- elsif GPRs_Found > 1 then LSP.Ada_Project_Loading.Multiple_Projects
295+ elsif GPRs_Found > 1
296+ then LSP.Ada_Project_Loading.Multiple_Projects
281297 else LSP.Ada_Project_Loading.Project_Not_Found));
282298 end if ;
283299
284300 -- By this point we must have a context: either a project was
285301 -- successfully loaded, or project loading failed and we created a dummy
286302 -- context to avoid retrying.
287303 pragma Assert (not Self.Contexts.Is_Empty);
304+
305+ -- Publish workspace diagnostics every time a project might have
306+ -- been loaded/reloaded.
307+ Self.Publish_Diagnostics (Force => True);
288308 end Ensure_Project_Loaded ;
289309
290310 -- -------------------
0 commit comments