@@ -37,7 +37,7 @@ package body LSP.Ada_Completions.Generic_Assoc is
3737 Names : in out Ada_Completions.Completion_Maps.Map;
3838 Unsorted_Res : in out LSP.Messages.CompletionItem_Vector)
3939 is
40- pragma Unreferenced (Filter, Sloc, Names);
40+ pragma Unreferenced (Filter, Names);
4141 use Libadalang.Analysis;
4242 use Libadalang.Common;
4343 use LSP.Ada_Completions.Generic_Assoc_Utils;
@@ -49,6 +49,12 @@ package body LSP.Ada_Completions.Generic_Assoc is
4949
5050 Designators : Laltools.Common.Node_Vectors.Vector;
5151
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+
5258 function Match_Designators
5359 (Child : Laltools.Common.Node_Vectors.Vector;
5460 Parent : Laltools.Common.Node_Vectors.Vector)
@@ -120,8 +126,10 @@ package body LSP.Ada_Completions.Generic_Assoc is
120126 Snippet_Index : Integer :=
121127 Integer (Spec_Designators.Length);
122128 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));
125133 begin
126134 if Match_Designators (Designators, Spec_Designators) then
127135
@@ -229,8 +237,7 @@ package body LSP.Ada_Completions.Generic_Assoc is
229237 and then Token_Kind in Ada_Par_Open | Ada_Comma
230238 then
231239 declare
232- Last :
233- VSS.Strings.Character_Iterators.Character_Iterator
240+ Last : VSS.Strings.Character_Iterators.Character_Iterator
234241 := Params_Snippet.At_Last_Character;
235242 Success : Boolean with Unreferenced;
236243
@@ -249,7 +256,7 @@ package body LSP.Ada_Completions.Generic_Assoc is
249256 Params_Snippet.Prepend (Snippet_Prefix);
250257
251258 declare
252- Item : LSP.Messages.CompletionItem;
259+ Item : LSP.Messages.CompletionItem;
253260 begin
254261 Item.label := Title;
255262 Item.insertTextFormat :=
@@ -264,6 +271,13 @@ package body LSP.Ada_Completions.Generic_Assoc is
264271 Item => Item,
265272 Compute_Doc_And_Details =>
266273 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);
267281 Unsorted_Res.Append (Item);
268282 end ;
269283 end if ;
@@ -275,6 +289,14 @@ package body LSP.Ada_Completions.Generic_Assoc is
275289 return ;
276290 end if ;
277291
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+
278300 Designators := Get_Designators (Elem_Node);
279301
280302 if Token_Kind = Ada_Whitespace then
0 commit comments