Skip to content

Commit b9ee6b3

Browse files
committed
Add parameters for qualifier and aspects text.
Remove unused parameter for trace.
1 parent 11cd2d4 commit b9ee6b3

File tree

5 files changed

+104
-61
lines changed

5 files changed

+104
-61
lines changed

source/ada/lsp-ada_completions-generic_assoc.adb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -506,18 +506,21 @@ package body LSP.Ada_Completions.Generic_Assoc is
506506
Cursor_Position => Cursor_Position)),
507507
others => <>
508508
);
509+
Declaration_Text : VSS.Strings.Virtual_String;
510+
Qualifier_Text : VSS.Strings.Virtual_String;
509511
Location_Text : VSS.Strings.Virtual_String;
510512
Documentation_Text : VSS.Strings.Virtual_String;
511-
Declaration_Text : VSS.Strings.Virtual_String;
513+
Aspects_Text : VSS.Strings.Virtual_String;
512514

513515
begin
514516
LSP.Ada_Documentation.Get_Tooltip_Text
515-
(Spec.Decl,
516-
Me_Debug,
517-
Context.Get_Documentation_Style,
518-
Location_Text,
519-
Documentation_Text,
520-
Declaration_Text);
517+
(BD => Spec.Decl,
518+
Style => Context.Get_Documentation_Style,
519+
Declaration_Text => Declaration_Text,
520+
Qualifier_Text => Qualifier_Text,
521+
Location_Text => Location_Text,
522+
Documentation_Text => Documentation_Text,
523+
Aspects_Text => Aspects_Text);
521524

522525
Signature.label := Declaration_Text;
523526
Signature.documentation :=

source/ada/lsp-ada_documentation.adb

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -485,15 +485,14 @@ package body LSP.Ada_Documentation is
485485
----------------------
486486

487487
procedure Get_Tooltip_Text
488-
(BD : Libadalang.Analysis.Basic_Decl;
489-
Trace : GNATCOLL.Traces.Trace_Handle;
490-
Style : GNATdoc.Comments.Options.Documentation_Style;
491-
Loc_Text : out VSS.Strings.Virtual_String;
492-
Doc_Text : out VSS.Strings.Virtual_String;
493-
Decl_Text : out VSS.Strings.Virtual_String)
488+
(BD : Libadalang.Analysis.Basic_Decl;
489+
Style : GNATdoc.Comments.Options.Documentation_Style;
490+
Declaration_Text : out VSS.Strings.Virtual_String;
491+
Qualifier_Text : out VSS.Strings.Virtual_String;
492+
Location_Text : out VSS.Strings.Virtual_String;
493+
Documentation_Text : out VSS.Strings.Virtual_String;
494+
Aspects_Text : out VSS.Strings.Virtual_String)
494495
is
495-
pragma Unreferenced (Trace);
496-
497496
Options : constant
498497
GNATdoc.Comments.Options.Extractor_Options :=
499498
(Style => Style,
@@ -511,20 +510,22 @@ package body LSP.Ada_Documentation is
511510
Code_Snippet => Decl_Lines,
512511
Documentation => Doc_Lines);
513512

514-
Decl_Text := Decl_Lines.Join_Lines (VSS.Strings.LF, False);
515-
Doc_Text := Doc_Lines.Join_Lines (VSS.Strings.LF, False);
513+
Declaration_Text := Decl_Lines.Join_Lines (VSS.Strings.LF, False);
514+
Documentation_Text := Doc_Lines.Join_Lines (VSS.Strings.LF, False);
516515

517516
-- If GNATdoc failed to compute the declaration text, use the old engine
518-
if Decl_Text.Is_Empty
517+
if Declaration_Text.Is_Empty
519518
or else (BD.Kind not in Ada_Enum_Literal_Decl
520519
and not BD.P_Subp_Spec_Or_Null.Is_Null)
521520
then
522521
-- For subprograms additional information is added, use old code to
523522
-- obtain it yet.
524-
Decl_Text := Get_Hover_Text (BD);
523+
Declaration_Text := Get_Hover_Text (BD);
525524
end if;
526525

527-
Loc_Text := LSP.Lal_Utils.Node_Location_Image (BD);
526+
Location_Text := LSP.Lal_Utils.Node_Location_Image (BD);
527+
Qualifier_Text.Clear;
528+
Aspects_Text.Clear;
528529
end Get_Tooltip_Text;
529530

530531
end LSP.Ada_Documentation;

source/ada/lsp-ada_documentation.ads

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
-- Subprograms to obtain documentation for declarations.
1919

20-
with GNATCOLL.Traces;
21-
2220
with VSS.Strings;
2321

2422
with Libadalang.Analysis;
@@ -28,18 +26,28 @@ with GNATdoc.Comments.Options;
2826
package LSP.Ada_Documentation is
2927

3028
procedure Get_Tooltip_Text
31-
(BD : Libadalang.Analysis.Basic_Decl;
32-
Trace : GNATCOLL.Traces.Trace_Handle;
33-
Style : GNATdoc.Comments.Options.Documentation_Style;
34-
Loc_Text : out VSS.Strings.Virtual_String;
35-
Doc_Text : out VSS.Strings.Virtual_String;
36-
Decl_Text : out VSS.Strings.Virtual_String);
29+
(BD : Libadalang.Analysis.Basic_Decl;
30+
Style : GNATdoc.Comments.Options.Documentation_Style;
31+
Declaration_Text : out VSS.Strings.Virtual_String;
32+
Qualifier_Text : out VSS.Strings.Virtual_String;
33+
Location_Text : out VSS.Strings.Virtual_String;
34+
Documentation_Text : out VSS.Strings.Virtual_String;
35+
Aspects_Text : out VSS.Strings.Virtual_String);
3736
-- Get all the information needed to produce tooltips (hover and completion
3837
-- requests) for the given declaration.
39-
-- Style is used by GNATdoc for extracting the associated comments.
40-
-- Loc_Text contains the declaration's location text (e.g: a.adb (11:1)).
41-
-- Doc_Text contains the comments associated with the declaration.
42-
-- Decl_Text contains the code corresponding to the declaration, formatted
43-
-- by GNATdoc when possible.
38+
--
39+
-- @param BD Declaration's node.
40+
-- @param Style
41+
-- Is used by GNATdoc for extracting the associated comments.
42+
-- @param Qualifier_Text
43+
-- Auxiliary information about properties of the delaration.
44+
-- @param Location_Text
45+
-- Contains the declaration's location text (e.g: a.adb (11:1)).
46+
-- @param Documentation_Text
47+
-- Contains the comments associated with the declaration.
48+
-- @param Declaration_Text
49+
-- Contains the code corresponding to the declaration.
50+
-- @param Aspects_Text
51+
-- Contains the code of aspects of the declaration.
4452

4553
end LSP.Ada_Documentation;

source/ada/lsp-ada_documents.adb

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,25 +2494,28 @@ package body LSP.Ada_Documents is
24942494
(Context : LSP.Ada_Contexts.Context;
24952495
BD : Libadalang.Analysis.Basic_Decl;
24962496
Item : in out LSP.Messages.CompletionItem;
2497-
Compute_Doc_And_Details : Boolean)
2498-
is
2497+
Compute_Doc_And_Details : Boolean) is
24992498
begin
25002499
-- Compute the 'documentation' and 'detail' fields immediately if
25012500
-- requested (i.e: when the client does not support lazy computation
25022501
-- for these fields or if we are dealing with predefined types).
25032502
if Compute_Doc_And_Details or else LSP.Lal_Utils.Is_Synthetic (BD) then
25042503
declare
2505-
Loc_Text : VSS.Strings.Virtual_String;
2506-
Doc_Text : VSS.Strings.Virtual_String;
2507-
Decl_Text : VSS.Strings.Virtual_String;
2504+
Qual_Text : VSS.Strings.Virtual_String;
2505+
Decl_Text : VSS.Strings.Virtual_String;
2506+
Loc_Text : VSS.Strings.Virtual_String;
2507+
Doc_Text : VSS.Strings.Virtual_String;
2508+
Aspects_Text : VSS.Strings.Virtual_String;
2509+
25082510
begin
25092511
LSP.Ada_Documentation.Get_Tooltip_Text
2510-
(BD => BD,
2511-
Trace => Context.Trace,
2512-
Style => Context.Get_Documentation_Style,
2513-
Loc_Text => Loc_Text,
2514-
Doc_Text => Doc_Text,
2515-
Decl_Text => Decl_Text);
2512+
(BD => BD,
2513+
Style => Context.Get_Documentation_Style,
2514+
Declaration_Text => Decl_Text,
2515+
Qualifier_Text => Qual_Text,
2516+
Location_Text => Loc_Text,
2517+
Documentation_Text => Doc_Text,
2518+
Aspects_Text => Aspects_Text);
25162519

25172520
Item.detail := (True, Decl_Text);
25182521

@@ -2530,6 +2533,7 @@ package body LSP.Ada_Documents is
25302533
(Is_String => True,
25312534
String => Loc_Text));
25322535
end;
2536+
25332537
else
25342538
-- Set node's location to the 'data' field of the completion item, so
25352539
-- that we can retrieve it in the completionItem/resolve handler.

source/ada/lsp-ada_handlers.adb

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3255,9 +3255,11 @@ package body LSP.Ada_Handlers is
32553255

32563256
Defining_Name_Node : Defining_Name;
32573257
Decl : Basic_Decl;
3258+
Qualifier_Text : VSS.Strings.Virtual_String;
32583259
Decl_Text : VSS.Strings.Virtual_String;
32593260
Comments_Text : VSS.Strings.Virtual_String;
32603261
Location_Text : VSS.Strings.Virtual_String;
3262+
Aspects_Text : VSS.Strings.Virtual_String;
32613263

32623264
C : constant Context_Access :=
32633265
Self.Contexts.Get_Best_Context (Value.textDocument.uri);
@@ -3279,26 +3281,37 @@ package body LSP.Ada_Handlers is
32793281
end if;
32803282

32813283
LSP.Ada_Documentation.Get_Tooltip_Text
3282-
(BD => Decl,
3283-
Trace => Self.Trace,
3284-
Style => C.Get_Documentation_Style,
3285-
Loc_Text => Location_Text,
3286-
Doc_Text => Comments_Text,
3287-
Decl_Text => Decl_Text);
3284+
(BD => Decl,
3285+
Style => C.Get_Documentation_Style,
3286+
Declaration_Text => Decl_Text,
3287+
Qualifier_Text => Qualifier_Text,
3288+
Location_Text => Location_Text,
3289+
Documentation_Text => Comments_Text,
3290+
Aspects_Text => Aspects_Text);
32883291

32893292
if Decl_Text.Is_Empty then
32903293
return Response;
32913294
end if;
32923295

3293-
-- Append the whole declaration text to the response
32943296
Response.result := (Is_Set => True, others => <>);
32953297

3298+
-- Append the whole declaration text to the response
3299+
32963300
Response.result.Value.contents.Vector.Append
32973301
(LSP.Messages.MarkedString'
32983302
(Is_String => False,
32993303
value => Decl_Text,
33003304
language => "ada"));
33013305

3306+
-- Append qualifier text if any
3307+
3308+
if not Qualifier_Text.Is_Empty then
3309+
Response.result.Value.contents.Vector.Append
3310+
(LSP.Messages.MarkedString'
3311+
(Is_String => True,
3312+
value => Qualifier_Text));
3313+
end if;
3314+
33023315
-- Append the declaration's location.
33033316
-- In addition, append the project's name if we are dealing with an
33043317
-- aggregate project.
@@ -3328,6 +3341,16 @@ package body LSP.Ada_Handlers is
33283341
value => Comments_Text));
33293342
end if;
33303343

3344+
-- Append text of aspects
3345+
3346+
if not Aspects_Text.Is_Empty then
3347+
Response.result.Value.contents.Vector.Append
3348+
(LSP.Messages.MarkedString'
3349+
(Is_String => False,
3350+
value => Aspects_Text,
3351+
language => "ada"));
3352+
end if;
3353+
33313354
return Response;
33323355
end On_Hover_Request;
33333356

@@ -5959,19 +5982,23 @@ package body LSP.Ada_Handlers is
59595982
-- Compute the completion item's details
59605983
if not Node.Is_Null then
59615984
declare
5962-
BD : constant Libadalang.Analysis.Basic_Decl :=
5985+
BD : constant Libadalang.Analysis.Basic_Decl :=
59635986
Node.As_Basic_Decl;
5964-
Loc_Text : VSS.Strings.Virtual_String;
5965-
Doc_Text : VSS.Strings.Virtual_String;
5966-
Decl_Text : VSS.Strings.Virtual_String;
5987+
Qual_Text : VSS.Strings.Virtual_String;
5988+
Loc_Text : VSS.Strings.Virtual_String;
5989+
Doc_Text : VSS.Strings.Virtual_String;
5990+
Decl_Text : VSS.Strings.Virtual_String;
5991+
Aspects_Text : VSS.Strings.Virtual_String;
5992+
59675993
begin
59685994
LSP.Ada_Documentation.Get_Tooltip_Text
5969-
(BD => BD,
5970-
Trace => C.Trace,
5971-
Style => Self.Options.Documentation.Style,
5972-
Loc_Text => Loc_Text,
5973-
Doc_Text => Doc_Text,
5974-
Decl_Text => Decl_Text);
5995+
(BD => BD,
5996+
Style => Self.Options.Documentation.Style,
5997+
Qualifier_Text => Qual_Text,
5998+
Location_Text => Loc_Text,
5999+
Documentation_Text => Doc_Text,
6000+
Declaration_Text => Decl_Text,
6001+
Aspects_Text => Aspects_Text);
59756002

59766003
Item.detail := (True, Decl_Text);
59776004

0 commit comments

Comments
 (0)