From 45c7f6e9e0fad7c6203d0f25f390f1319b10776c Mon Sep 17 00:00:00 2001 From: Monika Kurovszky Date: Fri, 16 Feb 2024 12:22:24 +0100 Subject: [PATCH] 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