Skip to content

Commit

Permalink
Merge branch 'gnatformat-issue_53' into 'master'
Browse files Browse the repository at this point in the history
Unparsing: Add config for PackageRenamingDecl and fix other renaming decls

Closes eng/ide/gnatformat#53

See merge request eng/libadalang/libadalang!1718
  • Loading branch information
joaopsazevedo committed Aug 1, 2024
2 parents 82027ed + 4ab8147 commit 01c9f10
Show file tree
Hide file tree
Showing 21 changed files with 83 additions and 22 deletions.
51 changes: 44 additions & 7 deletions extensions/default_unparsing_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3173,13 +3173,13 @@
{
"kind": "recurse_field",
"field": "f_renames"
},
{
"kind": "recurse_field",
"field": "f_aspects"
}
]
},
{
"kind": "recurse_field",
"field": "f_aspects"
},
{
"kind": "text",
"text": ";"
Expand All @@ -3188,7 +3188,7 @@
},
"fields": {
"f_aspects": [
"hardlineWithoutBreakParent",
"line",
"recurse"
]
}
Expand Down Expand Up @@ -4304,6 +4304,43 @@
]
}
},
"PackageRenamingDecl": {
"node": {
"kind": "group",
"document": [
{
"kind": "text",
"text": "package"
},
"whitespace",
{
"kind": "recurse_field",
"field": "f_name"
},
{
"kind": "continuationLineIndent",
"contents": {
"kind": "recurse_field",
"field": "f_renames"
}
},
{
"kind": "recurse_field",
"field": "f_aspects"
},
{
"kind": "text",
"text": ";"
}
]
},
"fields": {
"f_aspects": [
"line",
"recurse"
]
}
},
"ParamAssoc": {
"node": [
{
Expand Down Expand Up @@ -4925,12 +4962,12 @@
"node": {
"kind": "group",
"document": [
"whitespace",
"line",
{
"kind": "text",
"text": "renames"
},
"line",
"whitespace",
{
"kind": "recurse_field",
"field": "f_renamed_object"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Baaaaaaaaaaaaaaaaaaaaar : exception renames
Fooooooooooooooooooooooooooooooooooo
Baaaaaaaaaaaaaaaaaaaaar : exception
renames Fooooooooooooooooooooooooooooooooooo
with
Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Baaaaaaaaaaaaaaaaaaaaar : exception renames
Foooooooooooooooooooooooooooooooooo;
Baaaaaaaaaaaaaaaaaaaaar : exception
renames Foooooooooooooooooooooooooooooooooo;
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
generic package Foo
renames Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar
with Baz;
with Baz;
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
generic package Foo renames Bar
with Baz;
generic package Foo renames Bar with Baz;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
driver: unparser
rule: generic_renaming_decl
description: |
Test the line break before the `with` keyword.
Test that no line break is added before the `with` keyword.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Fooooooooooooooooooooooooooooooooo renames
Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar;
Fooooooooooooooooooooooooooooooooo
renames Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar;
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
Fooooooooooooooooo :
aliased constant Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa renames Baaaaaaaaaaaaaaaz;

Fooooooooooooooooo : aliased constant Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa renames Baaaaaaaaaaaaaaaz;
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Fooooooooooooooooo :
aliased constant Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa renames
Baaaaaaaaaaaaaaaz;
aliased constant Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
renames Baaaaaaaaaaaaaaaz;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package Foo renames Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar;
2 changes: 2 additions & 0 deletions testsuite/tests/unparsing/package_renaming_decl/long/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package Foo
renames Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
driver: unparser
rule: package_renaming_decl
description: |
Test the line break before the `renames` keyword.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package Foo renames Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar with Baz;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package Foo
renames Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar
with Baz;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
driver: unparser
rule: package_renaming_decl
description: |
Test the line break before the `renames` and `with` keywords.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package Foo renames Bar;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package Foo renames Bar;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
driver: unparser
rule: package_renaming_decl
description: |
Test that no line breaks are added.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package Foo renames Bar with Baz;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package Foo renames Bar with Baz;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
driver: unparser
rule: package_renaming_decl
description: |
Test that no line break is added before the `with` keyword.

0 comments on commit 01c9f10

Please sign in to comment.