Skip to content

Commit 748dfb8

Browse files
author
mergerepo
committed
Merge remote branch 'origin/master' into edge
(no-precommit-check no-tn-check)
2 parents 8e86258 + 8ff5864 commit 748dfb8

21 files changed

+1448
-56
lines changed

source/ada/lsp-ada_completions-generic_assoc.adb

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

source/ada/lsp-ada_completions-names.adb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ package body LSP.Ada_Completions.Names is
6767
(Token, Exclude_Trivia => True)))
6868
= Libadalang.Common.Ada_Dot;
6969
begin
70+
7071
-- Get the outermost dotted name of which node is a prefix, so that when
7172
-- completing in a situation such as the following:
7273
--

source/ada/lsp-ada_completions-parameters.ads

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
-- A completion provider for parameters inside a call
1818

1919
with LSP.Ada_Handlers;
20+
with LSP.Ada_Documents;
2021

2122
package LSP.Ada_Completions.Parameters is
2223

2324
type Parameter_Completion_Provider
2425
(Context : not null LSP.Ada_Handlers.Context_Access;
26+
Document : LSP.Ada_Documents.Document_Access;
2527
Named_Notation_Threshold : Natural;
2628
Compute_Doc_And_Details : Boolean)
2729
is new Completion_Provider with null record;

0 commit comments

Comments
 (0)