1515-- of the license. --
1616-- ----------------------------------------------------------------------------
1717
18- with Ada.Exceptions ;
1918with Ada.Strings.Unbounded ;
2019with Ada.Strings.UTF_Encoding ;
2120with Ada.Tags.Generic_Dispatching_Constructor ;
@@ -32,7 +31,6 @@ with VSS.Strings.Templates;
3231with VSS.String_Vectors ;
3332with VSS.JSON.Streams ;
3433
35- with Libadalang.Analysis ;
3634with Libadalang.Common ;
3735
3836with Laltools.Common ;
@@ -60,7 +58,6 @@ with LSP.Ada_Completions.Parameters;
6058with LSP.Ada_Completions.Pragmas ;
6159with LSP.Ada_Completions.Use_Clauses ;
6260with LSP.Ada_Completions ;
63- with LSP.Ada_Contexts ;
6461with LSP.Ada_Documentation ;
6562with LSP.Ada_Empty_Handlers ;
6663with LSP.Ada_Handlers.Call_Hierarchy ;
@@ -87,14 +84,12 @@ with LSP.Ada_Handlers.Renaming;
8784with LSP.Ada_Handlers.Symbols ;
8885with LSP.Ada_Commands ;
8986with LSP.Client_Side_File_Monitors ;
90- with LSP.Constants ;
9187with LSP.Diagnostic_Sources ;
9288with LSP.Enumerations ;
9389with LSP.Errors ;
9490with LSP.Formatters.Texts ;
9591with LSP.Generic_Cancel_Check ;
9692with LSP.GNATCOLL_Tracers.Handle ;
97- with LSP.Locations ;
9893with LSP.Predefined_Completion ;
9994with LSP.Search ;
10095with LSP.Servers ;
@@ -154,20 +149,14 @@ package body LSP.Ada_Handlers is
154149 return Libadalang.Analysis.Ada_Node
155150 renames LSP.Ada_Handlers.Locations.Get_Node_At;
156151
157- procedure Append_Location
152+ overriding procedure Append_Location
158153 (Self : in out Message_Handler;
159154 Result : in out LSP.Structures.Location_Vector;
160155 Filter : in out LSP.Locations.File_Span_Sets.Set;
161156 Node : Libadalang.Analysis.Ada_Node'Class;
162157 Kinds : AlsReferenceKind_Array := LSP.Constants.Empty)
163158 renames LSP.Ada_Handlers.Locations.Append_Location;
164159
165- function Imprecise_Resolve_Name
166- (Self : in out Message_Handler'Class;
167- Context : LSP.Ada_Contexts.Context;
168- Position : LSP.Structures.TextDocumentPositionParams'Class)
169- return Libadalang.Analysis.Defining_Name;
170-
171160 function Project_Predefined_Units
172161 (Self : in out Message_Handler;
173162 Context : LSP.Ada_Contexts.Context)
@@ -348,8 +337,8 @@ package body LSP.Ada_Handlers is
348337 -- Imprecise_Resolve_Name --
349338 -- --------------------------
350339
351- function Imprecise_Resolve_Name
352- (Self : in out Message_Handler'Class ;
340+ overriding function Imprecise_Resolve_Name
341+ (Self : in out Message_Handler;
353342 Context : LSP.Ada_Contexts.Context;
354343 Position : LSP.Structures.TextDocumentPositionParams'Class)
355344 return Libadalang.Analysis.Defining_Name
@@ -3706,189 +3695,6 @@ package body LSP.Ada_Handlers is
37063695 end if ;
37073696 end On_RangeFormatting_Request ;
37083697
3709- -- -------------------------
3710- -- On_References_Request --
3711- -- -------------------------
3712-
3713- overriding procedure On_References_Request
3714- (Self : in out Message_Handler;
3715- Id : LSP.Structures.Integer_Or_Virtual_String;
3716- Value : LSP.Structures.ReferenceParams)
3717- is
3718- use all type LSP.Enumerations.AlsReferenceKind;
3719-
3720- Response : LSP.Structures.Location_Vector_Or_Null;
3721- Imprecise : Boolean := False;
3722- Filter : LSP.Locations.File_Span_Sets.Set;
3723-
3724- Additional_Kinds : AlsReferenceKind_Array :=
3725- [others => False];
3726-
3727- procedure Process_Context (C : LSP.Ada_Context_Sets.Context_Access);
3728- -- Process the references found in one context and append
3729- -- them to Response.results.
3730-
3731- function Get_Reference_Kind
3732- (Node : Libadalang.Analysis.Ada_Node'Class;
3733- Is_Overriding_Decl : Boolean := False)
3734- return AlsReferenceKind_Array;
3735- -- Fetch reference kind for given node.
3736-
3737- -- ----------------------
3738- -- Get_Reference_Kind --
3739- -- ----------------------
3740-
3741- function Get_Reference_Kind
3742- (Node : Libadalang.Analysis.Ada_Node'Class;
3743- Is_Overriding_Decl : Boolean := False)
3744- return AlsReferenceKind_Array
3745- is
3746- use type AlsReferenceKind_Array;
3747-
3748- Id : constant Libadalang.Analysis.Name :=
3749- Laltools.Common.Get_Node_As_Name (Node.As_Ada_Node);
3750-
3751- Result : AlsReferenceKind_Array := [others => False];
3752- begin
3753- begin
3754- Result (write) := Id.P_Is_Write_Reference;
3755- exception
3756- when E : Libadalang.Common.Property_Error =>
3757- Self.Tracer.Trace_Exception (E);
3758- end ;
3759-
3760- begin
3761- Result (an_access) :=
3762- Laltools.Common.Is_Access_Ref (Id.As_Ada_Node);
3763- exception
3764- when E : Libadalang.Common.Property_Error =>
3765- Self.Tracer.Trace_Exception (E);
3766- end ;
3767-
3768- begin
3769- Result (call) := Id.P_Is_Static_Call;
3770- exception
3771- when E : Libadalang.Common.Property_Error =>
3772- Self.Tracer.Trace_Exception (E);
3773- end ;
3774-
3775- begin
3776- Result (dispatching_call) :=
3777- Id.P_Is_Dispatching_Call;
3778- exception
3779- when E : Libadalang.Common.Property_Error =>
3780- Self.Tracer.Trace_Exception (E);
3781- end ;
3782-
3783- begin
3784- Result (child) :=
3785- Laltools.Common.Is_Type_Derivation (Id.As_Ada_Node);
3786- exception
3787- when E : Libadalang.Common.Property_Error =>
3788- Self.Tracer.Trace_Exception (E);
3789- end ;
3790-
3791- Result (an_overriding) := Is_Overriding_Decl;
3792-
3793- -- If the result has not any set flags at this point, flag it as a
3794- -- simple reference.
3795- if Result = [Result'Range => False] then
3796- Result (reference) := True;
3797- end if ;
3798-
3799- -- Apply additional kinds
3800- Result := Result or Additional_Kinds;
3801-
3802- return Result;
3803- end Get_Reference_Kind ;
3804-
3805- -- -------------------
3806- -- Process_Context --
3807- -- -------------------
3808-
3809- procedure Process_Context (C : LSP.Ada_Context_Sets.Context_Access) is
3810- procedure Callback
3811- (Node : Libadalang.Analysis.Base_Id;
3812- Kind : Libadalang.Common.Ref_Result_Kind;
3813- Cancel : in out Boolean);
3814-
3815- procedure Callback
3816- (Node : Libadalang.Analysis.Base_Id;
3817- Kind : Libadalang.Common.Ref_Result_Kind;
3818- Cancel : in out Boolean)
3819- is
3820- pragma Unreferenced (Kind);
3821- begin
3822- if not Laltools.Common.Is_End_Label (Node.As_Ada_Node) then
3823-
3824- Self.Append_Location
3825- (Response,
3826- Filter,
3827- Node,
3828- Get_Reference_Kind (Node));
3829- end if ;
3830-
3831- Cancel := Self.Is_Canceled.all ;
3832- end Callback ;
3833-
3834- Definition : Libadalang.Analysis.Defining_Name;
3835-
3836- use Libadalang.Common;
3837- begin
3838-
3839- Definition := Self.Imprecise_Resolve_Name (C.all , Value);
3840-
3841- if Definition.Is_Null or else Self.Is_Canceled.all then
3842- return ;
3843- end if ;
3844-
3845- -- Set additional "reference" kind for enumeration literal
3846- declare
3847- Decl : constant Libadalang.Analysis.Basic_Decl :=
3848- Libadalang.Analysis.P_Basic_Decl (Definition);
3849- begin
3850- if not Decl.Is_Null
3851- and then Libadalang.Analysis.Kind (Decl) = Ada_Enum_Literal_Decl
3852- then
3853- Additional_Kinds (reference) := True;
3854- end if ;
3855-
3856- -- Find all the references
3857- C.Find_All_References (Definition, Callback'Access );
3858-
3859- -- Find all the overriding declarations, if any
3860- for Subp of C.Find_All_Overrides (Decl, Imprecise) loop
3861- Self.Append_Location
3862- (Response,
3863- Filter,
3864- Subp.P_Defining_Name,
3865- Get_Reference_Kind
3866- (Definition,
3867- Is_Overriding_Decl => True));
3868- end loop ;
3869-
3870- if Value.context.includeDeclaration then
3871- Self.Append_Location
3872- (Response,
3873- Filter,
3874- Definition,
3875- Get_Reference_Kind (Definition));
3876- end if ;
3877- end ;
3878- end Process_Context ;
3879-
3880- begin
3881- for C of Self.Contexts_For_URI (Value.textDocument.uri) loop
3882- Process_Context (C);
3883-
3884- exit when Self.Is_Canceled.all ;
3885- end loop ;
3886-
3887- Locations.Sort (Response);
3888-
3889- Self.Sender.On_References_Response (Id, Response);
3890- end On_References_Request ;
3891-
38923698 -- ---------------------
38933699 -- On_Rename_Request --
38943700 -- ---------------------
@@ -4733,4 +4539,17 @@ package body LSP.Ada_Handlers is
47334539 end return ;
47344540 end To_Workspace_Edit ;
47354541
4542+ -- -------------------
4543+ -- Trace_Exception --
4544+ -- -------------------
4545+
4546+ overriding procedure Trace_Exception
4547+ (Self : Message_Handler;
4548+ Error : Ada.Exceptions.Exception_Occurrence;
4549+ Message : VSS.Strings.Virtual_String :=
4550+ VSS.Strings.Empty_Virtual_String) is
4551+ begin
4552+ Self.Tracer.Trace_Exception (Error, Message);
4553+ end Trace_Exception ;
4554+
47364555end LSP.Ada_Handlers ;
0 commit comments