Avoid breaking change on Libadalang.Auto_Provider.Get_Unit and Libadalang.Project_Provider.Get_Unit
Nobody has claimed this yet.
- Dominant language
- Ada
- Stars
- 171
- Forks
- 48
- PR merge metrics
- No merged PRs in 30d
Description
Integrating libadalang 25.0.0 from libadalang 23.0.0
Calls to Libadalang.Auto_Provider.Get_Unit and Libadalang.Project_Provider.Get_Unit explicitly raise Program_Error exception.
Previously, developer was able to get a unit through the call
declare
Unit : constant Libadalang.Analysis.Analysis_Unit'Class := LAL_Auto_Unit_Provider.Get_Unit
(Context => LAL_Context,
Name => Name,
Kind => Kind);
within the context below
declare
LAL_Auto_Unit_Provider : Libadalang.Auto_Provider.Auto_Unit_Provider;
LAL_Context : Libadalang.Analysis.Analysis_Context;
begin
LAL_Auto_Unit_Provider := Libadalang.Auto_Provider.Create_Auto_Provider (Input_Files => Files);
Unit_Provider_Ref := LAL_Auto_Unit_Provider.Create_Unit_Provider_Reference;
LAL_Context := Libadalang.Analysis.Create_Context (Unit_Provider => Unit_Provider_Ref);
This breaking change is related to the implementation of "PLE root" Langkit mechanism (Commit 1ab5c03 [1])
In order to maintain compatibility, Libadalang.Auto_Provider.Get_Unit and Libadalang.Project_Provider.Get_Unit could simply call the class underlying Get_Unit_And_PLE_Root, with the additional parameters Unit and PLE_Root_Index declared in the Get_Unit function scope, as proposed below instead of explicitly raising a Program_Error exception
overriding function Get_Unit
(Provider : Auto_Unit_Provider;
Context : Analysis_Context'Class;
Name : Text_Type;
Kind : Analysis_Unit_Kind;
Charset : String := "";
Reparse : Boolean := False) return Analysis_Unit'Class
is
Unit : Analysis_Unit := No_Analysis_Unit;
PLE_Root_Index : Natural := 0;
begin
Provider.Get_Unit_And_PLE_Root
(Context => Context,
Name => Name,
Kind => Kind,
Charset => Charset,
Reparse => Reparse,
Unit => Unit,
PLE_Root_Index => PLE_Root_Index);
return Unit;
end Get_Unit;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Libadalang.Auto_Provider.Get_Unit and Libadalang.Project_Provider.Get_Unit, then inspect the underlying Get_Unit_And_PLE_Root implementation introduced by commit 1ab5c03. Confirm how the Unit and PLE_Root_Index outputs are handled. Done means both public Get_Unit calls preserve the previous behavior instead of explicitly raising Program_Error.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100