Skip to content

Commit

Permalink
Add table alignment to AggregateAssoc, ComponentDecl, ObjectDecl, Par…
Browse files Browse the repository at this point in the history
…amAssoc and ParamSpec
  • Loading branch information
joaopsazevedo committed Jul 29, 2024
1 parent 43b2168 commit ba6a5e9
Show file tree
Hide file tree
Showing 24 changed files with 434 additions and 318 deletions.
624 changes: 336 additions & 288 deletions extensions/default_unparsing_config.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion testsuite/tests/unparsing/aggregate/long_complete/test.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Foo :=
(Baaaar with
Qux => Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
Qux => Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
Baaaz => Bazzzzzzzz);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Foo :=
[Baaaar with
Qux => Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
Qux => Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
Baaaz => Bazzzzzzzz];
1 change: 1 addition & 0 deletions testsuite/tests/unparsing/call_stmt/long_params/input.ada
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ada.Text_IO.Put_Line (Foooooooooooo, Prettier_Ada.Documents.Json.Serialize (Document));
2 changes: 2 additions & 0 deletions testsuite/tests/unparsing/call_stmt/long_params/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Ada.Text_IO.Put_Line
(Foooooooooooo, Prettier_Ada.Documents.Json.Serialize (Document));
5 changes: 5 additions & 0 deletions testsuite/tests/unparsing/call_stmt/long_params/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
driver: unparser
rule: stmt
description: |
Tests that if the statement is too long, the underlying `CallExpr` breaks.
Additionally, this that if the `f_suffix` fits, it does not break.
6 changes: 3 additions & 3 deletions testsuite/tests/unparsing/call_stmt/param_align/test.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Foo
(AAAA => Foo_1,
BB => Foo_2,
CCCCCCC => Foo_3,
(AAAA => Foo_1,
BB => Foo_2,
CCCCCCC => Foo_3,
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD => 7);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
for VeeeeeeeeeeeeryLoooooooooooongTyyyyyyyyyyyyyyyyypeNaaaaaaaaaaaame use
(Aaaaaaaaaaaa => 1,
Bbbbbbbbbbb => 5,
Ccccccccc => 10,
Dddd => 1,
E => 5,
F => 10);
Bbbbbbbbbbb => 5,
Ccccccccc => 10,
Dddd => 1,
E => 5,
F => 10);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
for T use
(Aaaaaaaaaaaa => 1,
Bbbbbbbbbbb => 5,
Ccccccccc => 10,
Dddd => 1,
E => 5,
F => 10);
Bbbbbbbbbbb => 5,
Ccccccccc => 10,
Dddd => 1,
E => 5,
F => 10);
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package Foo is new
"-j",
"--jobs",
Garply => Natural,
Corge => 1,
Fred =>
Corge => 1,
Fred =>
"Maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaax",
Bar => Bar_Foo);
Bar => Bar_Foo);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
generic
function Perform_Comparison_Check
(Comparing_Value : Foo_Bar_Baz;
Rule_Value : Foo_Bar_Baz;
Logic_Operator : Unbounded_String) return Boolean;
Rule_Value : Foo_Bar_Baz;
Logic_Operator : Unbounded_String) return Boolean;
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ generic
type Foo_Bar_Baz is private;
with
function ">"
(Left_Left_Left_Left_Left : Foo_Bar_Baz;
(Left_Left_Left_Left_Left : Foo_Bar_Baz;
Right_Right_Right_Right_Right : Foo_Bar_Baz) return Boolean is <>;
function Perform_Comparison_Check
(Comparing_Value : Foo_Bar_Baz;
Rule_Value : Foo_Bar_Baz;
Logic_Operator : Unbounded_String) return Boolean;
Rule_Value : Foo_Bar_Baz;
Logic_Operator : Unbounded_String) return Boolean;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function Foo is new
"-j",
"--jobs",
Garply => Natural,
Corge => 1,
Fred =>
Corge => 1,
Fred =>
"Maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaax",
Bar => Bar_Foo);
Bar => Bar_Foo);
9 changes: 9 additions & 0 deletions testsuite/tests/unparsing/object_decl/table/input.ada
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
procedure Main is
AAAAAAAAAAAAAAAA : Baaaaaar := Bar;
BBBBBBBBBBBBBBBBBBBB : Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz :=
Bazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz;
CCCCCCCCCCCCCCCCCCCCCCCCCCCC : Quuuuuuuuuuuuuuuuuux := Qux;
DDDDDDDDDDDDDDD : Corge;
begin
null;
end Main;
11 changes: 11 additions & 0 deletions testsuite/tests/unparsing/object_decl/table/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
procedure Main
is
AAAAAAAAAAAAAAAA : Baaaaaar := Bar;
BBBBBBBBBBBBBBBBBBBB :
Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz :=
Bazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz;
CCCCCCCCCCCCCCCCCCCCCCCCCCCC : Quuuuuuuuuuuuuuuuuux := Qux;
DDDDDDDDDDDDDDD : Corge;
begin
null;
end Main;
6 changes: 6 additions & 0 deletions testsuite/tests/unparsing/object_decl/table/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
driver: unparser
rule: subp_body
description: |
Test the alignemnt of the `:` and `:=` tokens on `ObjectDecl` nodes.
Also test continuation line indentation when they're followed by a line
break.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type Date is
record
A : Integer range 1 .. 31 := 15;
B : Real := 0.15;
C : String := "my_str";
B : Real := 0.15;
C : String := "my_str";
end record;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type Date is
record
Day : Integer range 1 .. 31;
Day : Integer range 1 .. 31;
Month : Month_Enum;
Year : Integer range 0 .. 4000;
Year : Integer range 0 .. 4000;
end record;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function Foo
(AAAAAAAAAAAA : Bar;
BBBBBBBBBBBBB : Baz;
CCCCCCCCCCCCCC : Qux;
DDDDDDDDDDDDDDD : Corge) return Freeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function Foo
(AAAAAAAAAAAA : Bar;
BBBBBBBBBBBBB : Baz;
CCCCCCCCCCCCCC : Qux;
DDDDDDDDDDDDDDD : Corge)
return Freeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
driver: unparser
rule: subp_spec
description: |
Test that parameters ids of different length are aligned by the `:` token.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function Foo
(AAAAAAAAAAAAAAAA : Baaaaaar := Bar;
BBBBBBBBBBBBBBBBBBBB : Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz := Bazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz;
CCCCCCCCCCCCCCCCCCCCCCCCCCCC : Quuuuuuuuuuuuuuuuuux := Qux;
DDDDDDDDDDDDDDD : Corge) return Freeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function Foo
(AAAAAAAAAAAAAAAA : Baaaaaar := Bar;
BBBBBBBBBBBBBBBBBBBB :
Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz :=
Bazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz;
CCCCCCCCCCCCCCCCCCCCCCCCCCCC : Quuuuuuuuuuuuuuuuuux := Qux;
DDDDDDDDDDDDDDD : Corge)
return Freeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeed
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
driver: unparser
rule: subp_spec
description: |
Test the alignemnt of the `:` and `:=` tokens on `ParamSpec` nodes.
Also test continuation line indentation when they're followed by a line
break.

0 comments on commit ba6a5e9

Please sign in to comment.