Skip to content

Commit 05f7812

Browse files
V901-009: Generate Signatures using the Parameter completion
Add test for signatureHelp and generic instantiation. Add tests for signatureHelp and aggregates.
1 parent 189e83e commit 05f7812

25 files changed

+2684
-746
lines changed

source/ada/lsp-ada_completions-generic_assoc.adb

Lines changed: 549 additions & 49 deletions
Large diffs are not rendered by default.

source/ada/lsp-ada_completions-generic_assoc.ads

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,31 @@ generic
3939
with function Get_Designators
4040
(E : Element;
4141
Sloc : Langkit_Support.Slocs.Source_Location;
42+
Prefixed : out Boolean;
4243
Unnamed_Params : out Natural)
4344
return Laltools.Common.Node_Vectors.Vector;
44-
-- Return the current list of Designators for E.
45-
-- Unnamed_Params correspond to the number of parameters without
46-
-- designators before Sloc.
45+
-- Compute the list of parameters in E, they are separated in 4 categories:
46+
-- - Prefixed indicates if we are prefixed by a parameter
47+
-- - Unnamed_Params corresponds to all the params without designators
48+
-- at the start of the function
49+
-- - The Result starts with the list of all the designators
50+
-- - The Result finishes with X No_Ada_Node, one for each params without
51+
-- designator after the first named param.
52+
--
53+
-- Example: Obj.Foo (1, 2, 3, X => 4, Y => 5, 7, 8
54+
-- Prefixed = Is_Param (Obj)
55+
-- Unnamed_Params = 3
56+
-- Result = [X, Y, No_Ada_Node, No_Ada_Node]
4757

4858
with function Get_Spec_Designators
49-
(E : Element;
50-
Context : not null LSP.Ada_Handlers.Context_Access)
59+
(E : Element;
60+
Context : not null LSP.Ada_Handlers.Context_Access;
61+
For_Signature : Boolean)
5162
return LSP.Ada_Completions.Generic_Assoc_Utils.Assoc_Data_Lists.List;
5263
-- Return all the specs matching E
64+
-- When For_Signature, modify the data for signature
65+
-- For example: completion requires the missing parameters but signature
66+
-- requires all parameters
5367

5468
Pretty_Print_Rule : Libadalang.Common.Grammar_Rule;
5569
-- Rule used to pretty print the completion item
@@ -60,6 +74,10 @@ generic
6074
return Libadalang.Analysis.Ada_Node'Class;
6175
-- Get the node needed to match Pretty_Print_Rule
6276
-- Column represent the block indentation level
77+
78+
with function To_Node
79+
(E : Element) return Libadalang.Analysis.Ada_Node'Class;
80+
6381
package LSP.Ada_Completions.Generic_Assoc is
6482
procedure Propose_Completion
6583
(Self :
@@ -71,4 +89,14 @@ package LSP.Ada_Completions.Generic_Assoc is
7189
Filter : in out LSP.Ada_Completions.Filters.Filter;
7290
Names : in out Ada_Completions.Completion_Maps.Map;
7391
Unsorted_Res : in out LSP.Messages.CompletionItem_Vector);
92+
93+
procedure Propose_Signatures
94+
(Context : not null LSP.Ada_Handlers.Context_Access;
95+
Node : Libadalang.Analysis.Ada_Node;
96+
Cursor : Langkit_Support.Slocs.Source_Location;
97+
Prev_Signatures : LSP.Messages.Optional_SignatureHelpContext;
98+
Res : in out LSP.Messages.SignatureHelp;
99+
Lazy : Boolean := False);
100+
-- If Lazy, give up on trying to highlight the parameters when multiple
101+
-- signature are possible.
74102
end LSP.Ada_Completions.Generic_Assoc;

0 commit comments

Comments
 (0)