Skip to content

Commit 86d3087

Browse files
author
mergerepo
committed
Merge remote branch 'origin/master' into edge
(no-precommit-check no-tn-check)
2 parents a55dccf + 0ace5e7 commit 86d3087

File tree

105 files changed

+143
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+143
-17
lines changed

source/ada/lsp-ada_completions-parameters.adb

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,14 @@ package body LSP.Ada_Completions.Parameters is
4646
use Libadalang.Analysis;
4747
use Libadalang.Common;
4848

49-
Call_Expr_Node : constant Libadalang.Analysis.Call_Expr :=
49+
Call_Expr_Node : constant Libadalang.Analysis.Call_Expr :=
5050
LSP.Lal_Utils.Get_Call_Expr (Node);
51-
Token_Kind : Libadalang.Common.Token_Kind :=
51+
Token_Kind : Libadalang.Common.Token_Kind :=
5252
Kind (Data (Token));
53-
Designators : Laltools.Common.Node_Vectors.Vector;
53+
Whitespace_Prefix : LSP_String := Empty_LSP_String;
54+
-- Empty if we already have a whitespace before a ","
55+
56+
Designators : Laltools.Common.Node_Vectors.Vector;
5457

5558
function Is_Present (Id_Text : Text_Type) return Boolean;
5659
-- Return True if Id_Name match one of the designators
@@ -78,6 +81,8 @@ package body LSP.Ada_Completions.Parameters is
7881

7982
if Token_Kind = Ada_Whitespace then
8083
Token_Kind := Kind (Data (Previous (Token, Exclude_Trivia => True)));
84+
elsif Token_Kind = Ada_Comma then
85+
Whitespace_Prefix := Whitespace_Prefix & " ";
8186
end if;
8287

8388
declare
@@ -119,7 +124,9 @@ package body LSP.Ada_Completions.Parameters is
119124
Item.label := To_Virtual_String (Name);
120125
Item.insertTextFormat :=
121126
(True, LSP.Messages.PlainText);
122-
Item.insertText := (True, Name & " => ");
127+
Item.insertText :=
128+
(True,
129+
Whitespace_Prefix & Name & " => ");
123130
Item.kind := (True, LSP.Messages.Text);
124131
Result.items.Append (Item);
125132
end if;
@@ -139,7 +146,9 @@ package body LSP.Ada_Completions.Parameters is
139146
end loop;
140147

141148
-- If the string is empty => nothing to do
142-
if Params_Snippet /= Empty_LSP_String then
149+
if Params_Snippet /= Empty_LSP_String
150+
and then Token_Kind in Ada_Par_Open | Ada_Comma
151+
then
143152
-- Remove the last 2 characters which are ", " and
144153
-- replace it by ")" and the final tab stop
145154
Params_Snippet := Unbounded_Slice
@@ -156,7 +165,8 @@ package body LSP.Ada_Completions.Parameters is
156165
(Snippet_Name);
157166
Item.insertTextFormat :=
158167
(True, LSP.Messages.Snippet);
159-
Item.insertText := (True, Params_Snippet);
168+
Item.insertText :=
169+
(True, Whitespace_Prefix & Params_Snippet);
160170
Item.kind := (True, LSP.Messages.Snippet);
161171
Result.items.Append (Item);
162172
end if;

source/ada/lsp-ada_completions-parameters.ads

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ package LSP.Ada_Completions.Parameters is
3232
Filter : in out LSP.Ada_Completions.Filters.Filter;
3333
Names : out Ada_Completions.Completion_Maps.Map;
3434
Result : out LSP.Messages.CompletionList);
35-
-- Get completion for keywords, filtering them with the prefix.
35+
-- Using the context, check if we are inside a function call and get its
36+
-- unset parameters while filtering them with the prefix.
3637

3738
end LSP.Ada_Completions.Parameters;

source/ada/lsp-ada_documents.adb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,6 +2227,11 @@ package body LSP.Ada_Documents is
22272227

22282228
Filter : LSP.Ada_Completions.Filters.Filter;
22292229
begin
2230+
if Node.Kind in Libadalang.Common.Ada_String_Literal_Range then
2231+
-- Do nothing when inside a string
2232+
return;
2233+
end if;
2234+
22302235
Context.Trace.Trace
22312236
("Getting completions, Pos = ("
22322237
& Sloc.Line'Image & ", " & Sloc.Column'Image & ") Node = "

source/ada/lsp-ada_handlers.adb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,8 @@ package body LSP.Ada_Handlers is
721721
Response.result.capabilities.completionProvider :=
722722
(True,
723723
(resolveProvider => LSP.Types.True,
724-
triggerCharacters => (True, Empty_Vector & (+".") & (+"(")),
724+
triggerCharacters => (True,
725+
Empty_Vector & (+".") & (+",") & (+"(")),
725726
allCommitCharacters => (Is_Set => False),
726727
workDoneProgress => LSP.Types.None));
727728
Response.result.capabilities.hoverProvider :=

source/protocol/lsp-generic_notifications.adb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
with VSS.Strings.Conversions;
1919

20-
with LSP.Types;
2120
with LSP.Messages.Common_Writers;
2221

2322
package body LSP.Generic_Notifications is
@@ -81,6 +80,18 @@ package body LSP.Generic_Notifications is
8180
raise Program_Error;
8281
end Visit;
8382

83+
-----------
84+
-- Visit --
85+
-----------
86+
87+
procedure Visit
88+
(Self : Notification;
89+
Token : LSP.Types.LSP_Number_Or_String;
90+
Handler : access Visitor) is
91+
begin
92+
raise Program_Error;
93+
end Visit;
94+
8495
-----------
8596
-- Write --
8697
-----------

source/protocol/lsp-generic_notifications.ads

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ with Ada.Streams;
2222

2323
with LSP.JSON_Streams;
2424
with LSP.Messages;
25+
with LSP.Types;
2526

2627
generic
2728
type Base_Message is abstract new LSP.Messages.NotificationMessage
@@ -45,6 +46,11 @@ package LSP.Generic_Notifications is
4546
(Self : Notification;
4647
Handler : access Visitor);
4748

49+
procedure Visit
50+
(Self : Notification;
51+
Token : LSP.Types.LSP_Number_Or_String;
52+
Handler : access Visitor);
53+
4854
procedure Read
4955
(S : access Ada.Streams.Root_Stream_Type'Class;
5056
V : out Notification);

testsuite/ada_lsp/C825-005.xrefs.extending/test.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"completionProvider": {
4242
"triggerCharacters": [
4343
".",
44+
",",
4445
"("
4546
],
4647
"resolveProvider": true

testsuite/ada_lsp/D301-004.xrefs.generics/test.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"completionProvider": {
4242
"triggerCharacters": [
4343
".",
44+
",",
4445
"("
4546
],
4647
"resolveProvider": true

testsuite/ada_lsp/D803-003.xrefs.generics_go_to_body/test.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"completionProvider": {
4242
"triggerCharacters": [
4343
".",
44+
",",
4445
"("
4546
],
4647
"resolveProvider": true

testsuite/ada_lsp/F131-024.xrefs.separate_body/test.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"completionProvider": {
4949
"triggerCharacters": [
5050
".",
51+
",",
5152
"("
5253
],
5354
"resolveProvider": true

0 commit comments

Comments
 (0)