1
1
-- ----------------------------------------------------------------------------
2
2
-- Language Server Protocol --
3
3
-- --
4
- -- Copyright (C) 2018-2023 , AdaCore --
4
+ -- Copyright (C) 2018-2024 , AdaCore --
5
5
-- --
6
6
-- This is free software; you can redistribute it and/or modify it under --
7
7
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -140,7 +140,7 @@ package body LSP.Ada_Handlers is
140
140
Id : LSP.Structures.Integer_Or_Virtual_String;
141
141
Context : LSP.Ada_Contexts.Context;
142
142
Name_Node : Libadalang.Analysis.Name;
143
- Imprecise : out Boolean )
143
+ Imprecise : out Libadalang.Common.Ref_Result_Kind )
144
144
return Libadalang.Analysis.Defining_Name;
145
145
-- Toplayer Resolve_Name based on Laltools.Common.Resolve_Name.
146
146
-- This function is handling Imprecise and Error results during Nameres by
@@ -1737,7 +1737,8 @@ package body LSP.Ada_Handlers is
1737
1737
On_Defining_Name : Boolean := False;
1738
1738
-- Set to True if we are on a denfining name node
1739
1739
1740
- Imprecise : Boolean;
1740
+ Imprecise_Ignore : Libadalang.Common.Ref_Result_Kind;
1741
+
1741
1742
begin
1742
1743
if Name_Node.Is_Null then
1743
1744
return ;
@@ -1754,7 +1755,7 @@ package body LSP.Ada_Handlers is
1754
1755
Id => Id,
1755
1756
Context => C.all ,
1756
1757
Name_Node => Name_Node,
1757
- Imprecise => Imprecise );
1758
+ Imprecise => Imprecise_Ignore );
1758
1759
else
1759
1760
On_Defining_Name := True;
1760
1761
end if ;
@@ -1806,16 +1807,15 @@ package body LSP.Ada_Handlers is
1806
1807
1807
1808
if not Decl_For_Find_Overrides.Is_Null then
1808
1809
declare
1809
- Is_Imprecise : Boolean;
1810
1810
Overridings : constant Libadalang.Analysis.Basic_Decl_Array :=
1811
1811
C.Find_All_Overrides
1812
1812
(Decl_For_Find_Overrides,
1813
- Imprecise_Results => Is_Imprecise );
1813
+ Imprecise_Results => Imprecise_Ignore );
1814
1814
1815
1815
Bases : constant Libadalang.Analysis.Basic_Decl_Array :=
1816
1816
C.Find_All_Base_Declarations
1817
1817
(Decl_For_Find_Overrides,
1818
- Imprecise_Results => Is_Imprecise );
1818
+ Imprecise_Results => Imprecise_Ignore );
1819
1819
begin
1820
1820
for Subp of Bases loop
1821
1821
Self.Append_Location
@@ -2742,9 +2742,11 @@ package body LSP.Ada_Handlers is
2742
2742
end Update_Response ;
2743
2743
2744
2744
Definition : Libadalang.Analysis.Defining_Name;
2745
- Imprecise : Boolean := False;
2746
2745
Decl : Libadalang.Analysis.Basic_Decl;
2747
2746
2747
+ Imprecise_Ignore : Libadalang.Common.Ref_Result_Kind :=
2748
+ Libadalang.Common.No_Ref;
2749
+
2748
2750
begin
2749
2751
if Name_Node.Is_Null then
2750
2752
return ;
@@ -2755,7 +2757,7 @@ package body LSP.Ada_Handlers is
2755
2757
Id => Id,
2756
2758
Context => C.all ,
2757
2759
Name_Node => Name_Node,
2758
- Imprecise => Imprecise );
2760
+ Imprecise => Imprecise_Ignore );
2759
2761
2760
2762
-- If we didn't find a definition, give up for this context
2761
2763
if Definition.Is_Null then
@@ -2764,7 +2766,8 @@ package body LSP.Ada_Handlers is
2764
2766
2765
2767
-- First list the bodies of this definition
2766
2768
Update_Response
2767
- (Laltools.Common.List_Bodies_Of (Definition, Trace, Imprecise),
2769
+ (Laltools.Common.List_Bodies_Of
2770
+ (Definition, Trace, Imprecise_Ignore),
2768
2771
LSP.Constants.Empty);
2769
2772
2770
2773
-- Then list the bodies of the parent implementations
@@ -2777,19 +2780,19 @@ package body LSP.Ada_Handlers is
2777
2780
(Display_Method_Policy = Usage_And_Abstract_Only
2778
2781
and then Decl.Kind in Ada_Abstract_Subp_Decl_Range)
2779
2782
then
2780
- for Subp of C.Find_All_Base_Declarations (Decl, Imprecise )
2783
+ for Subp of C.Find_All_Base_Declarations (Decl, Imprecise_Ignore )
2781
2784
loop
2782
2785
Update_Response
2783
2786
(Laltools.Common.List_Bodies_Of
2784
- (Subp.P_Defining_Name, Trace, Imprecise ),
2787
+ (Subp.P_Defining_Name, Trace, Imprecise_Ignore ),
2785
2788
Is_Parent);
2786
2789
end loop ;
2787
2790
2788
2791
-- And finally the bodies of child implementations
2789
- for Subp of C.Find_All_Overrides (Decl, Imprecise ) loop
2792
+ for Subp of C.Find_All_Overrides (Decl, Imprecise_Ignore ) loop
2790
2793
Update_Response
2791
2794
(Laltools.Common.List_Bodies_Of
2792
- (Subp.P_Defining_Name, Trace, Imprecise ),
2795
+ (Subp.P_Defining_Name, Trace, Imprecise_Ignore ),
2793
2796
Is_Child);
2794
2797
end loop ;
2795
2798
end if ;
@@ -3310,7 +3313,11 @@ package body LSP.Ada_Handlers is
3310
3313
3311
3314
Defining_Name : Libadalang.Analysis.Defining_Name;
3312
3315
3313
- Imprecise : Boolean := False;
3316
+ Imprecise : Libadalang.Common.Ref_Result_Kind :=
3317
+ Libadalang.Common.No_Ref;
3318
+
3319
+ use type Libadalang.Common.Ref_Result_Kind;
3320
+
3314
3321
begin
3315
3322
if not Name_Node.Is_Null then
3316
3323
Defining_Name := Resolve_Name
@@ -3323,7 +3330,7 @@ package body LSP.Ada_Handlers is
3323
3330
3324
3331
if not Name_Node.Is_Null
3325
3332
and then not Defining_Name.Is_Null
3326
- and then not Imprecise
3333
+ and then Imprecise in Libadalang.Common.Precise
3327
3334
then
3328
3335
-- Success only if the node is a name and can be resolved precisely
3329
3336
Response :=
@@ -3923,7 +3930,9 @@ package body LSP.Ada_Handlers is
3923
3930
Response : LSP.Structures.Definition_Result (LSP.Structures.Variant_1);
3924
3931
Vector : LSP.Structures.Location_Vector renames Response.Variant_1;
3925
3932
Filter : LSP.Locations.File_Span_Sets.Set;
3926
- Imprecise : Boolean := False;
3933
+
3934
+ Imprecise_Ignore : Libadalang.Common.Ref_Result_Kind :=
3935
+ Libadalang.Common.No_Ref;
3927
3936
3928
3937
procedure Resolve_In_Context (C : LSP.Ada_Context_Sets.Context_Access);
3929
3938
-- Utility function to gather results on one context
@@ -3960,7 +3969,7 @@ package body LSP.Ada_Handlers is
3960
3969
Id => Id,
3961
3970
Context => C.all ,
3962
3971
Name_Node => Type_Expr.P_Type_Name,
3963
- Imprecise => Imprecise );
3972
+ Imprecise => Imprecise_Ignore );
3964
3973
end if ;
3965
3974
end ;
3966
3975
else
@@ -4064,19 +4073,18 @@ package body LSP.Ada_Handlers is
4064
4073
Id : LSP.Structures.Integer_Or_Virtual_String;
4065
4074
Context : LSP.Ada_Contexts.Context;
4066
4075
Name_Node : Libadalang.Analysis.Name;
4067
- Imprecise : out Boolean )
4076
+ Imprecise : out Libadalang.Common.Ref_Result_Kind )
4068
4077
return Libadalang.Analysis.Defining_Name
4069
4078
is
4070
4079
Definition : Libadalang.Analysis.Defining_Name;
4071
- Result_Kind : Libadalang.Common.Ref_Result_Kind;
4072
4080
Trace : constant GNATCOLL.Traces.Trace_Handle :=
4073
4081
LSP.GNATCOLL_Tracers.Handle (Self.Tracer.all );
4074
4082
Id_Image : constant String :=
4075
4083
(if Id.Is_Integer
4076
4084
then Id.Integer'Image
4077
4085
else VSS.Strings.Conversions.To_UTF_8_String (Id.Virtual_String));
4078
4086
begin
4079
- Imprecise := False ;
4087
+ Imprecise := Libadalang.Common.No_Ref ;
4080
4088
4081
4089
if Name_Node.Is_Null then
4082
4090
-- Internal tracing of resolve on null node
@@ -4086,9 +4094,9 @@ package body LSP.Ada_Handlers is
4086
4094
4087
4095
-- Find the definition
4088
4096
Definition := Laltools.Common.Resolve_Name
4089
- (Name_Node, Trace, Result_Kind );
4097
+ (Name_Node, Trace, Imprecise );
4090
4098
4091
- if Result_Kind in Libadalang.Common.Error then
4099
+ if Imprecise in Libadalang.Common.Error then
4092
4100
declare
4093
4101
Err_Msg : constant String :=
4094
4102
" Failed to resolve " & Name_Node.Image;
@@ -4138,7 +4146,7 @@ package body LSP.Ada_Handlers is
4138
4146
return Libadalang.Analysis.No_Defining_Name;
4139
4147
end ;
4140
4148
4141
- elsif Result_Kind in Libadalang.Common.Imprecise then
4149
+ elsif Imprecise in Libadalang.Common.Imprecise then
4142
4150
-- Internal tracing of imprecise resolving
4143
4151
Self.Tracer.Trace
4144
4152
(" Imprecise result when resolving "
@@ -4147,7 +4155,6 @@ package body LSP.Ada_Handlers is
4147
4155
& VSS.Strings.Conversions.To_UTF_8_String (Context.Id)
4148
4156
& " for request "
4149
4157
& Id_Image);
4150
- Imprecise := True;
4151
4158
end if ;
4152
4159
4153
4160
return Definition;
0 commit comments