diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index 0e8d99b37..51ba10ef2 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -1583,6 +1583,49 @@ "line" ] }, + "EnumRepClause": { + "node": { + "kind": "group", + "document": [ + { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "for" + }, + { + "kind": "recurse_field", + "field": "f_type_name" + }, + "whitespace", + { + "kind": "text", + "text": "use" + } + ] + }, + { + "kind": "group", + "document": { + "kind": "align", + "width": 2, + "contents": [ + "line", + { + "kind": "recurse_field", + "field": "f_aggregate" + }, + { + "kind": "text", + "text": ";" + } + ] + } + } + ] + } + }, "EnumTypeDef": { "node": { "kind": "group", diff --git a/testsuite/tests/unparsing/enum_rep_clause/everything_long/doc-baseline.json b/testsuite/tests/unparsing/enum_rep_clause/everything_long/doc-baseline.json new file mode 100644 index 000000000..9c68c2e70 --- /dev/null +++ b/testsuite/tests/unparsing/enum_rep_clause/everything_long/doc-baseline.json @@ -0,0 +1,591 @@ +{ + "id": 75, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 74, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 1, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "for VeeeeeeeeeeeeryLoooooooooooongTyyyyyyyyyyyyyyyyypeNaaaaaaaaaaaame use" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 73, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 72, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 71, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 69, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 68, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "text", + "text": "(" + }, + { + "id": 66, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 65, + "kind": "list", + "list": [ + { + "id": 64, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 63, + "kind": "list", + "list": [ + { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "text", + "text": "Aaaaaaaaaaaa =>" + }, + { + "id": 6, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 10, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 9, + "kind": "text", + "text": "1" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 13, + "kind": "text", + "text": "," + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 22, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 21, + "kind": "list", + "list": [ + { + "id": 18, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 17, + "kind": "list", + "list": [ + { + "id": 15, + "kind": "text", + "text": "Bbbbbbbbbbb =>" + }, + { + "id": 16, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 20, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 19, + "kind": "text", + "text": "5" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 23, + "kind": "text", + "text": "," + }, + { + "id": 24, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 32, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 31, + "kind": "list", + "list": [ + { + "id": 28, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 27, + "kind": "list", + "list": [ + { + "id": 25, + "kind": "text", + "text": "Ccccccccc =>" + }, + { + "id": 26, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 29, + "kind": "text", + "text": "10" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 33, + "kind": "text", + "text": "," + }, + { + "id": 34, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 42, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 41, + "kind": "list", + "list": [ + { + "id": 38, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 37, + "kind": "list", + "list": [ + { + "id": 35, + "kind": "text", + "text": "Dddd =>" + }, + { + "id": 36, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 40, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 39, + "kind": "text", + "text": "1" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 43, + "kind": "text", + "text": "," + }, + { + "id": 44, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 52, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 51, + "kind": "list", + "list": [ + { + "id": 48, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 47, + "kind": "list", + "list": [ + { + "id": 45, + "kind": "text", + "text": "E =>" + }, + { + "id": 46, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 50, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 49, + "kind": "text", + "text": "5" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 53, + "kind": "text", + "text": "," + }, + { + "id": 54, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 62, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 61, + "kind": "list", + "list": [ + { + "id": 58, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 57, + "kind": "list", + "list": [ + { + "id": 55, + "kind": "text", + "text": "F =>" + }, + { + "id": 56, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 60, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 59, + "kind": "text", + "text": "10" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + } + } + }, + { + "id": 67, + "kind": "text", + "text": ")" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 70, + "kind": "text", + "text": ";" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/enum_rep_clause/everything_long/input.ada b/testsuite/tests/unparsing/enum_rep_clause/everything_long/input.ada new file mode 100644 index 000000000..ab9f384d0 --- /dev/null +++ b/testsuite/tests/unparsing/enum_rep_clause/everything_long/input.ada @@ -0,0 +1 @@ +for VeeeeeeeeeeeeryLoooooooooooongTyyyyyyyyyyyyyyyyypeNaaaaaaaaaaaame use (Aaaaaaaaaaaa => 1, Bbbbbbbbbbb => 5, Ccccccccc => 10, Dddd => 1, E => 5, F => 10); diff --git a/testsuite/tests/unparsing/enum_rep_clause/everything_long/test.out b/testsuite/tests/unparsing/enum_rep_clause/everything_long/test.out new file mode 100644 index 000000000..4895fe70c --- /dev/null +++ b/testsuite/tests/unparsing/enum_rep_clause/everything_long/test.out @@ -0,0 +1,7 @@ +for VeeeeeeeeeeeeryLoooooooooooongTyyyyyyyyyyyyyyyyypeNaaaaaaaaaaaame use + (Aaaaaaaaaaaa => 1, + Bbbbbbbbbbb => 5, + Ccccccccc => 10, + Dddd => 1, + E => 5, + F => 10); diff --git a/testsuite/tests/unparsing/enum_rep_clause/everything_long/test.yaml b/testsuite/tests/unparsing/enum_rep_clause/everything_long/test.yaml new file mode 100644 index 000000000..06b6be3eb --- /dev/null +++ b/testsuite/tests/unparsing/enum_rep_clause/everything_long/test.yaml @@ -0,0 +1,9 @@ +description: | + This test checks the formatting of an enum representation + clause with long type name and long aggregate. + It is expected the declaration breaks after `use` keyword + and the aggregagte be broken, one element per new line, + and all these new lines be indented. + +driver: unparser +rule: aspect_clause diff --git a/testsuite/tests/unparsing/enum_rep_clause/long_aggregate/doc-baseline.json b/testsuite/tests/unparsing/enum_rep_clause/long_aggregate/doc-baseline.json new file mode 100644 index 000000000..f77cfc9da --- /dev/null +++ b/testsuite/tests/unparsing/enum_rep_clause/long_aggregate/doc-baseline.json @@ -0,0 +1,591 @@ +{ + "id": 75, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 74, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 1, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "for T use" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 73, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 72, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 71, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 69, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 68, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "text", + "text": "(" + }, + { + "id": 66, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 65, + "kind": "list", + "list": [ + { + "id": 64, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 63, + "kind": "list", + "list": [ + { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "text", + "text": "Aaaaaaaaaaaa =>" + }, + { + "id": 6, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 10, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 9, + "kind": "text", + "text": "1" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 13, + "kind": "text", + "text": "," + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 22, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 21, + "kind": "list", + "list": [ + { + "id": 18, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 17, + "kind": "list", + "list": [ + { + "id": 15, + "kind": "text", + "text": "Bbbbbbbbbbb =>" + }, + { + "id": 16, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 20, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 19, + "kind": "text", + "text": "5" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 23, + "kind": "text", + "text": "," + }, + { + "id": 24, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 32, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 31, + "kind": "list", + "list": [ + { + "id": 28, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 27, + "kind": "list", + "list": [ + { + "id": 25, + "kind": "text", + "text": "Ccccccccc =>" + }, + { + "id": 26, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 29, + "kind": "text", + "text": "10" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 33, + "kind": "text", + "text": "," + }, + { + "id": 34, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 42, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 41, + "kind": "list", + "list": [ + { + "id": 38, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 37, + "kind": "list", + "list": [ + { + "id": 35, + "kind": "text", + "text": "Dddd =>" + }, + { + "id": 36, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 40, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 39, + "kind": "text", + "text": "1" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 43, + "kind": "text", + "text": "," + }, + { + "id": 44, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 52, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 51, + "kind": "list", + "list": [ + { + "id": 48, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 47, + "kind": "list", + "list": [ + { + "id": 45, + "kind": "text", + "text": "E =>" + }, + { + "id": 46, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 50, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 49, + "kind": "text", + "text": "5" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 53, + "kind": "text", + "text": "," + }, + { + "id": 54, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 62, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 61, + "kind": "list", + "list": [ + { + "id": 58, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 57, + "kind": "list", + "list": [ + { + "id": 55, + "kind": "text", + "text": "F =>" + }, + { + "id": 56, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 60, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 59, + "kind": "text", + "text": "10" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + } + } + }, + { + "id": 67, + "kind": "text", + "text": ")" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 70, + "kind": "text", + "text": ";" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/enum_rep_clause/long_aggregate/input.ada b/testsuite/tests/unparsing/enum_rep_clause/long_aggregate/input.ada new file mode 100644 index 000000000..e14db5739 --- /dev/null +++ b/testsuite/tests/unparsing/enum_rep_clause/long_aggregate/input.ada @@ -0,0 +1 @@ +for T use (Aaaaaaaaaaaa => 1, Bbbbbbbbbbb => 5, Ccccccccc => 10, Dddd => 1, E => 5, F => 10); diff --git a/testsuite/tests/unparsing/enum_rep_clause/long_aggregate/test.out b/testsuite/tests/unparsing/enum_rep_clause/long_aggregate/test.out new file mode 100644 index 000000000..e971921f8 --- /dev/null +++ b/testsuite/tests/unparsing/enum_rep_clause/long_aggregate/test.out @@ -0,0 +1,7 @@ +for T use + (Aaaaaaaaaaaa => 1, + Bbbbbbbbbbb => 5, + Ccccccccc => 10, + Dddd => 1, + E => 5, + F => 10); diff --git a/testsuite/tests/unparsing/enum_rep_clause/long_aggregate/test.yaml b/testsuite/tests/unparsing/enum_rep_clause/long_aggregate/test.yaml new file mode 100644 index 000000000..55de7fad1 --- /dev/null +++ b/testsuite/tests/unparsing/enum_rep_clause/long_aggregate/test.yaml @@ -0,0 +1,9 @@ +description: | + This test checks the formatting of an enum representation + clause with long aggregate. + It is expected the declaration breaks after `use` keyword + the aggregate is broken, each line contains one element, + and all these new lines are indented. + +driver: unparser +rule: aspect_clause diff --git a/testsuite/tests/unparsing/enum_rep_clause/long_type/doc-baseline.json b/testsuite/tests/unparsing/enum_rep_clause/long_type/doc-baseline.json new file mode 100644 index 000000000..94e33deaa --- /dev/null +++ b/testsuite/tests/unparsing/enum_rep_clause/long_type/doc-baseline.json @@ -0,0 +1,357 @@ +{ + "id": 45, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 44, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 1, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "for VeeeeeeeeeeeeeeeeeeryLoooooooooooongTyyyyyyyyyyyyyyyyyypeNaaaaaaaaaaaame use" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 43, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 42, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 41, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 39, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 38, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "text", + "text": "(" + }, + { + "id": 36, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 35, + "kind": "list", + "list": [ + { + "id": 34, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 33, + "kind": "list", + "list": [ + { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "text", + "text": "A =>" + }, + { + "id": 6, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 10, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 9, + "kind": "text", + "text": "1" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 13, + "kind": "text", + "text": "," + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 22, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 21, + "kind": "list", + "list": [ + { + "id": 18, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 17, + "kind": "list", + "list": [ + { + "id": 15, + "kind": "text", + "text": "B =>" + }, + { + "id": 16, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 20, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 19, + "kind": "text", + "text": "5" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 23, + "kind": "text", + "text": "," + }, + { + "id": 24, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 32, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 31, + "kind": "list", + "list": [ + { + "id": 28, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 27, + "kind": "list", + "list": [ + { + "id": 25, + "kind": "text", + "text": "C =>" + }, + { + "id": 26, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 29, + "kind": "text", + "text": "10" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + } + } + }, + { + "id": 37, + "kind": "text", + "text": ")" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 40, + "kind": "text", + "text": ";" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/enum_rep_clause/long_type/input.ada b/testsuite/tests/unparsing/enum_rep_clause/long_type/input.ada new file mode 100644 index 000000000..cf0064e2b --- /dev/null +++ b/testsuite/tests/unparsing/enum_rep_clause/long_type/input.ada @@ -0,0 +1 @@ +for VeeeeeeeeeeeeeeeeeeryLoooooooooooongTyyyyyyyyyyyyyyyyyypeNaaaaaaaaaaaame use (A => 1, B => 5, C => 10); diff --git a/testsuite/tests/unparsing/enum_rep_clause/long_type/test.out b/testsuite/tests/unparsing/enum_rep_clause/long_type/test.out new file mode 100644 index 000000000..ed6cbf213 --- /dev/null +++ b/testsuite/tests/unparsing/enum_rep_clause/long_type/test.out @@ -0,0 +1,2 @@ +for VeeeeeeeeeeeeeeeeeeryLoooooooooooongTyyyyyyyyyyyyyyyyyypeNaaaaaaaaaaaame use + (A => 1, B => 5, C => 10); diff --git a/testsuite/tests/unparsing/enum_rep_clause/long_type/test.yaml b/testsuite/tests/unparsing/enum_rep_clause/long_type/test.yaml new file mode 100644 index 000000000..2b896eb97 --- /dev/null +++ b/testsuite/tests/unparsing/enum_rep_clause/long_type/test.yaml @@ -0,0 +1,8 @@ +description: | + This test checks the formatting of an enum representation + clause with a long type name. + It is expected the declaration breaks after the `use` keyword + and the new line be indented. + +driver: unparser +rule: aspect_clause diff --git a/testsuite/tests/unparsing/enum_rep_clause/short/doc-baseline.json b/testsuite/tests/unparsing/enum_rep_clause/short/doc-baseline.json new file mode 100644 index 000000000..a871bae33 --- /dev/null +++ b/testsuite/tests/unparsing/enum_rep_clause/short/doc-baseline.json @@ -0,0 +1,357 @@ +{ + "id": 45, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 44, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 1, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "for r use" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 43, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 42, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 41, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 39, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 38, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "text", + "text": "(" + }, + { + "id": 36, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 35, + "kind": "list", + "list": [ + { + "id": 34, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 33, + "kind": "list", + "list": [ + { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "text", + "text": "A =>" + }, + { + "id": 6, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 10, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 9, + "kind": "text", + "text": "1" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 13, + "kind": "text", + "text": "," + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 22, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 21, + "kind": "list", + "list": [ + { + "id": 18, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 17, + "kind": "list", + "list": [ + { + "id": 15, + "kind": "text", + "text": "B =>" + }, + { + "id": 16, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 20, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 19, + "kind": "text", + "text": "5" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 23, + "kind": "text", + "text": "," + }, + { + "id": 24, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 32, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 31, + "kind": "list", + "list": [ + { + "id": 28, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 27, + "kind": "list", + "list": [ + { + "id": 25, + "kind": "text", + "text": "C =>" + }, + { + "id": 26, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 30, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 29, + "kind": "text", + "text": "10" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + } + } + }, + { + "id": 37, + "kind": "text", + "text": ")" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 40, + "kind": "text", + "text": ";" + } + ] + } + } + }, + "break": false, + "expandedStates": null + } + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/enum_rep_clause/short/input.ada b/testsuite/tests/unparsing/enum_rep_clause/short/input.ada new file mode 100644 index 000000000..08184dc01 --- /dev/null +++ b/testsuite/tests/unparsing/enum_rep_clause/short/input.ada @@ -0,0 +1 @@ +for r use (A => 1, B => 5, C => 10); diff --git a/testsuite/tests/unparsing/enum_rep_clause/short/test.out b/testsuite/tests/unparsing/enum_rep_clause/short/test.out new file mode 100644 index 000000000..08184dc01 --- /dev/null +++ b/testsuite/tests/unparsing/enum_rep_clause/short/test.out @@ -0,0 +1 @@ +for r use (A => 1, B => 5, C => 10); diff --git a/testsuite/tests/unparsing/enum_rep_clause/short/test.yaml b/testsuite/tests/unparsing/enum_rep_clause/short/test.yaml new file mode 100644 index 000000000..e31678d76 --- /dev/null +++ b/testsuite/tests/unparsing/enum_rep_clause/short/test.yaml @@ -0,0 +1,7 @@ +description: | + This test checks the formatting of an enum representation + clause. + It is expected the declaration stays on a single line. + +driver: unparser +rule: aspect_clause