Skip to content

Commit 01325a9

Browse files
BoulangerAnthonyLeonardoGracio
authored andcommitted
Prevent GNATpp from breaking the snippet placeholder mechanism
Closes eng/ide/ada_language_server#1607 (cherry picked from commit 55889dd)
1 parent 55ee432 commit 01325a9

File tree

6 files changed

+475
-4
lines changed

6 files changed

+475
-4
lines changed

source/ada/lsp-ada_completions.adb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ with VSS.Strings.Conversions;
2525
with VSS.Strings.Cursors.Iterators.Characters;
2626
with VSS.Strings.Cursors.Markers;
2727
with VSS.Strings.Hash;
28+
with VSS.Transformers.Casing;
2829

2930
with LSP.Ada_Configurations;
3031
with LSP.Ada_Contexts;
@@ -198,7 +199,7 @@ package body LSP.Ada_Completions is
198199

199200
Encoding : Encoding_Maps.Map;
200201
-- Map of Snippet fake name to snippet:
201-
-- {"Foo_1" : "$1", "Foo_2" : "${2: Integer}"}
202+
-- {"foobar_1" : "$1", "foobar_2" : "${2: Integer}"}
202203
-- $0 will not be replaced
203204

204205
procedure Set_PP_Switches
@@ -212,7 +213,7 @@ package body LSP.Ada_Completions is
212213
-- Recreate the snippet via the pseudo code
213214

214215
function Snippet_Placeholder (S : Virtual_String) return Virtual_String
215-
is ("FooBar_" & S);
216+
is ("foobar_" & S);
216217
-- Generate a fake entity for a snippet (S is the index of the snippet)
217218
-- The length of the placeholder will affect where the strings is cut
218219
-- to avoid exceeding line length => 8/9 characters seems to be
@@ -369,7 +370,11 @@ package body LSP.Ada_Completions is
369370
Dummy := Pos.Backward;
370371
Append (Res, U.Slice (Iterator, Pos));
371372
end;
372-
Append (Res, Encoding (Match.Captured));
373+
Append
374+
(Res,
375+
Encoding
376+
(VSS.Transformers.Casing.To_Lowercase.Transform
377+
(Match.Captured)));
373378
Iterator.Set_At (Match.Last_Marker);
374379
Dummy := Iterator.Forward;
375380
end;
@@ -393,7 +398,9 @@ package body LSP.Ada_Completions is
393398
is
394399
Placeholder_Regexp : constant VSS.Regular_Expressions.
395400
Regular_Expression := VSS.Regular_Expressions.To_Regular_Expression
396-
("FooBar_[0-9]+");
401+
("FooBar_[0-9]+",
402+
Options => [VSS.Regular_Expressions.Case_Insensitive => True,
403+
others => False]);
397404
begin
398405
return Placeholder_Regexp.Match (S, Start);
399406
end Find_Next_Placeholder;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
project Default is
2+
package Pretty_Printer is
3+
for Switches ("Ada") use ("--name-lower-case");
4+
end Pretty_Printer;
5+
end Default;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
procedure Foo is
2+
3+
procedure Bar (A, B, C, D, E, F, G, H, I, J : Integer);
4+
5+
procedure Bar (AAAAAAAA, BB, CCCCCCCC, DDDDDDDDDDDD, E : Integer);
6+
7+
procedure Bar (A, B : Integer);
8+
9+
procedure Bar (A, B, C, D, E, F, G, H, I, J : Integer) is
10+
begin
11+
null;
12+
end Bar;
13+
14+
procedure Bar (AAAAAAAA, BB, CCCCCCCC, DDDDDDDDDDDD, E : Integer) is
15+
begin
16+
null;
17+
end Bar;
18+
19+
procedure Bar (A, B : Integer) is
20+
begin
21+
null;
22+
end Bar;
23+
begin
24+
Bar (
25+
end Foo;

0 commit comments

Comments
 (0)