Skip to content

Commit 159f09a

Browse files
committed
Merge branch 'refine-predef-units' into 'master'
Refine indexing iteration over predefined units See merge request eng/ide/ada_language_server!1780
2 parents 7407fd0 + 5803f8e commit 159f09a

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

source/ada/lsp-ada_handlers-project_loading.adb

+37-6
Original file line numberDiff line numberDiff line change
@@ -834,18 +834,49 @@ package body LSP.Ada_Handlers.Project_Loading is
834834
(Self : in out Message_Handler'Class)
835835
is
836836
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;
838863
begin
839864
Self.Project_Predefined_Sources.Clear;
840865

841866
if Self.Project_Tree.Is_Defined
842867
and then Self.Project_Tree.Has_Runtime_Project
843868
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;
849880
end loop;
850881
end if;
851882
end Update_Project_Predefined_Sources;

0 commit comments

Comments
 (0)