@@ -37,7 +37,7 @@ package body LSP.Ada_Completions.Generic_Assoc is
37
37
Names : in out Ada_Completions.Completion_Maps.Map;
38
38
Unsorted_Res : in out LSP.Messages.CompletionItem_Vector)
39
39
is
40
- pragma Unreferenced (Filter, Sloc, Names);
40
+ pragma Unreferenced (Filter, Names);
41
41
use Libadalang.Analysis;
42
42
use Libadalang.Common;
43
43
use LSP.Ada_Completions.Generic_Assoc_Utils;
@@ -49,6 +49,12 @@ package body LSP.Ada_Completions.Generic_Assoc is
49
49
50
50
Designators : Laltools.Common.Node_Vectors.Vector;
51
51
52
+ Prefix : VSS.Strings.Virtual_String;
53
+ -- The whole string before the snippet (including whitespaces)
54
+
55
+ Prefix_Span : LSP.Messages.Span;
56
+ -- The span covering Prefix.
57
+
52
58
function Match_Designators
53
59
(Child : Laltools.Common.Node_Vectors.Vector;
54
60
Parent : Laltools.Common.Node_Vectors.Vector)
@@ -120,8 +126,10 @@ package body LSP.Ada_Completions.Generic_Assoc is
120
126
Snippet_Index : Integer :=
121
127
Integer (Spec_Designators.Length);
122
128
Use_Named_Notation : constant Boolean :=
123
- Limit > 0
124
- and then (Snippet_Index = 1 or else Snippet_Index >= Limit);
129
+ (not Designators.Is_Empty)
130
+ or else (Limit > 0
131
+ and then (Snippet_Index = 1
132
+ or else Snippet_Index >= Limit));
125
133
begin
126
134
if Match_Designators (Designators, Spec_Designators) then
127
135
@@ -229,8 +237,7 @@ package body LSP.Ada_Completions.Generic_Assoc is
229
237
and then Token_Kind in Ada_Par_Open | Ada_Comma
230
238
then
231
239
declare
232
- Last :
233
- VSS.Strings.Character_Iterators.Character_Iterator
240
+ Last : VSS.Strings.Character_Iterators.Character_Iterator
234
241
:= Params_Snippet.At_Last_Character;
235
242
Success : Boolean with Unreferenced;
236
243
@@ -249,7 +256,7 @@ package body LSP.Ada_Completions.Generic_Assoc is
249
256
Params_Snippet.Prepend (Snippet_Prefix);
250
257
251
258
declare
252
- Item : LSP.Messages.CompletionItem;
259
+ Item : LSP.Messages.CompletionItem;
253
260
begin
254
261
Item.label := Title;
255
262
Item.insertTextFormat :=
@@ -264,6 +271,13 @@ package body LSP.Ada_Completions.Generic_Assoc is
264
271
Item => Item,
265
272
Compute_Doc_And_Details =>
266
273
Self.Compute_Doc_And_Details);
274
+ Pretty_Print_Snippet
275
+ (Context => Self.Context.all ,
276
+ Prefix =>
277
+ VSS.Strings.Conversions.To_UTF_8_String (Prefix),
278
+ Span => Prefix_Span,
279
+ Rule => Libadalang.Common.Param_Assoc_Rule,
280
+ Result => Item);
267
281
Unsorted_Res.Append (Item);
268
282
end ;
269
283
end if ;
@@ -275,6 +289,14 @@ package body LSP.Ada_Completions.Generic_Assoc is
275
289
return ;
276
290
end if ;
277
291
292
+ Prefix_Span :=
293
+ Self.Document.To_LSP_Range
294
+ (Langkit_Support.Slocs.Make_Range
295
+ (Langkit_Support.Slocs.Start_Sloc (Node.Parent.Sloc_Range),
296
+ Sloc));
297
+ Prefix := Self.Document.Get_Text_At
298
+ (Prefix_Span.first, Prefix_Span.last);
299
+
278
300
Designators := Get_Designators (Elem_Node);
279
301
280
302
if Token_Kind = Ada_Whitespace then
0 commit comments