From 062a32fad78eefc54820b9810a4b8f2a30b703b2 Mon Sep 17 00:00:00 2001 From: Monika Kurovszky Date: Fri, 16 Feb 2024 11:15:52 +0100 Subject: [PATCH 1/2] Add UsePackageClause config --- extensions/default_unparsing_config.json | 55 +++++ .../doc-baseline.json | 216 ++++++++++++++++++ .../input.ada | 1 + .../test.out | 6 + .../test.yaml | 14 ++ .../simple_packs_list/doc-baseline.json | 152 ++++++++++++ .../simple_packs_list/input.ada | 1 + .../simple_packs_list/test.out | 8 + .../simple_packs_list/test.yaml | 9 + .../simple_use/doc-baseline.json | 108 +++++++++ .../use_package_clause/simple_use/input.ada | 1 + .../use_package_clause/simple_use/test.out | 1 + .../use_package_clause/simple_use/test.yaml | 6 + .../doc-baseline.json | 123 ++++++++++ .../simple_use_long_dotted_name/input.ada | 1 + .../simple_use_long_dotted_name/test.out | 4 + .../simple_use_long_dotted_name/test.yaml | 12 + .../simple_use_pack_list/doc-baseline.json | 179 +++++++++++++++ .../simple_use_pack_list/input.ada | 1 + .../simple_use_pack_list/test.out | 1 + .../simple_use_pack_list/test.yaml | 9 + 21 files changed, 908 insertions(+) create mode 100644 testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/mixed_dotted_and_simple_packs_list/doc-baseline.json create mode 100644 testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/mixed_dotted_and_simple_packs_list/input.ada create mode 100644 testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/mixed_dotted_and_simple_packs_list/test.out create mode 100644 testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/mixed_dotted_and_simple_packs_list/test.yaml create mode 100644 testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/simple_packs_list/doc-baseline.json create mode 100644 testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/simple_packs_list/input.ada create mode 100644 testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/simple_packs_list/test.out create mode 100644 testsuite/tests/unparsing/use_package_clause/max_line_length_exceeded/simple_packs_list/test.yaml create mode 100644 testsuite/tests/unparsing/use_package_clause/simple_use/doc-baseline.json create mode 100644 testsuite/tests/unparsing/use_package_clause/simple_use/input.ada create mode 100644 testsuite/tests/unparsing/use_package_clause/simple_use/test.out create mode 100644 testsuite/tests/unparsing/use_package_clause/simple_use/test.yaml create mode 100644 testsuite/tests/unparsing/use_package_clause/simple_use_long_dotted_name/doc-baseline.json create mode 100644 testsuite/tests/unparsing/use_package_clause/simple_use_long_dotted_name/input.ada create mode 100644 testsuite/tests/unparsing/use_package_clause/simple_use_long_dotted_name/test.out create mode 100644 testsuite/tests/unparsing/use_package_clause/simple_use_long_dotted_name/test.yaml create mode 100644 testsuite/tests/unparsing/use_package_clause/simple_use_pack_list/doc-baseline.json create mode 100644 testsuite/tests/unparsing/use_package_clause/simple_use_pack_list/input.ada create mode 100644 testsuite/tests/unparsing/use_package_clause/simple_use_pack_list/test.out create mode 100644 testsuite/tests/unparsing/use_package_clause/simple_use_pack_list/test.yaml 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 From 45c7f6e9e0fad7c6203d0f25f390f1319b10776c Mon Sep 17 00:00:00 2001 From: Monika Kurovszky Date: Fri, 16 Feb 2024 12:22:24 +0100 Subject: [PATCH 2/2] Add UseTypeClause config --- .../long_use_types_list/doc-baseline.json | 179 +++++++++++++++ .../long_use_types_list/input.ada | 1 + .../long_use_types_list/test.out | 5 + .../long_use_types_list/test.yaml | 10 + .../simple_types_list/doc-baseline.json | 179 +++++++++++++++ .../simple_types_list/input.ada | 1 + .../simple_types_list/test.out | 1 + .../simple_types_list/test.yaml | 8 + .../simple_use_type/doc-baseline.json | 108 +++++++++ .../use_type_clause/simple_use_type/input.ada | 1 + .../use_type_clause/simple_use_type/test.out | 1 + .../use_type_clause/simple_use_type/test.yaml | 6 + .../use_all_type_clause/doc-baseline.json | 216 ++++++++++++++++++ .../use_all_type_clause/input.ada | 1 + .../use_all_type_clause/test.out | 1 + .../use_all_type_clause/test.yaml | 6 + 16 files changed, 724 insertions(+) create mode 100644 testsuite/tests/unparsing/use_type_clause/long_use_types_list/doc-baseline.json create mode 100644 testsuite/tests/unparsing/use_type_clause/long_use_types_list/input.ada create mode 100644 testsuite/tests/unparsing/use_type_clause/long_use_types_list/test.out create mode 100644 testsuite/tests/unparsing/use_type_clause/long_use_types_list/test.yaml create mode 100644 testsuite/tests/unparsing/use_type_clause/simple_types_list/doc-baseline.json create mode 100644 testsuite/tests/unparsing/use_type_clause/simple_types_list/input.ada create mode 100644 testsuite/tests/unparsing/use_type_clause/simple_types_list/test.out create mode 100644 testsuite/tests/unparsing/use_type_clause/simple_types_list/test.yaml create mode 100644 testsuite/tests/unparsing/use_type_clause/simple_use_type/doc-baseline.json create mode 100644 testsuite/tests/unparsing/use_type_clause/simple_use_type/input.ada create mode 100644 testsuite/tests/unparsing/use_type_clause/simple_use_type/test.out create mode 100644 testsuite/tests/unparsing/use_type_clause/simple_use_type/test.yaml create mode 100644 testsuite/tests/unparsing/use_type_clause/use_all_type_clause/doc-baseline.json create mode 100644 testsuite/tests/unparsing/use_type_clause/use_all_type_clause/input.ada create mode 100644 testsuite/tests/unparsing/use_type_clause/use_all_type_clause/test.out create mode 100644 testsuite/tests/unparsing/use_type_clause/use_all_type_clause/test.yaml diff --git a/testsuite/tests/unparsing/use_type_clause/long_use_types_list/doc-baseline.json b/testsuite/tests/unparsing/use_type_clause/long_use_types_list/doc-baseline.json new file mode 100644 index 000000000..885fe2cad --- /dev/null +++ b/testsuite/tests/unparsing/use_type_clause/long_use_types_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 type " + }, + { + "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": "Aaaaaaaaa" + }, + { + "id": 2, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 3, + "kind": "text", + "text": ".Bbbbbbb" + }, + { + "id": 4, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 5, + "kind": "text", + "text": ".Cccccc" + } + ] + }, + "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": "Dddddddddddddddddddd," + }, + { + "id": 13, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 14, + "kind": "text", + "text": "eeeeeeeeeeeeeeeeeeeeeeeeee," + }, + { + "id": 15, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 16, + "kind": "text", + "text": "Fff," + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 18, + "kind": "text", + "text": "Ggg" + } + ] + } + } + }, + { + "id": 21, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/use_type_clause/long_use_types_list/input.ada b/testsuite/tests/unparsing/use_type_clause/long_use_types_list/input.ada new file mode 100644 index 000000000..e1e608080 --- /dev/null +++ b/testsuite/tests/unparsing/use_type_clause/long_use_types_list/input.ada @@ -0,0 +1 @@ +use type Aaaaaaaaa .Bbbbbbb. Cccccc, Dddddddddddddddddddd, eeeeeeeeeeeeeeeeeeeeeeeeee, Fff, Ggg; \ No newline at end of file diff --git a/testsuite/tests/unparsing/use_type_clause/long_use_types_list/test.out b/testsuite/tests/unparsing/use_type_clause/long_use_types_list/test.out new file mode 100644 index 000000000..ffc1c05e8 --- /dev/null +++ b/testsuite/tests/unparsing/use_type_clause/long_use_types_list/test.out @@ -0,0 +1,5 @@ +use type Aaaaaaaaa.Bbbbbbb.Cccccc, + Dddddddddddddddddddd, + eeeeeeeeeeeeeeeeeeeeeeeeee, + Fff, + Ggg; diff --git a/testsuite/tests/unparsing/use_type_clause/long_use_types_list/test.yaml b/testsuite/tests/unparsing/use_type_clause/long_use_types_list/test.yaml new file mode 100644 index 000000000..eac6112fb --- /dev/null +++ b/testsuite/tests/unparsing/use_type_clause/long_use_types_list/test.yaml @@ -0,0 +1,10 @@ +description: | + This test checks the formatting of a use type clause line + with an exceeding length. Dotted names and simple names are + used to designate the types. + It is expected to break after the first used type and get + all the types aligned afterbased on this element initial + position. + +driver: unparser +rule: use_clause diff --git a/testsuite/tests/unparsing/use_type_clause/simple_types_list/doc-baseline.json b/testsuite/tests/unparsing/use_type_clause/simple_types_list/doc-baseline.json new file mode 100644 index 000000000..84a072cff --- /dev/null +++ b/testsuite/tests/unparsing/use_type_clause/simple_types_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 type " + }, + { + "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": "Aaa" + }, + { + "id": 2, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 3, + "kind": "text", + "text": ".Bbb" + }, + { + "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": "Ddd," + }, + { + "id": 13, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 14, + "kind": "text", + "text": "eeeee," + }, + { + "id": 15, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 16, + "kind": "text", + "text": "Fff," + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 18, + "kind": "text", + "text": "Ggg" + } + ] + } + } + }, + { + "id": 21, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/use_type_clause/simple_types_list/input.ada b/testsuite/tests/unparsing/use_type_clause/simple_types_list/input.ada new file mode 100644 index 000000000..f3ed99d5d --- /dev/null +++ b/testsuite/tests/unparsing/use_type_clause/simple_types_list/input.ada @@ -0,0 +1 @@ +use type Aaa .Bbb. C, Ddd, eeeee, Fff, Ggg; \ No newline at end of file diff --git a/testsuite/tests/unparsing/use_type_clause/simple_types_list/test.out b/testsuite/tests/unparsing/use_type_clause/simple_types_list/test.out new file mode 100644 index 000000000..9a7ae2e76 --- /dev/null +++ b/testsuite/tests/unparsing/use_type_clause/simple_types_list/test.out @@ -0,0 +1 @@ +use type Aaa.Bbb.C, Ddd, eeeee, Fff, Ggg; diff --git a/testsuite/tests/unparsing/use_type_clause/simple_types_list/test.yaml b/testsuite/tests/unparsing/use_type_clause/simple_types_list/test.yaml new file mode 100644 index 000000000..4a414a6c0 --- /dev/null +++ b/testsuite/tests/unparsing/use_type_clause/simple_types_list/test.yaml @@ -0,0 +1,8 @@ +description: | + This test checks the formatting of a single line use type clause + with a dotted name ada kind used to designate the package. + It is expected to kee everything on the same line and keep the + initial casing as well. + +driver: unparser +rule: use_clause diff --git a/testsuite/tests/unparsing/use_type_clause/simple_use_type/doc-baseline.json b/testsuite/tests/unparsing/use_type_clause/simple_use_type/doc-baseline.json new file mode 100644 index 000000000..b2cb86e2c --- /dev/null +++ b/testsuite/tests/unparsing/use_type_clause/simple_use_type/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 type " + }, + { + "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_type_clause/simple_use_type/input.ada b/testsuite/tests/unparsing/use_type_clause/simple_use_type/input.ada new file mode 100644 index 000000000..f2a2dc187 --- /dev/null +++ b/testsuite/tests/unparsing/use_type_clause/simple_use_type/input.ada @@ -0,0 +1 @@ +use type A .B. C ; \ No newline at end of file diff --git a/testsuite/tests/unparsing/use_type_clause/simple_use_type/test.out b/testsuite/tests/unparsing/use_type_clause/simple_use_type/test.out new file mode 100644 index 000000000..ae5508341 --- /dev/null +++ b/testsuite/tests/unparsing/use_type_clause/simple_use_type/test.out @@ -0,0 +1 @@ +use type A.B.C; diff --git a/testsuite/tests/unparsing/use_type_clause/simple_use_type/test.yaml b/testsuite/tests/unparsing/use_type_clause/simple_use_type/test.yaml new file mode 100644 index 000000000..78ef6207d --- /dev/null +++ b/testsuite/tests/unparsing/use_type_clause/simple_use_type/test.yaml @@ -0,0 +1,6 @@ +description: | + This test checks the formatting of a simple use type clause + with a dotted name kind used to designate the package. + +driver: unparser +rule: use_clause diff --git a/testsuite/tests/unparsing/use_type_clause/use_all_type_clause/doc-baseline.json b/testsuite/tests/unparsing/use_type_clause/use_all_type_clause/doc-baseline.json new file mode 100644 index 000000000..7720219fb --- /dev/null +++ b/testsuite/tests/unparsing/use_type_clause/use_all_type_clause/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 all type " + }, + { + "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": "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": "Ffff," + }, + { + "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": "Gg" + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 18, + "kind": "text", + "text": ".Hhhhhhh" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + } + } + ] + } + } + }, + { + "id": 25, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/use_type_clause/use_all_type_clause/input.ada b/testsuite/tests/unparsing/use_type_clause/use_all_type_clause/input.ada new file mode 100644 index 000000000..7c3f0ef5f --- /dev/null +++ b/testsuite/tests/unparsing/use_type_clause/use_all_type_clause/input.ada @@ -0,0 +1 @@ +use all type A .B. C, D, Ffff, Gg.Hhhhhhh ; \ No newline at end of file diff --git a/testsuite/tests/unparsing/use_type_clause/use_all_type_clause/test.out b/testsuite/tests/unparsing/use_type_clause/use_all_type_clause/test.out new file mode 100644 index 000000000..371de6baf --- /dev/null +++ b/testsuite/tests/unparsing/use_type_clause/use_all_type_clause/test.out @@ -0,0 +1 @@ +use all type A.B.C, D, Ffff, Gg.Hhhhhhh; diff --git a/testsuite/tests/unparsing/use_type_clause/use_all_type_clause/test.yaml b/testsuite/tests/unparsing/use_type_clause/use_all_type_clause/test.yaml new file mode 100644 index 000000000..476927ad5 --- /dev/null +++ b/testsuite/tests/unparsing/use_type_clause/use_all_type_clause/test.yaml @@ -0,0 +1,6 @@ +description: | + This test checks the formatting of a use all type clause. + It is expected to have this formatted on the same line. + +driver: unparser +rule: use_clause