11-- ----------------------------------------------------------------------------
22-- Language Server Protocol --
33-- --
4- -- Copyright (C) 2018-2023 , AdaCore --
4+ -- Copyright (C) 2018-2024 , AdaCore --
55-- --
66-- This is free software; you can redistribute it and/or modify it under --
77-- terms of the GNU General Public License as published by the Free Soft- --
@@ -140,7 +140,7 @@ package body LSP.Ada_Handlers is
140140 Id : LSP.Structures.Integer_Or_Virtual_String;
141141 Context : LSP.Ada_Contexts.Context;
142142 Name_Node : Libadalang.Analysis.Name;
143- Imprecise : out Boolean )
143+ Imprecise : out Libadalang.Common.Ref_Result_Kind )
144144 return Libadalang.Analysis.Defining_Name;
145145 -- Toplayer Resolve_Name based on Laltools.Common.Resolve_Name.
146146 -- This function is handling Imprecise and Error results during Nameres by
@@ -1737,7 +1737,8 @@ package body LSP.Ada_Handlers is
17371737 On_Defining_Name : Boolean := False;
17381738 -- Set to True if we are on a denfining name node
17391739
1740- Imprecise : Boolean;
1740+ Imprecise_Ignore : Libadalang.Common.Ref_Result_Kind;
1741+
17411742 begin
17421743 if Name_Node.Is_Null then
17431744 return ;
@@ -1754,7 +1755,7 @@ package body LSP.Ada_Handlers is
17541755 Id => Id,
17551756 Context => C.all ,
17561757 Name_Node => Name_Node,
1757- Imprecise => Imprecise );
1758+ Imprecise => Imprecise_Ignore );
17581759 else
17591760 On_Defining_Name := True;
17601761 end if ;
@@ -1806,16 +1807,15 @@ package body LSP.Ada_Handlers is
18061807
18071808 if not Decl_For_Find_Overrides.Is_Null then
18081809 declare
1809- Is_Imprecise : Boolean;
18101810 Overridings : constant Libadalang.Analysis.Basic_Decl_Array :=
18111811 C.Find_All_Overrides
18121812 (Decl_For_Find_Overrides,
1813- Imprecise_Results => Is_Imprecise );
1813+ Imprecise_Results => Imprecise_Ignore );
18141814
18151815 Bases : constant Libadalang.Analysis.Basic_Decl_Array :=
18161816 C.Find_All_Base_Declarations
18171817 (Decl_For_Find_Overrides,
1818- Imprecise_Results => Is_Imprecise );
1818+ Imprecise_Results => Imprecise_Ignore );
18191819 begin
18201820 for Subp of Bases loop
18211821 Self.Append_Location
@@ -2742,9 +2742,11 @@ package body LSP.Ada_Handlers is
27422742 end Update_Response ;
27432743
27442744 Definition : Libadalang.Analysis.Defining_Name;
2745- Imprecise : Boolean := False;
27462745 Decl : Libadalang.Analysis.Basic_Decl;
27472746
2747+ Imprecise_Ignore : Libadalang.Common.Ref_Result_Kind :=
2748+ Libadalang.Common.No_Ref;
2749+
27482750 begin
27492751 if Name_Node.Is_Null then
27502752 return ;
@@ -2755,7 +2757,7 @@ package body LSP.Ada_Handlers is
27552757 Id => Id,
27562758 Context => C.all ,
27572759 Name_Node => Name_Node,
2758- Imprecise => Imprecise );
2760+ Imprecise => Imprecise_Ignore );
27592761
27602762 -- If we didn't find a definition, give up for this context
27612763 if Definition.Is_Null then
@@ -2764,7 +2766,8 @@ package body LSP.Ada_Handlers is
27642766
27652767 -- First list the bodies of this definition
27662768 Update_Response
2767- (Laltools.Common.List_Bodies_Of (Definition, Trace, Imprecise),
2769+ (Laltools.Common.List_Bodies_Of
2770+ (Definition, Trace, Imprecise_Ignore),
27682771 LSP.Constants.Empty);
27692772
27702773 -- Then list the bodies of the parent implementations
@@ -2777,19 +2780,19 @@ package body LSP.Ada_Handlers is
27772780 (Display_Method_Policy = Usage_And_Abstract_Only
27782781 and then Decl.Kind in Ada_Abstract_Subp_Decl_Range)
27792782 then
2780- for Subp of C.Find_All_Base_Declarations (Decl, Imprecise )
2783+ for Subp of C.Find_All_Base_Declarations (Decl, Imprecise_Ignore )
27812784 loop
27822785 Update_Response
27832786 (Laltools.Common.List_Bodies_Of
2784- (Subp.P_Defining_Name, Trace, Imprecise ),
2787+ (Subp.P_Defining_Name, Trace, Imprecise_Ignore ),
27852788 Is_Parent);
27862789 end loop ;
27872790
27882791 -- 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
27902793 Update_Response
27912794 (Laltools.Common.List_Bodies_Of
2792- (Subp.P_Defining_Name, Trace, Imprecise ),
2795+ (Subp.P_Defining_Name, Trace, Imprecise_Ignore ),
27932796 Is_Child);
27942797 end loop ;
27952798 end if ;
@@ -3310,7 +3313,11 @@ package body LSP.Ada_Handlers is
33103313
33113314 Defining_Name : Libadalang.Analysis.Defining_Name;
33123315
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+
33143321 begin
33153322 if not Name_Node.Is_Null then
33163323 Defining_Name := Resolve_Name
@@ -3323,7 +3330,7 @@ package body LSP.Ada_Handlers is
33233330
33243331 if not Name_Node.Is_Null
33253332 and then not Defining_Name.Is_Null
3326- and then not Imprecise
3333+ and then Imprecise in Libadalang.Common.Precise
33273334 then
33283335 -- Success only if the node is a name and can be resolved precisely
33293336 Response :=
@@ -3923,7 +3930,9 @@ package body LSP.Ada_Handlers is
39233930 Response : LSP.Structures.Definition_Result (LSP.Structures.Variant_1);
39243931 Vector : LSP.Structures.Location_Vector renames Response.Variant_1;
39253932 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;
39273936
39283937 procedure Resolve_In_Context (C : LSP.Ada_Context_Sets.Context_Access);
39293938 -- Utility function to gather results on one context
@@ -3960,7 +3969,7 @@ package body LSP.Ada_Handlers is
39603969 Id => Id,
39613970 Context => C.all ,
39623971 Name_Node => Type_Expr.P_Type_Name,
3963- Imprecise => Imprecise );
3972+ Imprecise => Imprecise_Ignore );
39643973 end if ;
39653974 end ;
39663975 else
@@ -4064,19 +4073,18 @@ package body LSP.Ada_Handlers is
40644073 Id : LSP.Structures.Integer_Or_Virtual_String;
40654074 Context : LSP.Ada_Contexts.Context;
40664075 Name_Node : Libadalang.Analysis.Name;
4067- Imprecise : out Boolean )
4076+ Imprecise : out Libadalang.Common.Ref_Result_Kind )
40684077 return Libadalang.Analysis.Defining_Name
40694078 is
40704079 Definition : Libadalang.Analysis.Defining_Name;
4071- Result_Kind : Libadalang.Common.Ref_Result_Kind;
40724080 Trace : constant GNATCOLL.Traces.Trace_Handle :=
40734081 LSP.GNATCOLL_Tracers.Handle (Self.Tracer.all );
40744082 Id_Image : constant String :=
40754083 (if Id.Is_Integer
40764084 then Id.Integer'Image
40774085 else VSS.Strings.Conversions.To_UTF_8_String (Id.Virtual_String));
40784086 begin
4079- Imprecise := False ;
4087+ Imprecise := Libadalang.Common.No_Ref ;
40804088
40814089 if Name_Node.Is_Null then
40824090 -- Internal tracing of resolve on null node
@@ -4086,9 +4094,9 @@ package body LSP.Ada_Handlers is
40864094
40874095 -- Find the definition
40884096 Definition := Laltools.Common.Resolve_Name
4089- (Name_Node, Trace, Result_Kind );
4097+ (Name_Node, Trace, Imprecise );
40904098
4091- if Result_Kind in Libadalang.Common.Error then
4099+ if Imprecise in Libadalang.Common.Error then
40924100 declare
40934101 Err_Msg : constant String :=
40944102 " Failed to resolve " & Name_Node.Image;
@@ -4138,7 +4146,7 @@ package body LSP.Ada_Handlers is
41384146 return Libadalang.Analysis.No_Defining_Name;
41394147 end ;
41404148
4141- elsif Result_Kind in Libadalang.Common.Imprecise then
4149+ elsif Imprecise in Libadalang.Common.Imprecise then
41424150 -- Internal tracing of imprecise resolving
41434151 Self.Tracer.Trace
41444152 (" Imprecise result when resolving "
@@ -4147,7 +4155,6 @@ package body LSP.Ada_Handlers is
41474155 & VSS.Strings.Conversions.To_UTF_8_String (Context.Id)
41484156 & " for request "
41494157 & Id_Image);
4150- Imprecise := True;
41514158 end if ;
41524159
41534160 return Definition;
0 commit comments