Skip to content

Commit

Permalink
gpr server: fix project loading
Browse files Browse the repository at this point in the history
Call Update_Sources and Set_Context, and properly catch
errors from these steps.

For eng/gpr/gpr-issues#317
  • Loading branch information
setton committed Jul 3, 2024
1 parent 3fb406f commit 2d1c7f2
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions source/gpr/lsp-gpr_documents.adb
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ package body LSP.GPR_Documents is
Self.Tree.Unload;

declare
Opts : GPR2.Options.Object;
Success : Boolean;
Opts : GPR2.Options.Object;
Success : Boolean;
Update_Log : GPR2.Log.Object;
begin
Opts.Add_Switch (GPR2.Options.P, String (Self.File.Value));

Expand All @@ -198,16 +199,29 @@ package body LSP.GPR_Documents is
Environment => LSP.GPR_Files.Environment);

if Success then
Success := Self.Tree.Set_Context (Configuration.Context);
Self.Tree.Update_Sources (Update_Log);
if Update_Log.Has_Error then
Self.Has_Messages := True;
else
Success := Self.Tree.Set_Context (Configuration.Context);
end if;
end if;

if not Success then
for C in Self.Tree.Log_Messages.Iterate loop
Self.Tracer.Trace (C.Element.Format);
Self.Messages.Append (C.Element);
end loop;
Self.Has_Messages := True;
end if;

-- Collect all messages coming from Load...
for C in Self.Tree.Log_Messages.Iterate loop
Self.Tracer.Trace (C.Element.Format);
Self.Messages.Append (C.Element);
end loop;

-- ... and all messages coming from Update_Sources
for C in Update_Log.Iterate loop
Self.Tracer.Trace (C.Element.Format);
Self.Messages.Append (C.Element);
end loop;
end;

Update_Diagnostics;
Expand Down

0 comments on commit 2d1c7f2

Please sign in to comment.