@@ -834,18 +834,49 @@ package body LSP.Ada_Handlers.Project_Loading is
834
834
(Self : in out Message_Handler'Class)
835
835
is
836
836
use GPR2;
837
- use GPR2.Build.Source.Sets;
837
+
838
+ procedure For_All_Part_Action
839
+ (Kind : Unit_Kind;
840
+ View : GPR2.Project.View.Object;
841
+ Path : Path_Name.Object;
842
+ Index : Unit_Index;
843
+ Sep_Name : Optional_Name_Type);
844
+
845
+ -- -----------------------
846
+ -- For_All_Part_Action --
847
+ -- -----------------------
848
+
849
+ procedure For_All_Part_Action
850
+ (Kind : Unit_Kind;
851
+ View : GPR2.Project.View.Object;
852
+ Path : Path_Name.Object;
853
+ Index : Unit_Index;
854
+ Sep_Name : Optional_Name_Type)
855
+ is
856
+ pragma Unreferenced (Kind);
857
+ pragma Unreferenced (View);
858
+ pragma Unreferenced (Index);
859
+ pragma Unreferenced (Sep_Name);
860
+ begin
861
+ Self.Project_Predefined_Sources.Include (Path.Virtual_File);
862
+ end For_All_Part_Action ;
838
863
begin
839
864
Self.Project_Predefined_Sources.Clear;
840
865
841
866
if Self.Project_Tree.Is_Defined
842
867
and then Self.Project_Tree.Has_Runtime_Project
843
868
then
844
- for Source of Self.Project_Tree.Runtime_Project.Sources loop
845
- if Source.Language = GPR2.Ada_Language then
846
- Self.Project_Predefined_Sources.Include
847
- (Source.Path_Name.Virtual_File);
848
- end if ;
869
+ -- Note that the following loop differs rather subtly from iterating
870
+ -- over the units in the runtime view: user projects are allowed to
871
+ -- override units from the runtime, and when they do the overridden
872
+ -- units should be ignored. We would incorrectly consider them if we
873
+ -- just iterated over the units of the runtime view.
874
+ for P of Self.Project_Tree.Namespace_Root_Projects loop
875
+ for Unit of P.Units (With_Externally_Built => True) loop
876
+ if Unit.Owning_View.Is_Runtime then
877
+ Unit.For_All_Part (For_All_Part_Action'Access );
878
+ end if ;
879
+ end loop ;
849
880
end loop ;
850
881
end if ;
851
882
end Update_Project_Predefined_Sources ;
0 commit comments