diff --git a/extensions/src/libadalang-project_provider.adb b/extensions/src/libadalang-project_provider.adb index f378456b7..0f149cc70 100644 --- a/extensions/src/libadalang-project_provider.adb +++ b/extensions/src/libadalang-project_provider.adb @@ -302,8 +302,8 @@ package body Libadalang.Project_Provider is and then Unit_Files.Reference (Prj_Pos).Element.all /= Part.Unit_Files.Reference (Part_Pos).Element.all then - if Trace.Is_Active then - Trace.Trace + if Partition_Trace.Is_Active then + Partition_Trace.Trace ("Found conflicting source files for unit " & To_String (Unit_Name) & " in " & Name (Project) & " and " & Part_Image (Part)); @@ -390,7 +390,8 @@ package body Libadalang.Project_Provider is is Partition : Aggregate_Part_Vectors.Vector; begin - Trace.Increase_Indent ("Trying to partition " & Name (Root (Tree))); + Partition_Trace.Increase_Indent + ("Trying to partition " & Name (Root (Tree))); if Is_Aggregate_Project (Root (Tree)) then @@ -488,22 +489,23 @@ package body Libadalang.Project_Provider is end; end if; - Trace.Decrease_Indent; + Partition_Trace.Decrease_Indent; -- For debuggability, log how the Tree was partitioned - if Trace.Is_Active then - Trace.Increase_Indent ("Input project partitioned into:"); + if Partition_Trace.Is_Active then + Partition_Trace.Increase_Indent ("Input project partitioned into:"); for Cur in Partition.Iterate loop declare N : constant Positive := Aggregate_Part_Vectors.To_Index (Cur); Part : Aggregate_Part renames Partition.Element (N).all; begin - Trace.Trace ("Part" & N'Image & ": " & Part_Image (Part)); + Partition_Trace.Trace + ("Part" & N'Image & ": " & Part_Image (Part)); end; end loop; - Trace.Decrease_Indent; + Partition_Trace.Decrease_Indent; end if; -- For GPR2, make sure that all projects are namespace roots @@ -693,6 +695,27 @@ package body Libadalang.Project_Provider is Filename : in out US.Unbounded_String; PLE_Root_Index : in out Natural) is + function Request_Image return String + is (Kind'Image & " of unit " & Image (Name, With_Quotes => True)); + + procedure Trace_Found; + -- Assuming that we found the requested unit, log information about it + -- to the project provider trace. + + ----------------- + -- Trace_Found -- + ----------------- + + procedure Trace_Found is + begin + if Resolution_Trace.Is_Active then + Resolution_Trace.Trace + (Request_Image & " is located in " + & US.To_String (Filename) + & " at" & PLE_Root_Index'Image); + end if; + end Trace_Found; + Str_Name : constant String := Libadalang.Unit_Files.Unit_String_Name (Name); begin @@ -732,6 +755,7 @@ package body Libadalang.Project_Provider is if Fullname'Length /= 0 then GNAT.Task_Lock.Unlock; Filename := US.To_Unbounded_String (Fullname); + Trace_Found; return; end if; end; @@ -770,6 +794,7 @@ package body Libadalang.Project_Provider is US.To_Unbounded_String (String (Unit.Source.Value)); PLE_Root_Index := (if Unit.Index = 0 then 1 else Positive (Unit.Index)); + Trace_Found; return; end if; end; @@ -779,6 +804,9 @@ package body Libadalang.Project_Provider is -- If we reach this point, we have not found a unit handled by this -- provider that matches the requested name/kind. + if Resolution_Trace.Is_Active then + Resolution_Trace.Trace ("No unit found for " & Request_Image); + end if; Filename := US.Null_Unbounded_String; PLE_Root_Index := 1; end Get_Unit_Location; diff --git a/extensions/src/libadalang-project_provider.ads b/extensions/src/libadalang-project_provider.ads index ebe39916d..39601d7c2 100644 --- a/extensions/src/libadalang-project_provider.ads +++ b/extensions/src/libadalang-project_provider.ads @@ -27,8 +27,15 @@ package Libadalang.Project_Provider is package LAL renames Libadalang.Analysis; package Prj renames GNATCOLL.Projects; - Trace : constant GNATCOLL.Traces.Trace_Handle := GNATCOLL.Traces.Create - ("LIBADALANG.PROJECT_PROVIDER", GNATCOLL.Traces.From_Config); + Trace : constant GNATCOLL.Traces.Trace_Handle := + GNATCOLL.Traces.Create + ("LIBADALANG.PROJECT_PROVIDER", GNATCOLL.Traces.From_Config); + Partition_Trace : constant GNATCOLL.Traces.Trace_Handle := + GNATCOLL.Traces.Create + ("LIBADALANG.PROJECT_PROVIDER.PARTITION", GNATCOLL.Traces.From_Config); + Resolution_Trace : constant GNATCOLL.Traces.Trace_Handle := + GNATCOLL.Traces.Create + ("LIBADALANG.PROJECT_PROVIDER.RESOLUTION", GNATCOLL.Traces.From_Config); Unsupported_View_Error : exception; -- See the ``Create_Project_Unit_Provider`` functions below diff --git a/testsuite/tests/ada_api/gpr2_project_partition/basic/main.adb b/testsuite/tests/ada_api/gpr2_project_partition/basic/main.adb index 09ac3e151..a47b4f1b0 100644 --- a/testsuite/tests/ada_api/gpr2_project_partition/basic/main.adb +++ b/testsuite/tests/ada_api/gpr2_project_partition/basic/main.adb @@ -23,7 +23,7 @@ procedure Main is PAPs : GPR2_Provider_And_Projects_Array_Access; begin - GNATCOLL.Traces.Parse_Config ("LIBADALANG.PROJECT_PROVIDER=yes"); + GNATCOLL.Traces.Parse_Config ("LIBADALANG.PROJECT_PROVIDER.PARTITION=yes"); Put_Line ("Loading the project:"); Options.Add_Switch (GPR2.Options.P, "ap1.gpr"); if not Tree.Load (Options, With_Runtime => True) diff --git a/testsuite/tests/ada_api/gpr2_project_partition/basic/test.out b/testsuite/tests/ada_api/gpr2_project_partition/basic/test.out index 94a21b4d9..aee0d942b 100644 --- a/testsuite/tests/ada_api/gpr2_project_partition/basic/test.out +++ b/testsuite/tests/ada_api/gpr2_project_partition/basic/test.out @@ -1,9 +1,9 @@ Loading the project: -[LIBADALANG.PROJECT_PROVIDER] Trying to partition AP1 - [LIBADALANG.PROJECT_PROVIDER] Found conflicting source files for unit P1 in P3 and -[LIBADALANG.PROJECT_PROVIDER] Input project partitioned into: - [LIBADALANG.PROJECT_PROVIDER] Part 1: - [LIBADALANG.PROJECT_PROVIDER] Part 2: +[LIBADALANG.PROJECT_PROVIDER.PARTITION] Trying to partition AP1 + [LIBADALANG.PROJECT_PROVIDER.PARTITION] Found conflicting source files for unit P1 in P3 and +[LIBADALANG.PROJECT_PROVIDER.PARTITION] Input project partitioned into: + [LIBADALANG.PROJECT_PROVIDER.PARTITION] Part 1: + [LIBADALANG.PROJECT_PROVIDER.PARTITION] Part 2: * P1 P2 * P3 diff --git a/testsuite/tests/ada_api/project_partition/basic/main.adb b/testsuite/tests/ada_api/project_partition/basic/main.adb index ff901c08d..4a6e13071 100644 --- a/testsuite/tests/ada_api/project_partition/basic/main.adb +++ b/testsuite/tests/ada_api/project_partition/basic/main.adb @@ -23,7 +23,7 @@ procedure Main is PAPs : Provider_And_Projects_Array_Access; begin - GNATCOLL.Traces.Parse_Config ("LIBADALANG.PROJECT_PROVIDER=yes"); + GNATCOLL.Traces.Parse_Config ("LIBADALANG.PROJECT_PROVIDER.PARTITION=yes"); Put_Line ("Loading the project:"); Initialize (Env); Load (Tree.all, Create (+"ap1.gpr"), Env); diff --git a/testsuite/tests/ada_api/project_partition/basic/test.out b/testsuite/tests/ada_api/project_partition/basic/test.out index bd36da1b6..156d7273a 100644 --- a/testsuite/tests/ada_api/project_partition/basic/test.out +++ b/testsuite/tests/ada_api/project_partition/basic/test.out @@ -1,9 +1,9 @@ Loading the project: -[LIBADALANG.PROJECT_PROVIDER] Trying to partition AP1 - [LIBADALANG.PROJECT_PROVIDER] Found conflicting source files for unit p1 in P3 and -[LIBADALANG.PROJECT_PROVIDER] Input project partitioned into: - [LIBADALANG.PROJECT_PROVIDER] Part 1: - [LIBADALANG.PROJECT_PROVIDER] Part 2: +[LIBADALANG.PROJECT_PROVIDER.PARTITION] Trying to partition AP1 + [LIBADALANG.PROJECT_PROVIDER.PARTITION] Found conflicting source files for unit p1 in P3 and +[LIBADALANG.PROJECT_PROVIDER.PARTITION] Input project partitioned into: + [LIBADALANG.PROJECT_PROVIDER.PARTITION] Part 1: + [LIBADALANG.PROJECT_PROVIDER.PARTITION] Part 2: * P1 P2 * P3