From be6d1424049df6a0fc505000dda11cdf98fcdf5c Mon Sep 17 00:00:00 2001 From: Anthony Leonardo Gracio Date: Thu, 25 Apr 2024 09:30:21 +0000 Subject: [PATCH] Revert edge on master To avoid conflicts in the future. For eng/shared/automatic-merges#222 --- source/ada/lsp-ada_contexts.adb | 88 ++++++------- source/ada/lsp-ada_contexts.ads | 24 ++-- source/ada/lsp-ada_declaration.adb | 22 +--- source/ada/lsp-ada_definition.adb | 15 +-- .../ada/lsp-ada_handlers-call_hierarchy.adb | 8 +- source/ada/lsp-ada_handlers-renaming.adb | 18 +-- source/ada/lsp-ada_handlers.adb | 122 +++++++++--------- source/ada/lsp-ada_references.adb | 3 +- 8 files changed, 133 insertions(+), 167 deletions(-) diff --git a/source/ada/lsp-ada_contexts.adb b/source/ada/lsp-ada_contexts.adb index c181d355f..3432915e6 100644 --- a/source/ada/lsp-ada_contexts.adb +++ b/source/ada/lsp-ada_contexts.adb @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ -- Language Server Protocol -- -- -- --- Copyright (C) 2018-2024, AdaCore -- +-- Copyright (C) 2018-2022, AdaCore -- -- -- -- This is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -78,10 +78,10 @@ package body LSP.Ada_Contexts is -- Return the charset with which the context was initialized procedure Find_All_References_In_Hierarchy - (Self : Context; - Decl : Libadalang.Analysis.Basic_Decl; - Result_Kind : in out Libadalang.Common.Ref_Result_Kind; - Callback : not null access procedure + (Self : Context; + Decl : Libadalang.Analysis.Basic_Decl; + Imprecise : in out Boolean; + Callback : not null access procedure (Base_Id : Libadalang.Analysis.Base_Id; Kind : Libadalang.Common.Ref_Result_Kind; Cancel : in out Boolean)); @@ -208,15 +208,15 @@ package body LSP.Ada_Contexts is ------------------------ function Find_All_Overrides - (Self : Context; - Decl : Libadalang.Analysis.Basic_Decl; - Result_Kind : out Libadalang.Common.Ref_Result_Kind) + (Self : Context; + Decl : Libadalang.Analysis.Basic_Decl; + Imprecise_Results : out Boolean) return Libadalang.Analysis.Basic_Decl_Array is Units : constant Libadalang.Analysis.Analysis_Unit_Array := Self.Analysis_Units; begin - Result_Kind := Libadalang.Common.Precise; + Imprecise_Results := False; if Decl.Is_Null then return (1 .. 0 => <>); @@ -228,14 +228,13 @@ package body LSP.Ada_Contexts is return Decl.P_Find_All_Overrides (Units); exception when E : Libadalang.Common.Property_Error => - Result_Kind := Libadalang.Common.Imprecise; + Imprecise_Results := True; Self.Tracer.Trace_Exception (E, "in Find_All_Overrides (precise)"); return Decl.P_Find_All_Overrides (Units, Imprecise_Fallback => True); end; exception when E : Libadalang.Common.Property_Error => - Result_Kind := Libadalang.Common.Error; Self.Tracer.Trace_Exception (E, "in Find_All_Overrides (imprecise)"); return (1 .. 0 => <>); end Find_All_Overrides; @@ -245,9 +244,9 @@ package body LSP.Ada_Contexts is -------------------------------- function Find_All_Base_Declarations - (Self : Context; - Decl : Libadalang.Analysis.Basic_Decl; - Result_Kind : out Libadalang.Common.Ref_Result_Kind) + (Self : Context; + Decl : Libadalang.Analysis.Basic_Decl; + Imprecise_Results : out Boolean) return Libadalang.Analysis.Basic_Decl_Array is use Libadalang.Analysis; @@ -260,7 +259,7 @@ package body LSP.Ada_Contexts is Langkit_Support.Slocs.Start_Sloc (Left.Sloc_Range) = Langkit_Support.Slocs.Start_Sloc (Right.Sloc_Range)); begin - Result_Kind := Libadalang.Common.Precise; + Imprecise_Results := False; if Decl.Is_Null then return (1 .. 0 => <>); @@ -294,7 +293,7 @@ package body LSP.Ada_Contexts is exception when E : Libadalang.Common.Property_Error => Self.Tracer.Trace_Exception (E, "in Find_All_Base_Declarations"); - Result_Kind := Libadalang.Common.Error; + Imprecise_Results := True; return (1 .. 0 => <>); end Find_All_Base_Declarations; @@ -303,10 +302,10 @@ package body LSP.Ada_Contexts is -------------------------------------- procedure Find_All_References_In_Hierarchy - (Self : Context; - Decl : Libadalang.Analysis.Basic_Decl; - Result_Kind : in out Libadalang.Common.Ref_Result_Kind; - Callback : not null access procedure + (Self : Context; + Decl : Libadalang.Analysis.Basic_Decl; + Imprecise : in out Boolean; + Callback : not null access procedure (Base_Id : Libadalang.Analysis.Base_Id; Kind : Libadalang.Common.Ref_Result_Kind; Cancel : in out Boolean)) @@ -324,44 +323,31 @@ package body LSP.Ada_Contexts is else Decl); - Overriding_Result_Kind : Libadalang.Common.Ref_Result_Kind; - Bases_Result_Kind : Libadalang.Common.Ref_Result_Kind; - Overriding_Decls : constant Libadalang.Analysis.Basic_Decl_Array := Self.Find_All_Overrides (Subp_Decl, - Result_Kind => Overriding_Result_Kind); + Imprecise_Results => Imprecise); Base_Decls : constant Libadalang.Analysis.Basic_Decl_Array := Self.Find_All_Base_Declarations (Subp_Decl, - Result_Kind => Bases_Result_Kind); + Imprecise_Results => Imprecise); + + Hierarchy : constant Libadalang.Analysis.Basic_Decl_Array := + Overriding_Decls & Base_Decls; begin - if Overriding_Result_Kind in Libadalang.Common.Error - or else Bases_Result_Kind in Libadalang.Common.Error - then - Result_Kind := Libadalang.Common.Error; - return; + if Is_Param then + LSP.Ada_Id_Iterators.Find_All_Param_References_In_Hierarchy + (Param => Decl.As_Param_Spec, + Hierarchy => Hierarchy, + Units => Self.Analysis_Units, + Callback => Callback); + else + LSP.Ada_Id_Iterators.Find_All_Subp_References_In_Hierarchy + (Hierarchy => Hierarchy, + Tracer => Self.Tracer.all, + Callback => Callback); end if; - - declare - Hierarchy : constant Libadalang.Analysis.Basic_Decl_Array := - Overriding_Decls & Base_Decls; - begin - - if Is_Param then - LSP.Ada_Id_Iterators.Find_All_Param_References_In_Hierarchy - (Param => Decl.As_Param_Spec, - Hierarchy => Hierarchy, - Units => Self.Analysis_Units, - Callback => Callback); - else - LSP.Ada_Id_Iterators.Find_All_Subp_References_In_Hierarchy - (Hierarchy => Hierarchy, - Tracer => Self.Tracer.all, - Callback => Callback); - end if; - end; end Find_All_References_In_Hierarchy; -------------------- @@ -383,7 +369,7 @@ package body LSP.Ada_Contexts is procedure Get_References_For_Renaming (Self : Context; Definition : Libadalang.Analysis.Defining_Name; - Imprecise_Results : out Libadalang.Common.Ref_Result_Kind; + Imprecise_Results : out Boolean; Callback : not null access procedure (Base_Id : Libadalang.Analysis.Base_Id; Kind : Libadalang.Common.Ref_Result_Kind; @@ -395,7 +381,7 @@ package body LSP.Ada_Contexts is begin -- Make sure to initialize the "out" variable Imprecise_Results - Imprecise_Results := Libadalang.Common.Precise; + Imprecise_Results := False; if Decl.Is_Null then return; diff --git a/source/ada/lsp-ada_contexts.ads b/source/ada/lsp-ada_contexts.ads index 6b2772523..4a664cee9 100644 --- a/source/ada/lsp-ada_contexts.ads +++ b/source/ada/lsp-ada_contexts.ads @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ -- Language Server Protocol -- -- -- --- Copyright (C) 2018-2014, AdaCore -- +-- Copyright (C) 2018-2019, AdaCore -- -- -- -- This is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -98,26 +98,26 @@ package LSP.Ada_Contexts is -- context. function Find_All_Overrides - (Self : Context; - Decl : Libadalang.Analysis.Basic_Decl; - Result_Kind : out Libadalang.Common.Ref_Result_Kind) + (Self : Context; + Decl : Libadalang.Analysis.Basic_Decl; + Imprecise_Results : out Boolean) return Libadalang.Analysis.Basic_Decl_Array; -- Finds all overriding subprograms of the given basic declaration. -- This is used to propose all the implementations of a given subprogram -- when textDocument/definition requests happen on dispatching calls. - -- Result_Kind indicates if LAL encountered an Error or if the result are - -- Imprecise. + -- Imprecise_Results is set to True if we don't know whether the results + -- are precise. -- Returns an empty array if Decl is null. function Find_All_Base_Declarations - (Self : Context; - Decl : Libadalang.Analysis.Basic_Decl; - Result_Kind : out Libadalang.Common.Ref_Result_Kind) + (Self : Context; + Decl : Libadalang.Analysis.Basic_Decl; + Imprecise_Results : out Boolean) return Libadalang.Analysis.Basic_Decl_Array; -- Given a subprogram declaration in Decl, find all the base subprograms -- that it inherits, not including self. - -- Result_Kind indicates if LAL encountered an Error or if the result are - -- Imprecise. + -- Imprecise_Results is set to True if we don't know whether the results + -- are precise. -- Returns an empty array if Decl is null. procedure Find_All_Calls @@ -145,7 +145,7 @@ package LSP.Ada_Contexts is procedure Get_References_For_Renaming (Self : Context; Definition : Libadalang.Analysis.Defining_Name; - Imprecise_Results : out Libadalang.Common.Ref_Result_Kind; + Imprecise_Results : out Boolean; Callback : not null access procedure (Base_Id : Libadalang.Analysis.Base_Id; Kind : Libadalang.Common.Ref_Result_Kind; diff --git a/source/ada/lsp-ada_declaration.adb b/source/ada/lsp-ada_declaration.adb index 0cc297635..5bc15979b 100644 --- a/source/ada/lsp-ada_declaration.adb +++ b/source/ada/lsp-ada_declaration.adb @@ -139,8 +139,8 @@ package body LSP.Ada_Declaration is On_Defining_Name : Boolean := False; -- Set to True if we are on a denfining name node - Imprecise_Ignore : Boolean; - Result_Kind : Libadalang.Common.Ref_Result_Kind; + Ignore : Boolean; + Dummy : Libadalang.Common.Ref_Result_Kind; begin if Self.Contexts.Is_Empty then -- No more contexts to process, sort and return collected results @@ -173,13 +173,12 @@ package body LSP.Ada_Declaration is if Definition.Is_Null then -- If we aren't on a defining_name already then try to resolve - Definition := Laltools.Common.Resolve_Name - (Name_Node, Trace, Result_Kind); + Definition := Laltools.Common.Resolve_Name (Name_Node, Trace, Dummy); else On_Defining_Name := True; end if; - if Result_Kind in Libadalang.Common.Error or else Definition.Is_Null then + if Definition.Is_Null then return; -- Name resolution fails, nothing to do. end if; @@ -230,25 +229,16 @@ package body LSP.Ada_Declaration is if not Decl_For_Find_Overrides.Is_Null then declare - Overriding_Result_Kind : Libadalang.Common.Ref_Result_Kind; - Bases_Result_Kind : Libadalang.Common.Ref_Result_Kind; Overridings : constant Libadalang.Analysis.Basic_Decl_Array := Context.Find_All_Overrides (Decl_For_Find_Overrides, - Result_Kind => Overriding_Result_Kind); + Imprecise_Results => Ignore); Bases : constant Libadalang.Analysis.Basic_Decl_Array := Context.Find_All_Base_Declarations (Decl_For_Find_Overrides, - Result_Kind => Bases_Result_Kind); + Imprecise_Results => Ignore); begin - if Overriding_Result_Kind in Libadalang.Common.Error - or else Bases_Result_Kind in Libadalang.Common.Error - then - -- Abort - return; - end if; - for Subp of Bases loop Self.Parent.Context.Append_Location (Self.Response, diff --git a/source/ada/lsp-ada_definition.adb b/source/ada/lsp-ada_definition.adb index 9a961b5de..f4786eb6c 100644 --- a/source/ada/lsp-ada_definition.adb +++ b/source/ada/lsp-ada_definition.adb @@ -123,6 +123,8 @@ package body LSP.Ada_Definition is Definition_Node : Libadalang.Analysis.Basic_Decl; Decl_For_Find_Overrides : Libadalang.Analysis.Basic_Decl; Entry_Decl_Node : Libadalang.Analysis.Entry_Decl; + + Ignore : Boolean; begin if Self.Contexts.Is_Empty then -- No more contexts to process, sort and return collected results @@ -236,25 +238,16 @@ package body LSP.Ada_Definition is if not Decl_For_Find_Overrides.Is_Null then declare - Overriding_Result_Kind : Libadalang.Common.Ref_Result_Kind; - Bases_Result_Kind : Libadalang.Common.Ref_Result_Kind; Overridings : constant Libadalang.Analysis.Basic_Decl_Array := Context.Find_All_Overrides (Decl_For_Find_Overrides, - Result_Kind => Overriding_Result_Kind); + Imprecise_Results => Ignore); Bases : constant Libadalang.Analysis.Basic_Decl_Array := Context.Find_All_Base_Declarations (Decl_For_Find_Overrides, - Result_Kind => Bases_Result_Kind); + Imprecise_Results => Ignore); begin - if Overriding_Result_Kind in Libadalang.Common.Error - or else Bases_Result_Kind in Libadalang.Common.Error - then - -- Abort - return; - end if; - for Subp of Bases loop Self.Parent.Context.Append_Location (Self.Response, diff --git a/source/ada/lsp-ada_handlers-call_hierarchy.adb b/source/ada/lsp-ada_handlers-call_hierarchy.adb index a635d4c26..2f3993c62 100644 --- a/source/ada/lsp-ada_handlers-call_hierarchy.adb +++ b/source/ada/lsp-ada_handlers-call_hierarchy.adb @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ -- Language Server Protocol -- -- -- --- Copyright (C) 2018-2024, AdaCore -- +-- Copyright (C) 2018-2023, AdaCore -- -- -- -- This is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -313,16 +313,16 @@ package body LSP.Ada_Handlers.Call_Hierarchy is end if; end Callback; - Imprecise_Ignore : Libadalang.Common.Ref_Result_Kind := + Cursor : Laltools.Common.References_By_Subprogram.Cursor; + Ignore : Libadalang.Common.Ref_Result_Kind := Libadalang.Common.No_Ref; - Cursor : Laltools.Common.References_By_Subprogram.Cursor; begin Laltools.Call_Hierarchy.Find_Outgoing_Calls (Definition => Definition, Callback => Callback'Access, Trace => Trace, - Imprecise => Imprecise_Ignore); + Imprecise => Ignore); Cursor := Result.First; -- Iterate through all the results, converting them to protocol diff --git a/source/ada/lsp-ada_handlers-renaming.adb b/source/ada/lsp-ada_handlers-renaming.adb index b4d2d87d5..538032ed1 100644 --- a/source/ada/lsp-ada_handlers-renaming.adb +++ b/source/ada/lsp-ada_handlers-renaming.adb @@ -16,6 +16,7 @@ ------------------------------------------------------------------------------ with Ada.Strings.Unbounded; +with Ada.Strings.Wide_Wide_Unbounded; with Langkit_Support.Slocs; with Langkit_Support.Text; @@ -187,7 +188,10 @@ package body LSP.Ada_Handlers.Renaming is Set : LAL_Refactor.Text_Edit_Ordered_Set; Token : Token_Reference := Unit.First_Token; - Name : constant Wide_Wide_String := Name_Node.Text; + -- Name : constant Wide_Wide_String := Name_Node.Text; + Name : constant Wide_Wide_String := + Ada.Strings.Wide_Wide_Unbounded.To_Wide_Wide_String + (Laltools.Common.Get_Last_Name (Name_Node)); Text_Edit : LAL_Refactor.Text_Edit; Span : Langkit_Support.Slocs.Source_Location_Range; Current : Token_Reference; @@ -275,11 +279,7 @@ package body LSP.Ada_Handlers.Renaming is begin if Kind (Data (Token)) = Ada_Comment and then Laltools.Common.Contains - (Token => Token, - Pattern => Name, - As_Word => True, - Span => This_Span, - Case_Sensitive => True) + (Token, Name, True, This_Span) then Text_Edit.Location := This_Span; Text_Edit.Text := @@ -290,11 +290,7 @@ package body LSP.Ada_Handlers.Renaming is if Diff /= 0 and then Laltools.Common.Contains - (Token => Token, - Pattern => "-- " & Name & " --", - As_Word => False, - Span => Span, - Case_Sensitive => True) + (Token, "-- " & Name & " --", False, Span) then -- Can be a comment box Current := Previous (Token); diff --git a/source/ada/lsp-ada_handlers.adb b/source/ada/lsp-ada_handlers.adb index 23a1a6a95..c19f9f60c 100644 --- a/source/ada/lsp-ada_handlers.adb +++ b/source/ada/lsp-ada_handlers.adb @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ -- Language Server Protocol -- -- -- --- Copyright (C) 2018-2024, AdaCore -- +-- Copyright (C) 2018-2023, AdaCore -- -- -- -- This is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -134,11 +134,11 @@ package body LSP.Ada_Handlers is -- Save method in/out in a log file function Resolve_Name - (Self : in out Message_Handler; - Id : LSP.Structures.Integer_Or_Virtual_String; - Context : LSP.Ada_Contexts.Context; - Name_Node : Libadalang.Analysis.Name; - Result_Kind : out Libadalang.Common.Ref_Result_Kind) + (Self : in out Message_Handler; + Id : LSP.Structures.Integer_Or_Virtual_String; + Context : LSP.Ada_Contexts.Context; + Name_Node : Libadalang.Analysis.Name; + Imprecise : out Boolean) return Libadalang.Analysis.Defining_Name; -- Toplayer Resolve_Name based on Laltools.Common.Resolve_Name. -- This function is handling Imprecise and Error results during Nameres by @@ -357,9 +357,10 @@ package body LSP.Ada_Handlers is Name_Node : Libadalang.Analysis.Name) return Libadalang.Analysis.Defining_Name is - Trace : constant GNATCOLL.Traces.Trace_Handle := + Trace : constant GNATCOLL.Traces.Trace_Handle := LSP.GNATCOLL_Tracers.Handle (Self.Tracer.all); - Result_Kind : Libadalang.Common.Ref_Result_Kind; + + Ref_Kind : Libadalang.Common.Ref_Result_Kind; begin if Name_Node.Is_Null then return Libadalang.Analysis.No_Defining_Name; @@ -368,7 +369,7 @@ package body LSP.Ada_Handlers is return Laltools.Common.Resolve_Name (Name_Node, Trace, - Ref_Kind => Result_Kind); + Ref_Kind => Ref_Kind); end Imprecise_Resolve_Name; --------------------------------- @@ -2503,30 +2504,32 @@ package body LSP.Ada_Handlers is end loop; end Update_Response; - Definition : Libadalang.Analysis.Defining_Name; - Decl : Libadalang.Analysis.Basic_Decl; - Result_Kind : Libadalang.Common.Ref_Result_Kind := + Definition : Libadalang.Analysis.Defining_Name; + Imprecise : Boolean := False; + Decl : Libadalang.Analysis.Basic_Decl; + Ignore : Libadalang.Common.Ref_Result_Kind := Libadalang.Common.No_Ref; + begin if Name_Node.Is_Null then return; end if; Definition := Resolve_Name - (Self => Self, - Id => Id, - Context => C.all, - Name_Node => Name_Node, - Result_Kind => Result_Kind); + (Self => Self, + Id => Id, + Context => C.all, + Name_Node => Name_Node, + Imprecise => Imprecise); -- If we didn't find a definition, give up for this context - if Result_Kind in Error or else Definition.Is_Null then + if Definition.Is_Null then return; end if; -- First list the bodies of this definition Update_Response - (Laltools.Common.List_Bodies_Of (Definition, Trace, Result_Kind), + (Laltools.Common.List_Bodies_Of (Definition, Trace, Ignore), LSP.Constants.Empty); -- Then list the bodies of the parent implementations @@ -2539,18 +2542,19 @@ package body LSP.Ada_Handlers is (Display_Method_Policy = Usage_And_Abstract_Only and then Decl.Kind in Ada_Abstract_Subp_Decl_Range) then - for Subp of C.Find_All_Base_Declarations (Decl, Result_Kind) loop + for Subp of C.Find_All_Base_Declarations (Decl, Imprecise) + loop Update_Response (Laltools.Common.List_Bodies_Of - (Subp.P_Defining_Name, Trace, Result_Kind), + (Subp.P_Defining_Name, Trace, Ignore), Is_Parent); end loop; -- And finally the bodies of child implementations - for Subp of C.Find_All_Overrides (Decl, Result_Kind) loop + for Subp of C.Find_All_Overrides (Decl, Imprecise) loop Update_Response (Laltools.Common.List_Bodies_Of - (Subp.P_Defining_Name, Trace, Result_Kind), + (Subp.P_Defining_Name, Trace, Ignore), Is_Child); end loop; end if; @@ -3071,27 +3075,20 @@ package body LSP.Ada_Handlers is Defining_Name : Libadalang.Analysis.Defining_Name; - Result_Kind : Libadalang.Common.Ref_Result_Kind := - Libadalang.Common.No_Ref; - - use type Libadalang.Common.Ref_Result_Kind; + Imprecise : Boolean := False; begin if not Name_Node.Is_Null then Defining_Name := Resolve_Name - (Self => Self, - Id => Id, - Context => Context.all, - Name_Node => Name_Node, - Result_Kind => Result_Kind); - end if; - - if Result_Kind in Libadalang.Common.Error then - return; + (Self => Self, + Id => Id, + Context => Context.all, + Name_Node => Name_Node, + Imprecise => Imprecise); end if; if not Name_Node.Is_Null and then not Defining_Name.Is_Null - and then Result_Kind in Libadalang.Common.Precise + and then not Imprecise then -- Success only if the node is a name and can be resolved precisely Response := @@ -3629,9 +3626,10 @@ package body LSP.Ada_Handlers is Value : LSP.Structures.TypeDefinitionParams) is - Response : LSP.Structures.Definition_Result (LSP.Structures.Variant_1); - Vector : LSP.Structures.Location_Vector renames Response.Variant_1; - Filter : LSP.Locations.File_Span_Sets.Set; + Response : LSP.Structures.Definition_Result (LSP.Structures.Variant_1); + Vector : LSP.Structures.Location_Vector renames Response.Variant_1; + Filter : LSP.Locations.File_Span_Sets.Set; + Imprecise : Boolean := False; procedure Resolve_In_Context (C : LSP.Ada_Context_Sets.Context_Access); -- Utility function to gather results on one context @@ -3641,7 +3639,7 @@ package body LSP.Ada_Handlers is ------------------------ procedure Resolve_In_Context (C : LSP.Ada_Context_Sets.Context_Access) is - Name_Node : constant Libadalang.Analysis.Name := + Name_Node : constant Libadalang.Analysis.Name := Laltools.Common.Get_Node_As_Name (Self.Get_Node_At (C.all, Value)); Definition : Libadalang.Analysis.Defining_Name; @@ -3655,25 +3653,20 @@ package body LSP.Ada_Handlers is -- Special case if Name_Node is defining, for instance on the X in -- X : My_Type; declare - Def_Name : constant Libadalang.Analysis.Defining_Name := + Def_Name : constant Libadalang.Analysis.Defining_Name := Name_Node.P_Enclosing_Defining_Name; - Type_Expr : constant Libadalang.Analysis.Type_Expr := + + Type_Expr : constant Libadalang.Analysis.Type_Expr := Def_Name.P_Basic_Decl.P_Type_Expression; - Result_Kind : Libadalang.Common.Ref_Result_Kind := - Libadalang.Common.No_Ref; begin if not Type_Expr.Is_Null then Definition := Resolve_Name - (Self => Self, - Id => Id, - Context => C.all, - Name_Node => Type_Expr.P_Type_Name, - Result_Kind => Result_Kind); - - if Result_Kind in Libadalang.Common.Error then - return; - end if; + (Self => Self, + Id => Id, + Context => C.all, + Name_Node => Type_Expr.P_Type_Name, + Imprecise => Imprecise); end if; end; else @@ -3773,14 +3766,15 @@ package body LSP.Ada_Handlers is ------------------ function Resolve_Name - (Self : in out Message_Handler; - Id : LSP.Structures.Integer_Or_Virtual_String; - Context : LSP.Ada_Contexts.Context; - Name_Node : Libadalang.Analysis.Name; - Result_Kind : out Libadalang.Common.Ref_Result_Kind) + (Self : in out Message_Handler; + Id : LSP.Structures.Integer_Or_Virtual_String; + Context : LSP.Ada_Contexts.Context; + Name_Node : Libadalang.Analysis.Name; + Imprecise : out Boolean) return Libadalang.Analysis.Defining_Name is Definition : Libadalang.Analysis.Defining_Name; + Result_Kind : Libadalang.Common.Ref_Result_Kind; Trace : constant GNATCOLL.Traces.Trace_Handle := LSP.GNATCOLL_Tracers.Handle (Self.Tracer.all); Id_Image : constant String := @@ -3788,7 +3782,7 @@ package body LSP.Ada_Handlers is then Id.Integer'Image else VSS.Strings.Conversions.To_UTF_8_String (Id.Virtual_String)); begin - Result_Kind := Libadalang.Common.No_Ref; + Imprecise := False; if Name_Node.Is_Null then -- Internal tracing of resolve on null node @@ -3840,6 +3834,13 @@ package body LSP.Ada_Handlers is Diag_Params.diagnostics.Append (Diagnostic); Self.Sender.On_PublishDiagnostics_Notification (Diag_Params); + -- Inform the client that the request failed + Self.Sender.On_Error_Response + (Id, + (code => LSP.Enumerations.InternalError, + message => VSS.Strings.Conversions.To_Virtual_String + (Err_Msg))); + return Libadalang.Analysis.No_Defining_Name; end; @@ -3852,6 +3853,7 @@ package body LSP.Ada_Handlers is & VSS.Strings.Conversions.To_UTF_8_String (Context.Id) & " for request " & Id_Image); + Imprecise := True; end if; return Definition; diff --git a/source/ada/lsp-ada_references.adb b/source/ada/lsp-ada_references.adb index 84c4ca443..75002696e 100644 --- a/source/ada/lsp-ada_references.adb +++ b/source/ada/lsp-ada_references.adb @@ -163,8 +163,7 @@ package body LSP.Ada_References is return not Decl.Is_Null and then Decl.Kind = Ada_Enum_Literal_Decl; end Is_Enum; - Ignore : Libadalang.Common.Ref_Result_Kind; - + Ignore : Boolean; Units : Libadalang.Analysis.Analysis_Unit_Array (1 .. 1); begin -- Next file to process