Skip to content

Commit

Permalink
Merge branch 'issue_1331' into 'master'
Browse files Browse the repository at this point in the history
Unparsing: add configuration for NumberDecl

Closes #1331

See merge request eng/libadalang/libadalang!1597
  • Loading branch information
joaopsazevedo committed Mar 27, 2024
2 parents 3c58fd1 + d7910ad commit 13c852a
Show file tree
Hide file tree
Showing 9 changed files with 360 additions and 0 deletions.
66 changes: 66 additions & 0 deletions extensions/default_unparsing_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2817,6 +2817,72 @@
}
}
},
"NumberDecl": {
"node": {
"kind": "group",
"document": [
{
"kind": "group",
"document": {
"kind": "align",
"width": 2,
"contents": [
{
"kind": "recurse_field",
"field": "f_ids"
},
"whitespace",
{
"kind": "text",
"text": ":"
},
"line",
{
"kind": "text",
"text": "constant"
},
"whitespace",
{
"kind": "text",
"text": ":="
}
]
},
"id": "constant_ids"
},
{
"kind": "ifBreak",
"breakContents": {
"kind": "align",
"width": 4,
"contents": [
"line",
{
"kind": "recurse_field",
"field": "f_expr"
}
]
},
"flatContents": {
"kind": "align",
"width": 2,
"contents": [
"line",
{
"kind": "recurse_field",
"field": "f_expr"
}
]
},
"groupId": "constant_ids"
},
{
"kind": "text",
"text": ";"
}
]
}
},
"ObjectDecl": {
"node": {
"kind": "group",
Expand Down
140 changes: 140 additions & 0 deletions testsuite/tests/unparsing/number_decl/long/doc-baseline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"id": 17,
"kind": "command",
"command": {
"command": "group",
"id": 0,
"groupContents": {
"id": 16,
"kind": "list",
"list": [
{
"id": 5,
"kind": "command",
"command": {
"command": "group",
"id": 1,
"groupContents": {
"id": 4,
"kind": "command",
"command": {
"command": "align",
"alignData": {
"kind": "width",
"n": 2
},
"alignContents": {
"id": 3,
"kind": "list",
"list": [
{
"id": 0,
"kind": "text",
"text": "Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo :"
},
{
"id": 1,
"kind": "command",
"command": {
"command": "line",
"literal": false,
"soft": false,
"hard": false
}
},
{
"id": 2,
"kind": "text",
"text": "constant :="
}
]
}
}
},
"break": false,
"expandedStates": null
}
},
{
"id": 14,
"kind": "command",
"command": {
"command": "ifBreak",
"ifBreakGroupId": 1,
"breakContents": {
"id": 9,
"kind": "command",
"command": {
"command": "align",
"alignData": {
"kind": "width",
"n": 4
},
"alignContents": {
"id": 8,
"kind": "list",
"list": [
{
"id": 6,
"kind": "command",
"command": {
"command": "line",
"literal": false,
"soft": false,
"hard": false
}
},
{
"id": 7,
"kind": "text",
"text": "12222222222222222222222222222222222222222222222222222222222222222"
}
]
}
}
},
"flatContents": {
"id": 13,
"kind": "command",
"command": {
"command": "align",
"alignData": {
"kind": "width",
"n": 2
},
"alignContents": {
"id": 12,
"kind": "list",
"list": [
{
"id": 10,
"kind": "command",
"command": {
"command": "line",
"literal": false,
"soft": false,
"hard": false
}
},
{
"id": 11,
"kind": "text",
"text": "12222222222222222222222222222222222222222222222222222222222222222"
}
]
}
}
}
}
},
{
"id": 15,
"kind": "text",
"text": ";"
}
]
},
"break": false,
"expandedStates": null
}
}
1 change: 1 addition & 0 deletions testsuite/tests/unparsing/number_decl/long/input.ada
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo : constant := 12222222222222222222222222222222222222222222222222222222222222222;
3 changes: 3 additions & 0 deletions testsuite/tests/unparsing/number_decl/long/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo :
constant :=
12222222222222222222222222222222222222222222222222222222222222222;
4 changes: 4 additions & 0 deletions testsuite/tests/unparsing/number_decl/long/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
driver: unparser
rule: number_decl
description: |
Test the line breaks and indentation after the `:` and `:=` tokens.
140 changes: 140 additions & 0 deletions testsuite/tests/unparsing/number_decl/short/doc-baseline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"id": 17,
"kind": "command",
"command": {
"command": "group",
"id": 0,
"groupContents": {
"id": 16,
"kind": "list",
"list": [
{
"id": 5,
"kind": "command",
"command": {
"command": "group",
"id": 1,
"groupContents": {
"id": 4,
"kind": "command",
"command": {
"command": "align",
"alignData": {
"kind": "width",
"n": 2
},
"alignContents": {
"id": 3,
"kind": "list",
"list": [
{
"id": 0,
"kind": "text",
"text": "Foo :"
},
{
"id": 1,
"kind": "command",
"command": {
"command": "line",
"literal": false,
"soft": false,
"hard": false
}
},
{
"id": 2,
"kind": "text",
"text": "constant :="
}
]
}
}
},
"break": false,
"expandedStates": null
}
},
{
"id": 14,
"kind": "command",
"command": {
"command": "ifBreak",
"ifBreakGroupId": 1,
"breakContents": {
"id": 9,
"kind": "command",
"command": {
"command": "align",
"alignData": {
"kind": "width",
"n": 4
},
"alignContents": {
"id": 8,
"kind": "list",
"list": [
{
"id": 6,
"kind": "command",
"command": {
"command": "line",
"literal": false,
"soft": false,
"hard": false
}
},
{
"id": 7,
"kind": "text",
"text": "12"
}
]
}
}
},
"flatContents": {
"id": 13,
"kind": "command",
"command": {
"command": "align",
"alignData": {
"kind": "width",
"n": 2
},
"alignContents": {
"id": 12,
"kind": "list",
"list": [
{
"id": 10,
"kind": "command",
"command": {
"command": "line",
"literal": false,
"soft": false,
"hard": false
}
},
{
"id": 11,
"kind": "text",
"text": "12"
}
]
}
}
}
}
},
{
"id": 15,
"kind": "text",
"text": ";"
}
]
},
"break": false,
"expandedStates": null
}
}
1 change: 1 addition & 0 deletions testsuite/tests/unparsing/number_decl/short/input.ada
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Foo : constant := 12;
1 change: 1 addition & 0 deletions testsuite/tests/unparsing/number_decl/short/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Foo : constant := 12;
4 changes: 4 additions & 0 deletions testsuite/tests/unparsing/number_decl/short/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
driver: unparser
rule: number_decl
description: |
Test that no line break are added.

0 comments on commit 13c852a

Please sign in to comment.