diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index f616a40c6..9bf447188 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -31,6 +31,61 @@ ] } }, + "UsePackageClause": { + "node": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "use" + }, + "whitespace", + { + "kind": "innerRoot", + "contents": { + "kind": "recurse_field", + "field": "f_packages" + } + }, + { + "kind": "text", + "text": ";" + } + ] + } + }, + "UseTypeClause": { + "node": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "use" + }, + "whitespace", + { + "kind": "recurse_field", + "field": "f_has_all" + }, + { + "kind": "text", + "text": "type" + }, + "whitespace", + { + "kind": "innerRoot", + "contents": { + "kind": "recurse_field", + "field": "f_types" + } + }, + { + "kind": "text", + "text": ";" + } + ] + } + }, "NameList":{ "sep":["recurse", "line"] }, diff --git a/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/mixed_dotted_and_simple_packs_list/doc-baseline.json b/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/mixed_dotted_and_simple_packs_list/doc-baseline.json new file mode 100644 index 000000000..44754d62f --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/mixed_dotted_and_simple_packs_list/doc-baseline.json @@ -0,0 +1,216 @@ +{ + "id": 27, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 26, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "use " + }, + { + "id": 24, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 23, + "kind": "list", + "list": [ + { + "id": 9, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 6, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "text", + "text": "Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + }, + { + "id": 2, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 3, + "kind": "text", + "text": ".Bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + }, + { + "id": 4, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 5, + "kind": "text", + "text": ".Ccccccccccccccccccccccccccccccccccccc" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + } + }, + { + "id": 10, + "kind": "text", + "text": "," + }, + { + "id": 11, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 12, + "kind": "text", + "text": "Dddddddddddddd," + }, + { + "id": 13, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 14, + "kind": "text", + "text": "Eeeeeeeeeeeeeee," + }, + { + "id": 15, + "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": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "list", + "list": [ + { + "id": 16, + "kind": "text", + "text": "FFFFFFFF" + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 18, + "kind": "text", + "text": ".Gggggggggggggg" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + } + } + ] + } + } + }, + { + "id": 25, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/mixed_dotted_and_simple_packs_list/input.ada b/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/mixed_dotted_and_simple_packs_list/input.ada new file mode 100644 index 000000000..cafa6fb7f --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/mixed_dotted_and_simple_packs_list/input.ada @@ -0,0 +1 @@ +use Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa .Bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb. Ccccccccccccccccccccccccccccccccccccc , Dddddddddddddd, Eeeeeeeeeeeeeee, FFFFFFFF.Gggggggggggggg; \ No newline at end of file diff --git a/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/mixed_dotted_and_simple_packs_list/test.out b/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/mixed_dotted_and_simple_packs_list/test.out new file mode 100644 index 000000000..dcbd06730 --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/mixed_dotted_and_simple_packs_list/test.out @@ -0,0 +1,6 @@ +use Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + .Bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + .Ccccccccccccccccccccccccccccccccccccc, + Dddddddddddddd, + Eeeeeeeeeeeeeee, + FFFFFFFF.Gggggggggggggg; diff --git a/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/mixed_dotted_and_simple_packs_list/test.yaml b/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/mixed_dotted_and_simple_packs_list/test.yaml new file mode 100644 index 000000000..2f3d95264 --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/mixed_dotted_and_simple_packs_list/test.yaml @@ -0,0 +1,14 @@ +description: | + This test checks the formatting of a use package clause having + a list of package names exceeding the maximal line length. + The packages are designated by dotted and simple names with + different casing. + It is expected to break after the comma, align on the first + element of the package list and keep the casing unchanged. + The long dotted name will be formatted as expected (namely, a + line break is inserted before . and the alignment is based on + the initial position of the first field and a line continuation + indentation (i.e., 2 spaces) is added before . on each new line. + +driver: unparser +rule: use_clause diff --git a/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/simple_packs_list/doc-baseline.json b/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/simple_packs_list/doc-baseline.json new file mode 100644 index 000000000..409fb1912 --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/simple_packs_list/doc-baseline.json @@ -0,0 +1,152 @@ +{ + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "use " + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 16, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "text", + "text": "Aaaaaaa," + }, + { + "id": 2, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 3, + "kind": "text", + "text": "Bbbbbb," + }, + { + "id": 4, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 5, + "kind": "text", + "text": "Ccccccc," + }, + { + "id": 6, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 7, + "kind": "text", + "text": "Dddddddddddd," + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 9, + "kind": "text", + "text": "Eeeeeeeeeeeeeeeee," + }, + { + "id": 10, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 11, + "kind": "text", + "text": "Fffffffffffffffffff," + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 13, + "kind": "text", + "text": "Ggggggggggggggggggg," + }, + { + "id": 14, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 15, + "kind": "text", + "text": "Hhhhhhhhhhhhhhhh" + } + ] + } + } + }, + { + "id": 18, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/simple_packs_list/input.ada b/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/simple_packs_list/input.ada new file mode 100644 index 000000000..577ebfddb --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/simple_packs_list/input.ada @@ -0,0 +1 @@ +use Aaaaaaa, Bbbbbb, Ccccccc, Dddddddddddd, Eeeeeeeeeeeeeeeee, Fffffffffffffffffff, Ggggggggggggggggggg, Hhhhhhhhhhhhhhhh ; \ No newline at end of file diff --git a/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/simple_packs_list/test.out b/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/simple_packs_list/test.out new file mode 100644 index 000000000..9b8f3e101 --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/simple_packs_list/test.out @@ -0,0 +1,8 @@ +use Aaaaaaa, + Bbbbbb, + Ccccccc, + Dddddddddddd, + Eeeeeeeeeeeeeeeee, + Fffffffffffffffffff, + Ggggggggggggggggggg, + Hhhhhhhhhhhhhhhh; diff --git a/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/simple_packs_list/test.yaml b/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/simple_packs_list/test.yaml new file mode 100644 index 000000000..57f79de25 --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/simple_packs_list/test.yaml @@ -0,0 +1,9 @@ +description: | + This test checks the formatting of a use package clause having + a list of package names exceeding the maximal line length. + The packages are designated by simple names with different casing. + It is expected to break after the comma, align on the first element + of the package list and keep the casing unchanged. + +driver: unparser +rule: use_clause diff --git a/testsuite/tests/unparsing/use_package_clause/simple_use/doc-baseline.json b/testsuite/tests/unparsing/use_package_clause/simple_use/doc-baseline.json new file mode 100644 index 000000000..505cb80ba --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/simple_use/doc-baseline.json @@ -0,0 +1,108 @@ +{ + "id": 13, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 12, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "use " + }, + { + "id": 10, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 9, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 6, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "text", + "text": "A" + }, + { + "id": 2, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 3, + "kind": "text", + "text": ".B" + }, + { + "id": 4, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 5, + "kind": "text", + "text": ".C" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + } + } + } + }, + { + "id": 11, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/use_package_clause/simple_use/input.ada b/testsuite/tests/unparsing/use_package_clause/simple_use/input.ada new file mode 100644 index 000000000..a78f5ed51 --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/simple_use/input.ada @@ -0,0 +1 @@ +use A . B.C ; \ No newline at end of file diff --git a/testsuite/tests/unparsing/use_package_clause/simple_use/test.out b/testsuite/tests/unparsing/use_package_clause/simple_use/test.out new file mode 100644 index 000000000..eaf716277 --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/simple_use/test.out @@ -0,0 +1 @@ +use A.B.C; diff --git a/testsuite/tests/unparsing/use_package_clause/simple_use/test.yaml b/testsuite/tests/unparsing/use_package_clause/simple_use/test.yaml new file mode 100644 index 000000000..2800be499 --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/simple_use/test.yaml @@ -0,0 +1,6 @@ +description: | + This test checks the formatting of a simple use package clause + with a dotted name used to designate the package. + +driver: unparser +rule: use_clause diff --git a/testsuite/tests/unparsing/use_package_clause/simple_use_long_dotted_name/doc-baseline.json b/testsuite/tests/unparsing/use_package_clause/simple_use_long_dotted_name/doc-baseline.json new file mode 100644 index 000000000..1ad6dd960 --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/simple_use_long_dotted_name/doc-baseline.json @@ -0,0 +1,123 @@ +{ + "id": 15, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 14, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "use " + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 11, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 10, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 9, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 8, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "text", + "text": "Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + }, + { + "id": 2, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 3, + "kind": "text", + "text": ".Bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + }, + { + "id": 4, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 5, + "kind": "text", + "text": ".Ccccccccccccccccccccccccccccccccccccccc" + }, + { + "id": 6, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 7, + "kind": "text", + "text": ".Dddddddddddd" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + } + } + } + }, + { + "id": 13, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/use_package_clause/simple_use_long_dotted_name/input.ada b/testsuite/tests/unparsing/use_package_clause/simple_use_long_dotted_name/input.ada new file mode 100644 index 000000000..92460359b --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/simple_use_long_dotted_name/input.ada @@ -0,0 +1 @@ +use Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa .Bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb. Ccccccccccccccccccccccccccccccccccccccc.Dddddddddddd ; \ No newline at end of file diff --git a/testsuite/tests/unparsing/use_package_clause/simple_use_long_dotted_name/test.out b/testsuite/tests/unparsing/use_package_clause/simple_use_long_dotted_name/test.out new file mode 100644 index 000000000..66cc569e9 --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/simple_use_long_dotted_name/test.out @@ -0,0 +1,4 @@ +use Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + .Bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + .Ccccccccccccccccccccccccccccccccccccccc + .Dddddddddddd; diff --git a/testsuite/tests/unparsing/use_package_clause/simple_use_long_dotted_name/test.yaml b/testsuite/tests/unparsing/use_package_clause/simple_use_long_dotted_name/test.yaml new file mode 100644 index 000000000..fe8975843 --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/simple_use_long_dotted_name/test.yaml @@ -0,0 +1,12 @@ +description: | + This test checks the formatting of a use package clause using + a dotted name exceeding the maximal line length to designate + the package. + It is expected to keep the use and the dotted name first field + on the same line and break before .; the other fields are aligned + taking as initial indent the first field starting position and + adding a line continuation indentation (i.e., 2 spaces) before each . + for the other fields on the next lines. + +driver: unparser +rule: use_clause diff --git a/testsuite/tests/unparsing/use_package_clause/simple_use_pack_list/doc-baseline.json b/testsuite/tests/unparsing/use_package_clause/simple_use_pack_list/doc-baseline.json new file mode 100644 index 000000000..887a426ab --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/simple_use_pack_list/doc-baseline.json @@ -0,0 +1,179 @@ +{ + "id": 23, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 22, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "use " + }, + { + "id": 20, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 19, + "kind": "list", + "list": [ + { + "id": 9, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 6, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "text", + "text": "A" + }, + { + "id": 2, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 3, + "kind": "text", + "text": ".B" + }, + { + "id": 4, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 5, + "kind": "text", + "text": ".C" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + } + }, + { + "id": 10, + "kind": "text", + "text": "," + }, + { + "id": 11, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 12, + "kind": "text", + "text": "D," + }, + { + "id": 13, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 14, + "kind": "text", + "text": "e," + }, + { + "id": 15, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 16, + "kind": "text", + "text": "F," + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 18, + "kind": "text", + "text": "G" + } + ] + } + } + }, + { + "id": 21, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/use_package_clause/simple_use_pack_list/input.ada b/testsuite/tests/unparsing/use_package_clause/simple_use_pack_list/input.ada new file mode 100644 index 000000000..348f44cc4 --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/simple_use_pack_list/input.ada @@ -0,0 +1 @@ +use A .B. C , D,e, F ,G ; \ No newline at end of file diff --git a/testsuite/tests/unparsing/use_package_clause/simple_use_pack_list/test.out b/testsuite/tests/unparsing/use_package_clause/simple_use_pack_list/test.out new file mode 100644 index 000000000..f9f070ad7 --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/simple_use_pack_list/test.out @@ -0,0 +1 @@ +use A.B.C, D, e, F, G; diff --git a/testsuite/tests/unparsing/use_package_clause/simple_use_pack_list/test.yaml b/testsuite/tests/unparsing/use_package_clause/simple_use_pack_list/test.yaml new file mode 100644 index 000000000..1fe0aa8e9 --- /dev/null +++ b/testsuite/tests/unparsing/use_package_clause/simple_use_pack_list/test.yaml @@ -0,0 +1,9 @@ +description: | + This test checks the formatting of a use package clause + having a list of package names. The packages are designated + by dotted names or by simple names with different casing. + It is expected to keep them on the same line and respect + the initial casing. + +driver: unparser +rule: use_clause