diff --git a/extensions/src/libadalang-gpr_utils.adb b/extensions/src/libadalang-gpr_utils.adb index 931aad340..7baf74afd 100644 --- a/extensions/src/libadalang-gpr_utils.adb +++ b/extensions/src/libadalang-gpr_utils.adb @@ -745,63 +745,4 @@ package body Libadalang.GPR_Utils is return Result; end Closure; - ----------------------- - -- Unit_Location_For -- - ----------------------- - - function Unit_Location_For - (Self : GPR2.Project.View.Object; - Name : String; - Kind : Analysis_Unit_Kind) - return GPR2.Build.Compilation_Unit.Unit_Location - is - use type GPR2.Name_Type; - - Req_Name : constant GPR2.Name_Type := GPR2.Name_Type (Name); - Unit : constant GPR2.Build.Compilation_Unit.Object := - Self.Unit (Req_Name); - begin - if Unit.Is_Defined then - - -- If we got a unit, but not the one we requested, we are likely - -- requesting a subunit: in that case, extract the subunit name and - -- request it separately. - - if Req_Name = Unit.Name then - case Kind is - when Unit_Specification => - if Unit.Has_Part (GPR2.S_Spec) then - return Unit.Spec; - end if; - when Unit_Body => - if Unit.Has_Part (GPR2.S_Body) then - return Unit.Main_Body; - end if; - end case; - - else - pragma Assert (Kind = Unit_Body); - declare - -- Requested unit name is "[ROOT].[SEP]", the name of the unit - -- we got is "[ROOT]": skip it plus the "dot" to extract only - -- the "[SEP]" part. - - Prefix_Last : constant Positive := - Req_Name'First + Unit.Name'Length; - - pragma Assert - (Req_Name (Req_Name'First .. Prefix_Last) - = GPR2."&" (Unit.Name, ".")); - Subunit_Name : constant GPR2.Name_Type := - Req_Name (Prefix_Last + 1 .. Req_Name'Last); - begin - return - Unit.Get (GPR2.S_Separate, Subunit_Name); - end; - end if; - end if; - - return GPR2.Build.Compilation_Unit.No_Unit; - end Unit_Location_For; - end Libadalang.GPR_Utils; diff --git a/extensions/src/libadalang-gpr_utils.ads b/extensions/src/libadalang-gpr_utils.ads index a6b292f92..451d67353 100644 --- a/extensions/src/libadalang-gpr_utils.ads +++ b/extensions/src/libadalang-gpr_utils.ads @@ -11,14 +11,11 @@ with Ada.Containers.Vectors; with GNATCOLL.File_Paths; use GNATCOLL.File_Paths; with GNATCOLL.Projects; with GNATCOLL.Strings; use GNATCOLL.Strings; -with GPR2.Build.Compilation_Unit; with GPR2.Project.Registry.Attribute; with GPR2.Project.Tree; with GPR2.Project.View; with GPR2.Project.View.Vector; -with Libadalang.Common; use Libadalang.Common; - private package Libadalang.GPR_Utils is package GPR1 renames GNATCOLL.Projects; @@ -206,15 +203,4 @@ private package Libadalang.GPR_Utils is (Self : GPR2.Project.View.Object) return GPR2.Project.View.Vector.Object; -- Return the list of all views reachable from ``Self``, self included - function Unit_Location_For - (Self : GPR2.Project.View.Object; - Name : String; - Kind : Analysis_Unit_Kind) - return GPR2.Build.Compilation_Unit.Unit_Location; - -- Look in ``Self`` for the location of the ``Name``/``Kind`` unit and - -- return it. Return ``No_Unit`` if it is not found. - -- - -- TODO??? (eng/gpr/gpr-issues#338) Remove this function once an equivalent - -- one is included in LibGPR2. - end Libadalang.GPR_Utils; diff --git a/extensions/src/libadalang-project_provider.adb b/extensions/src/libadalang-project_provider.adb index 0f149cc70..16ca8e25b 100644 --- a/extensions/src/libadalang-project_provider.adb +++ b/extensions/src/libadalang-project_provider.adb @@ -781,7 +781,9 @@ package body Libadalang.Project_Provider is use type GPR2.Unit_Index; Unit : constant GPR2.Build.Compilation_Unit.Unit_Location := - Unit_Location_For (View.GPR2_Value, Str_Name, Kind); + View.GPR2_Value.Unit_Part + (Name => GPR2.Name_Type (Str_Name), + Is_Spec => Kind = Unit_Specification); begin if Unit /= GPR2.Build.Compilation_Unit.No_Unit then