diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index 32c19ca18..d71891c43 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -6,6 +6,85 @@ "hardline" ] }, + "Aggregate": { + "node": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "(" + }, + { + "kind": "align", + "width": 1, + "contents": [ + { + "kind": "recurse_field", + "field": "f_ancestor_expr" + }, + { + "kind": "innerRoot", + "contents": { + "kind": "recurse_field", + "field": "f_assocs" + } + } + ] + }, + { + "kind": "text", + "text": ")" + } + ] + }, + "fields": { + "f_ancestor_expr": { + "kind": "align", + "width": 2, + "contents": [ + "recurse", + { + "kind": "text", + "text": "with" + }, + "line" + ] + } + } + }, + "AggregateAssoc": { + "node": { + "kind": "group", + "document": [ + { + "kind": "recurse_field", + "field": "f_designators" + }, + { + "kind": "innerRoot", + "contents": { + "kind": "recurse_field", + "field": "f_r_expr" + } + } + ] + }, + "fields": { + "f_designators": { + "kind": "align", + "width": 2, + "contents": [ + "recurse", + "whitespace", + { + "kind": "text", + "text": "=>" + }, + "line" + ] + } + } + }, "AlternativesList": { "sep": [ "line", diff --git a/testsuite/tests/unparsing/aggregate/long_complete/doc-baseline.json b/testsuite/tests/unparsing/aggregate/long_complete/doc-baseline.json new file mode 100644 index 000000000..6252ffe87 --- /dev/null +++ b/testsuite/tests/unparsing/aggregate/long_complete/doc-baseline.json @@ -0,0 +1,279 @@ +{ + "id": 35, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 34, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 33, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "Foo :=" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 31, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 30, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "text", + "text": "(" + }, + { + "id": 28, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 27, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "text", + "text": "Baaaar with" + }, + { + "id": 4, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 26, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 25, + "kind": "list", + "list": [ + { + "id": 14, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 13, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 9, + "kind": "list", + "list": [ + { + "id": 7, + "kind": "text", + "text": "Qux =>" + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 11, + "kind": "text", + "text": "Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 15, + "kind": "text", + "text": "," + }, + { + "id": 16, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 24, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 23, + "kind": "list", + "list": [ + { + "id": 20, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 19, + "kind": "list", + "list": [ + { + "id": 17, + "kind": "text", + "text": "Baaaz =>" + }, + { + "id": 18, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 22, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 21, + "kind": "text", + "text": "Bazzzzzzzz" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + } + } + }, + { + "id": 29, + "kind": "text", + "text": ")" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 32, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } +} diff --git a/testsuite/tests/unparsing/aggregate/long_complete/input.ada b/testsuite/tests/unparsing/aggregate/long_complete/input.ada new file mode 100644 index 000000000..ef55002e5 --- /dev/null +++ b/testsuite/tests/unparsing/aggregate/long_complete/input.ada @@ -0,0 +1 @@ +Foo := (Baaaar with Qux => Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, Baaaz => Bazzzzzzzz); diff --git a/testsuite/tests/unparsing/aggregate/long_complete/test.out b/testsuite/tests/unparsing/aggregate/long_complete/test.out new file mode 100644 index 000000000..2eab88116 --- /dev/null +++ b/testsuite/tests/unparsing/aggregate/long_complete/test.out @@ -0,0 +1,4 @@ +Foo := + (Baaaar with + Qux => Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + Baaaz => Bazzzzzzzz); diff --git a/testsuite/tests/unparsing/aggregate/long_complete/test.yaml b/testsuite/tests/unparsing/aggregate/long_complete/test.yaml new file mode 100644 index 000000000..b85264fde --- /dev/null +++ b/testsuite/tests/unparsing/aggregate/long_complete/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: stmt +description: | + Test that no line breaks are added. diff --git a/testsuite/tests/unparsing/aggregate/long_no_ancestor_expr/doc-baseline.json b/testsuite/tests/unparsing/aggregate/long_no_ancestor_expr/doc-baseline.json new file mode 100644 index 000000000..912a1b1ff --- /dev/null +++ b/testsuite/tests/unparsing/aggregate/long_no_ancestor_expr/doc-baseline.json @@ -0,0 +1,247 @@ +{ + "id": 31, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 30, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 29, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "Foo :=" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 27, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 26, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "text", + "text": "(" + }, + { + "id": 24, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 23, + "kind": "list", + "list": [ + { + "id": 22, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 21, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 9, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "text", + "text": "Baz =>" + }, + { + "id": 4, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 7, + "kind": "text", + "text": "Baaaaaaaaaaaaaaaaaaaz" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 11, + "kind": "text", + "text": "," + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "list", + "list": [ + { + "id": 16, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 13, + "kind": "text", + "text": "Quuuuuux =>" + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 18, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 17, + "kind": "text", + "text": "Quuuuuuuuuuuuuuuuuuuuuuuuuux" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + } + } + }, + { + "id": 25, + "kind": "text", + "text": ")" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 28, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } +} diff --git a/testsuite/tests/unparsing/aggregate/long_no_ancestor_expr/input.ada b/testsuite/tests/unparsing/aggregate/long_no_ancestor_expr/input.ada new file mode 100644 index 000000000..c70293033 --- /dev/null +++ b/testsuite/tests/unparsing/aggregate/long_no_ancestor_expr/input.ada @@ -0,0 +1 @@ +Foo := (Baz => Baaaaaaaaaaaaaaaaaaaz, Quuuuuux => Quuuuuuuuuuuuuuuuuuuuuuuuuux); diff --git a/testsuite/tests/unparsing/aggregate/long_no_ancestor_expr/test.out b/testsuite/tests/unparsing/aggregate/long_no_ancestor_expr/test.out new file mode 100644 index 000000000..2b02ec3e5 --- /dev/null +++ b/testsuite/tests/unparsing/aggregate/long_no_ancestor_expr/test.out @@ -0,0 +1,2 @@ +Foo := + (Baz => Baaaaaaaaaaaaaaaaaaaz, Quuuuuux => Quuuuuuuuuuuuuuuuuuuuuuuuuux); diff --git a/testsuite/tests/unparsing/aggregate/long_no_ancestor_expr/test.yaml b/testsuite/tests/unparsing/aggregate/long_no_ancestor_expr/test.yaml new file mode 100644 index 000000000..b85264fde --- /dev/null +++ b/testsuite/tests/unparsing/aggregate/long_no_ancestor_expr/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: stmt +description: | + Test that no line breaks are added. diff --git a/testsuite/tests/unparsing/aggregate/long_no_assoc_no_ancestor_expr/doc-baseline.json b/testsuite/tests/unparsing/aggregate/long_no_assoc_no_ancestor_expr/doc-baseline.json new file mode 100644 index 000000000..6b1c0b3f1 --- /dev/null +++ b/testsuite/tests/unparsing/aggregate/long_no_assoc_no_ancestor_expr/doc-baseline.json @@ -0,0 +1,183 @@ +{ + "id": 23, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 22, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 21, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "Foo :=" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 19, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 18, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "text", + "text": "(" + }, + { + "id": 16, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 14, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 13, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 3, + "kind": "text", + "text": "Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 7, + "kind": "text", + "text": "," + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 9, + "kind": "text", + "text": "Baz" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + } + } + }, + { + "id": 17, + "kind": "text", + "text": ")" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 20, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } +} diff --git a/testsuite/tests/unparsing/aggregate/long_no_assoc_no_ancestor_expr/input.ada b/testsuite/tests/unparsing/aggregate/long_no_assoc_no_ancestor_expr/input.ada new file mode 100644 index 000000000..6c863c399 --- /dev/null +++ b/testsuite/tests/unparsing/aggregate/long_no_assoc_no_ancestor_expr/input.ada @@ -0,0 +1,2 @@ +Foo := + (Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar, Baz); diff --git a/testsuite/tests/unparsing/aggregate/long_no_assoc_no_ancestor_expr/test.out b/testsuite/tests/unparsing/aggregate/long_no_assoc_no_ancestor_expr/test.out new file mode 100644 index 000000000..7b4781b70 --- /dev/null +++ b/testsuite/tests/unparsing/aggregate/long_no_assoc_no_ancestor_expr/test.out @@ -0,0 +1,3 @@ +Foo := + (Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar, + Baz); diff --git a/testsuite/tests/unparsing/aggregate/long_no_assoc_no_ancestor_expr/test.yaml b/testsuite/tests/unparsing/aggregate/long_no_assoc_no_ancestor_expr/test.yaml new file mode 100644 index 000000000..b85264fde --- /dev/null +++ b/testsuite/tests/unparsing/aggregate/long_no_assoc_no_ancestor_expr/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: stmt +description: | + Test that no line breaks are added. diff --git a/testsuite/tests/unparsing/aggregate/short_no_assoc_no_ancestor_expr/doc-baseline.json b/testsuite/tests/unparsing/aggregate/short_no_assoc_no_ancestor_expr/doc-baseline.json new file mode 100644 index 000000000..6dd608c67 --- /dev/null +++ b/testsuite/tests/unparsing/aggregate/short_no_assoc_no_ancestor_expr/doc-baseline.json @@ -0,0 +1,183 @@ +{ + "id": 23, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 22, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 21, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "Foo :=" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 19, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 18, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "text", + "text": "(" + }, + { + "id": 16, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 14, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 13, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 3, + "kind": "text", + "text": "Bar" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 7, + "kind": "text", + "text": "," + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 9, + "kind": "text", + "text": "Baz" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + } + } + }, + { + "id": 17, + "kind": "text", + "text": ")" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 20, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } +} diff --git a/testsuite/tests/unparsing/aggregate/short_no_assoc_no_ancestor_expr/input.ada b/testsuite/tests/unparsing/aggregate/short_no_assoc_no_ancestor_expr/input.ada new file mode 100644 index 000000000..ec8df24d6 --- /dev/null +++ b/testsuite/tests/unparsing/aggregate/short_no_assoc_no_ancestor_expr/input.ada @@ -0,0 +1 @@ +Foo:=(Bar, Baz); diff --git a/testsuite/tests/unparsing/aggregate/short_no_assoc_no_ancestor_expr/test.out b/testsuite/tests/unparsing/aggregate/short_no_assoc_no_ancestor_expr/test.out new file mode 100644 index 000000000..fc75bfd12 --- /dev/null +++ b/testsuite/tests/unparsing/aggregate/short_no_assoc_no_ancestor_expr/test.out @@ -0,0 +1 @@ +Foo := (Bar, Baz); diff --git a/testsuite/tests/unparsing/aggregate/short_no_assoc_no_ancestor_expr/test.yaml b/testsuite/tests/unparsing/aggregate/short_no_assoc_no_ancestor_expr/test.yaml new file mode 100644 index 000000000..b85264fde --- /dev/null +++ b/testsuite/tests/unparsing/aggregate/short_no_assoc_no_ancestor_expr/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: stmt +description: | + Test that no line breaks are added.