@@ -33,7 +33,6 @@ with VSS.JSON.Streams;
3333
3434with Libadalang.Analysis ;
3535with Libadalang.Common ;
36- with Libadalang.Helpers ;
3736
3837with Laltools.Common ;
3938with Laltools.Partial_GNATPP ;
@@ -167,6 +166,11 @@ package body LSP.Ada_Handlers is
167166 Position : LSP.Structures.TextDocumentPositionParams'Class)
168167 return Libadalang.Analysis.Defining_Name;
169168
169+ function Project_Predefined_Units
170+ (Self : in out Message_Handler;
171+ Context : LSP.Ada_Contexts.Context)
172+ return Libadalang.Analysis.Analysis_Unit_Array;
173+
170174 -- ---------------------------
171175 -- Allocate_Progress_Token --
172176 -- ---------------------------
@@ -786,13 +790,14 @@ package body LSP.Ada_Handlers is
786790 use LAL_Refactor.Auto_Import;
787791 use LSP.Structures;
788792
793+ function Units_Provider return Analysis_Unit_Array is
794+ (Self.Project_Predefined_Units (Context.all )
795+ & Context.Analysis_Units);
796+ -- Concatenates user units with predefined units
797+
789798 Single_Location : constant Boolean :=
790799 Value.a_range.start = Value.a_range.an_end;
791800
792- Units_Vector : Libadalang.Helpers.Unit_Vectors.Vector;
793- Units_Array : constant Analysis_Unit_Array :=
794- Context.Analysis_Units;
795-
796801 Name : Libadalang.Analysis.Name := No_Name;
797802 Import_Suggestions : Import_Type_Ordered_Set;
798803
@@ -801,30 +806,13 @@ package body LSP.Ada_Handlers is
801806 return ;
802807 end if ;
803808
804- for Unit of Units_Array loop
805- Units_Vector.Append (Unit);
806- end loop ;
807-
808- for F in Self.Project_Predefined_Sources.Iterate loop
809- declare
810- VF : GNATCOLL.VFS.Virtual_File renames
811- LSP.Ada_File_Sets.File_Sets.Element (F);
812- begin
813- Units_Vector.Append
814- (Context.LAL_Context.Get_From_File
815- (VF.Display_Full_Name,
816- -- ??? What is the charset for predefined
817- -- files?
818- " " ));
819- end ;
820- end loop ;
821-
822809 if not Is_Auto_Import_Available
823- (Node.Unit,
824- Document.To_Source_Location (Value.a_range.start),
825- Units_Vector,
826- Name,
827- Import_Suggestions)
810+ (Unit => Node.Unit,
811+ Location =>
812+ Document.To_Source_Location (Value.a_range.start),
813+ Units => Units_Provider'Access ,
814+ Name => Name,
815+ Available_Imports => Import_Suggestions)
828816 then
829817 return ;
830818 end if ;
@@ -4587,6 +4575,31 @@ package body LSP.Ada_Handlers is
45874575 Self.Sender.On_Definition_Response (Id, Response);
45884576 end On_TypeDefinition_Request ;
45894577
4578+ -- ----------------------------
4579+ -- Project_Predefined_Units --
4580+ -- ----------------------------
4581+
4582+ function Project_Predefined_Units
4583+ (Self : in out Message_Handler;
4584+ Context : LSP.Ada_Contexts.Context)
4585+ return Libadalang.Analysis.Analysis_Unit_Array
4586+ is
4587+ use Libadalang.Analysis;
4588+
4589+ Units_Count : constant Natural :=
4590+ Self.Project_Predefined_Sources.Length;
4591+ Predefined_Units : Analysis_Unit_Array (1 .. Units_Count);
4592+ Index : Natural := Predefined_Units'First;
4593+
4594+ begin
4595+ for Source in Self.Project_Predefined_Sources.Iterate loop
4596+ Predefined_Units (Index) :=
4597+ Context.Get_AU (LSP.Ada_File_Sets.File_Sets.Element (Source));
4598+ Index := @ + 1 ;
4599+ end loop ;
4600+ return Predefined_Units;
4601+ end Project_Predefined_Units ;
4602+
45904603 -- -----------------------
45914604 -- Publish_Diagnostics --
45924605 -- -----------------------
0 commit comments