@@ -90,7 +90,6 @@ with LSP.Errors;
9090with LSP.Formatters.Texts ;
9191with LSP.Generic_Cancel_Check ;
9292with LSP.GNATCOLL_Tracers.Handle ;
93- with LSP.Predefined_Completion ;
9493with LSP.Search ;
9594with LSP.Servers ;
9695with LSP.Servers.FS_Watch ;
@@ -142,12 +141,12 @@ package body LSP.Ada_Handlers is
142141 return LSP.Structures.Location
143142 renames LSP.Ada_Handlers.Locations.To_LSP_Location;
144143
145- function Get_Node_At
146- (Self : in out Message_Handler'Class ;
144+ overriding function Get_Node_At
145+ (Self : in out Message_Handler;
147146 Context : LSP.Ada_Contexts.Context;
148147 Value : LSP.Structures.TextDocumentPositionParams'Class)
149- return Libadalang.Analysis.Ada_Node
150- renames LSP.Ada_Handlers.Locations.Get_Node_At;
148+ return Libadalang.Analysis.Ada_Node is
149+ ( LSP.Ada_Handlers.Locations.Get_Node_At (Self, Context, Value)) ;
151150
152151 overriding procedure Append_Location
153152 (Self : in out Message_Handler;
@@ -2840,153 +2839,6 @@ package body LSP.Ada_Handlers is
28402839 end if ;
28412840 end On_Formatting_Request ;
28422841
2843- -- --------------------
2844- -- On_Hover_Request --
2845- -- --------------------
2846-
2847- overriding procedure On_Hover_Request
2848- (Self : in out Message_Handler;
2849- Id : LSP.Structures.Integer_Or_Virtual_String;
2850- Value : LSP.Structures.HoverParams)
2851- is
2852-
2853- Response : LSP.Structures.Hover_Or_Null;
2854-
2855- procedure Compute_Response ;
2856-
2857- -- --------------------
2858- -- Compute_Response --
2859- -- --------------------
2860-
2861- procedure Compute_Response is
2862- Context : constant LSP.Ada_Context_Sets.Context_Access :=
2863- Self.Contexts.Get_Best_Context (Value.textDocument.uri);
2864- -- For the Hover request, we're only interested in the "best"
2865- -- response value, not in the list of values for all contexts
2866-
2867- Defining_Name_Node : constant Libadalang.Analysis.Defining_Name :=
2868- Self.Imprecise_Resolve_Name (Context.all , Value);
2869- Decl : constant Libadalang.Analysis.Basic_Decl :=
2870- (if Defining_Name_Node.Is_Null
2871- then Libadalang.Analysis.No_Basic_Decl
2872- else Defining_Name_Node.P_Basic_Decl);
2873- -- Associated basic declaration, if any
2874-
2875- Decl_Text : VSS.Strings.Virtual_String;
2876- Qualifier_Text : VSS.Strings.Virtual_String;
2877- Documentation_Text : VSS.Strings.Virtual_String;
2878- Location_Text : VSS.Strings.Virtual_String;
2879- Aspects_Text : VSS.Strings.Virtual_String;
2880-
2881- begin
2882- -- Return immediately if the request has been canceled
2883- if Self.Is_Canceled.all then
2884- return ;
2885- end if ;
2886-
2887- if Decl.Is_Null then
2888-
2889- -- There is no declaration for the hovered node: ask the predefined
2890- -- entities' completion provider (attributes, pragmas, aspects) for
2891- -- a tooltip text if it can.
2892- declare
2893- Node : constant Libadalang.Analysis.Ada_Node := Self.Get_Node_At
2894- (Context.all , Value);
2895- begin
2896- if not Node.Is_Null
2897- and then Node.Kind in Libadalang.Common.Ada_Identifier_Range
2898- then
2899- LSP.Predefined_Completion.Get_Tooltip_Text
2900- (Node => Node.As_Identifier,
2901- Declaration_Text => Decl_Text,
2902- Documentation_Text => Documentation_Text);
2903- end if ;
2904- end ;
2905- else
2906- -- We have resolved the hovered node to its declaration: use
2907- -- the default tooltip provider, based on GNATdoc.
2908- LSP.Ada_Documentation.Get_Tooltip_Text
2909- (BD => Decl,
2910- Style => Context.Get_Documentation_Style,
2911- Declaration_Text => Decl_Text,
2912- Qualifier_Text => Qualifier_Text,
2913- Location_Text => Location_Text,
2914- Documentation_Text => Documentation_Text,
2915- Aspects_Text => Aspects_Text);
2916- end if ;
2917-
2918- -- Return if no provider has been able to compute text for a tooltip.
2919- if Decl_Text.Is_Empty then
2920- return ;
2921- end if ;
2922-
2923- Response := (Is_Null => False, others => <>);
2924- Response.Value.contents := (Is_MarkupContent => False, others => <>);
2925-
2926- -- Append the whole declaration text to the response
2927-
2928- Response.Value.contents.MarkedString_Vector.Append
2929- (LSP.Structures.MarkedString'
2930- (Is_Virtual_String => False,
2931- value => Decl_Text,
2932- language => " ada" ));
2933-
2934- -- Append qualifier text if any
2935-
2936- if not Qualifier_Text.Is_Empty then
2937- Response.Value.contents.MarkedString_Vector.Append
2938- (LSP.Structures.MarkedString'
2939- (Is_Virtual_String => True,
2940- Virtual_String => Qualifier_Text));
2941- end if ;
2942-
2943- -- Append the declaration's location.
2944- --
2945- -- In addition, append the project's name if we are dealing with an
2946- -- aggregate project.
2947-
2948- if not Decl.Is_Null then
2949- Location_Text := LSP.Utils.Node_Location_Image (Decl);
2950-
2951- if Self.Project_Tree.Root_Project.Kind in GPR2.Aggregate_Kind then
2952- Location_Text.Append (VSS.Characters.Latin.Line_Feed);
2953- Location_Text.Append (" As defined in project " );
2954- Location_Text.Append (Context.Id);
2955- Location_Text.Append (" (other projects skipped)." );
2956- end if ;
2957-
2958- Response.Value.contents.MarkedString_Vector.Append
2959- (LSP.Structures.MarkedString'
2960- (Is_Virtual_String => True,
2961- Virtual_String => Location_Text));
2962- end if ;
2963-
2964- -- Append the comments associated with the basic declaration if any.
2965-
2966- if not Documentation_Text.Is_Empty then
2967- Response.Value.contents.MarkedString_Vector.Append
2968- (LSP.Structures.MarkedString'
2969- (Is_Virtual_String => False,
2970- language => " plaintext" ,
2971- value => Documentation_Text));
2972- end if ;
2973-
2974- -- Append text of aspects
2975-
2976- if not Aspects_Text.Is_Empty then
2977- Response.Value.contents.MarkedString_Vector.Append
2978- (LSP.Structures.MarkedString'
2979- (Is_Virtual_String => False,
2980- value => Aspects_Text,
2981- language => " ada" ));
2982- end if ;
2983- end Compute_Response ;
2984-
2985- begin
2986- Compute_Response;
2987- Self.Sender.On_Hover_Response (Id, Response);
2988- end On_Hover_Request ;
2989-
29902842 -- -----------------------------
29912843 -- On_Implementation_Request --
29922844 -- -----------------------------
0 commit comments