@@ -33,7 +33,6 @@ with VSS.JSON.Streams;
33
33
34
34
with Libadalang.Analysis ;
35
35
with Libadalang.Common ;
36
- with Libadalang.Helpers ;
37
36
38
37
with Laltools.Common ;
39
38
with Laltools.Partial_GNATPP ;
@@ -167,6 +166,11 @@ package body LSP.Ada_Handlers is
167
166
Position : LSP.Structures.TextDocumentPositionParams'Class)
168
167
return Libadalang.Analysis.Defining_Name;
169
168
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
+
170
174
-- ---------------------------
171
175
-- Allocate_Progress_Token --
172
176
-- ---------------------------
@@ -786,13 +790,14 @@ package body LSP.Ada_Handlers is
786
790
use LAL_Refactor.Auto_Import;
787
791
use LSP.Structures;
788
792
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
+
789
798
Single_Location : constant Boolean :=
790
799
Value.a_range.start = Value.a_range.an_end;
791
800
792
- Units_Vector : Libadalang.Helpers.Unit_Vectors.Vector;
793
- Units_Array : constant Analysis_Unit_Array :=
794
- Context.Analysis_Units;
795
-
796
801
Name : Libadalang.Analysis.Name := No_Name;
797
802
Import_Suggestions : Import_Type_Ordered_Set;
798
803
@@ -801,30 +806,13 @@ package body LSP.Ada_Handlers is
801
806
return ;
802
807
end if ;
803
808
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
-
822
809
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)
828
816
then
829
817
return ;
830
818
end if ;
@@ -4587,6 +4575,31 @@ package body LSP.Ada_Handlers is
4587
4575
Self.Sender.On_Definition_Response (Id, Response);
4588
4576
end On_TypeDefinition_Request ;
4589
4577
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
+
4590
4603
-- -----------------------
4591
4604
-- Publish_Diagnostics --
4592
4605
-- -----------------------
0 commit comments