From 90193a634c0e0c15def7b22e25d20af8fbd0c59e Mon Sep 17 00:00:00 2001 From: Monika Kurovszky Date: Fri, 12 Apr 2024 13:23:04 +0200 Subject: [PATCH] Add Allocator and QualExpr config --- extensions/default_unparsing_config.json | 47 +++++ .../unparsing/allocator/doc-baseline.json | 101 ++++++++++ testsuite/tests/unparsing/allocator/input.ada | 1 + testsuite/tests/unparsing/allocator/test.out | 1 + testsuite/tests/unparsing/allocator/test.yaml | 6 + .../qual_expr/expr_1/doc-baseline.json | 80 ++++++++ .../unparsing/qual_expr/expr_1/input.ada | 1 + .../tests/unparsing/qual_expr/expr_1/test.out | 1 + .../unparsing/qual_expr/expr_1/test.yaml | 6 + .../qual_expr/expr_2/doc-baseline.json | 184 ++++++++++++++++++ .../unparsing/qual_expr/expr_2/input.ada | 1 + .../tests/unparsing/qual_expr/expr_2/test.out | 1 + .../unparsing/qual_expr/expr_2/test.yaml | 6 + .../qual_expr/expr_3/doc-baseline.json | 164 ++++++++++++++++ .../unparsing/qual_expr/expr_3/input.ada | 1 + .../tests/unparsing/qual_expr/expr_3/test.out | 1 + .../unparsing/qual_expr/expr_3/test.yaml | 6 + .../qual_expr/long/doc-baseline.json | 184 ++++++++++++++++++ .../tests/unparsing/qual_expr/long/input.ada | 1 + .../tests/unparsing/qual_expr/long/test.out | 2 + .../tests/unparsing/qual_expr/long/test.yaml | 7 + 21 files changed, 802 insertions(+) create mode 100644 testsuite/tests/unparsing/allocator/doc-baseline.json create mode 100644 testsuite/tests/unparsing/allocator/input.ada create mode 100644 testsuite/tests/unparsing/allocator/test.out create mode 100644 testsuite/tests/unparsing/allocator/test.yaml create mode 100644 testsuite/tests/unparsing/qual_expr/expr_1/doc-baseline.json create mode 100644 testsuite/tests/unparsing/qual_expr/expr_1/input.ada create mode 100644 testsuite/tests/unparsing/qual_expr/expr_1/test.out create mode 100644 testsuite/tests/unparsing/qual_expr/expr_1/test.yaml create mode 100644 testsuite/tests/unparsing/qual_expr/expr_2/doc-baseline.json create mode 100644 testsuite/tests/unparsing/qual_expr/expr_2/input.ada create mode 100644 testsuite/tests/unparsing/qual_expr/expr_2/test.out create mode 100644 testsuite/tests/unparsing/qual_expr/expr_2/test.yaml create mode 100644 testsuite/tests/unparsing/qual_expr/expr_3/doc-baseline.json create mode 100644 testsuite/tests/unparsing/qual_expr/expr_3/input.ada create mode 100644 testsuite/tests/unparsing/qual_expr/expr_3/test.out create mode 100644 testsuite/tests/unparsing/qual_expr/expr_3/test.yaml create mode 100644 testsuite/tests/unparsing/qual_expr/long/doc-baseline.json create mode 100644 testsuite/tests/unparsing/qual_expr/long/input.ada create mode 100644 testsuite/tests/unparsing/qual_expr/long/test.out create mode 100644 testsuite/tests/unparsing/qual_expr/long/test.yaml diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index de6dede57..d8bafe245 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -220,6 +220,27 @@ } } }, + "Allocator": { + "node": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "new" + }, + "whitespace", + { + "kind": "recurse_field", + "field": "f_subpool" + }, + "whitespace", + { + "kind": "recurse_field", + "field": "f_type_or_expr" + } + ] + } + }, "AlternativesList": { "sep": [ "line", @@ -4297,6 +4318,32 @@ } } }, + "QualExpr": { + "node": { + "kind": "group", + "document": [ + { + "kind": "recurse_field", + "field": "f_prefix" + }, + { + "kind": "text", + "text": "'" + }, + { + "kind": "align", + "width": 2, + "contents": [ + "softline", + { + "kind": "recurse_field", + "field": "f_suffix" + } + ] + } + ] + } + }, "RangeSpec": { "node": { "kind": "align", diff --git a/testsuite/tests/unparsing/allocator/doc-baseline.json b/testsuite/tests/unparsing/allocator/doc-baseline.json new file mode 100644 index 000000000..047c15355 --- /dev/null +++ b/testsuite/tests/unparsing/allocator/doc-baseline.json @@ -0,0 +1,101 @@ +{ + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "new (Pool) " + }, + { + "id": 10, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 9, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "text", + "text": "Integer'" + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 6, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 5, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 4, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "text", + "text": "(12)" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/allocator/input.ada b/testsuite/tests/unparsing/allocator/input.ada new file mode 100644 index 000000000..fd57a00ac --- /dev/null +++ b/testsuite/tests/unparsing/allocator/input.ada @@ -0,0 +1 @@ +new (Pool) Integer'(12) diff --git a/testsuite/tests/unparsing/allocator/test.out b/testsuite/tests/unparsing/allocator/test.out new file mode 100644 index 000000000..fd57a00ac --- /dev/null +++ b/testsuite/tests/unparsing/allocator/test.out @@ -0,0 +1 @@ +new (Pool) Integer'(12) diff --git a/testsuite/tests/unparsing/allocator/test.yaml b/testsuite/tests/unparsing/allocator/test.yaml new file mode 100644 index 000000000..b7183e9bb --- /dev/null +++ b/testsuite/tests/unparsing/allocator/test.yaml @@ -0,0 +1,6 @@ +description: | + This test checks the formatting of an allocator. + It is expected the declaration stays on a single line. + +driver: unparser +rule: allocator diff --git a/testsuite/tests/unparsing/qual_expr/expr_1/doc-baseline.json b/testsuite/tests/unparsing/qual_expr/expr_1/doc-baseline.json new file mode 100644 index 000000000..5cc724f5c --- /dev/null +++ b/testsuite/tests/unparsing/qual_expr/expr_1/doc-baseline.json @@ -0,0 +1,80 @@ +{ + "id": 9, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 8, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "Integer'" + }, + { + "id": 7, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 6, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 5, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 4, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "text", + "text": "(12)" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/qual_expr/expr_1/input.ada b/testsuite/tests/unparsing/qual_expr/expr_1/input.ada new file mode 100644 index 000000000..48f5c9121 --- /dev/null +++ b/testsuite/tests/unparsing/qual_expr/expr_1/input.ada @@ -0,0 +1 @@ +Integer'(12) diff --git a/testsuite/tests/unparsing/qual_expr/expr_1/test.out b/testsuite/tests/unparsing/qual_expr/expr_1/test.out new file mode 100644 index 000000000..48f5c9121 --- /dev/null +++ b/testsuite/tests/unparsing/qual_expr/expr_1/test.out @@ -0,0 +1 @@ +Integer'(12) diff --git a/testsuite/tests/unparsing/qual_expr/expr_1/test.yaml b/testsuite/tests/unparsing/qual_expr/expr_1/test.yaml new file mode 100644 index 000000000..b25785717 --- /dev/null +++ b/testsuite/tests/unparsing/qual_expr/expr_1/test.yaml @@ -0,0 +1,6 @@ +description: | + This test checks the formatting of a qualified expression. + It is expected the declaration stays on a single line. + +driver: unparser +rule: expr diff --git a/testsuite/tests/unparsing/qual_expr/expr_2/doc-baseline.json b/testsuite/tests/unparsing/qual_expr/expr_2/doc-baseline.json new file mode 100644 index 000000000..18ea2d38e --- /dev/null +++ b/testsuite/tests/unparsing/qual_expr/expr_2/doc-baseline.json @@ -0,0 +1,184 @@ +{ + "id": 23, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 22, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "QualName'" + }, + { + "id": 21, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 20, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 19, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 18, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "text", + "text": "[" + }, + { + "id": 16, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 14, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 13, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 3, + "kind": "text", + "text": "Val1" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 7, + "kind": "text", + "text": "," + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 9, + "kind": "text", + "text": "Val2" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + } + } + }, + { + "id": 17, + "kind": "text", + "text": "]" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/qual_expr/expr_2/input.ada b/testsuite/tests/unparsing/qual_expr/expr_2/input.ada new file mode 100644 index 000000000..2346aebac --- /dev/null +++ b/testsuite/tests/unparsing/qual_expr/expr_2/input.ada @@ -0,0 +1 @@ +QualName'[Val1,Val2] diff --git a/testsuite/tests/unparsing/qual_expr/expr_2/test.out b/testsuite/tests/unparsing/qual_expr/expr_2/test.out new file mode 100644 index 000000000..8205083ab --- /dev/null +++ b/testsuite/tests/unparsing/qual_expr/expr_2/test.out @@ -0,0 +1 @@ +QualName'[Val1, Val2] diff --git a/testsuite/tests/unparsing/qual_expr/expr_2/test.yaml b/testsuite/tests/unparsing/qual_expr/expr_2/test.yaml new file mode 100644 index 000000000..b25785717 --- /dev/null +++ b/testsuite/tests/unparsing/qual_expr/expr_2/test.yaml @@ -0,0 +1,6 @@ +description: | + This test checks the formatting of a qualified expression. + It is expected the declaration stays on a single line. + +driver: unparser +rule: expr diff --git a/testsuite/tests/unparsing/qual_expr/expr_3/doc-baseline.json b/testsuite/tests/unparsing/qual_expr/expr_3/doc-baseline.json new file mode 100644 index 000000000..6020f111d --- /dev/null +++ b/testsuite/tests/unparsing/qual_expr/expr_3/doc-baseline.json @@ -0,0 +1,164 @@ +{ + "id": 20, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 19, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "QualName'" + }, + { + "id": 18, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 17, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 16, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "text", + "text": "[" + }, + { + "id": 13, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 12, + "kind": "list", + "list": [ + { + "id": 11, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 10, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 9, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "text", + "text": "others =>" + }, + { + "id": 4, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + } + ] + } + } + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 7, + "kind": "text", + "text": "False" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + } + } + }, + { + "id": 14, + "kind": "text", + "text": "]" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/qual_expr/expr_3/input.ada b/testsuite/tests/unparsing/qual_expr/expr_3/input.ada new file mode 100644 index 000000000..b8d336605 --- /dev/null +++ b/testsuite/tests/unparsing/qual_expr/expr_3/input.ada @@ -0,0 +1 @@ +QualName'[others => False] diff --git a/testsuite/tests/unparsing/qual_expr/expr_3/test.out b/testsuite/tests/unparsing/qual_expr/expr_3/test.out new file mode 100644 index 000000000..b8d336605 --- /dev/null +++ b/testsuite/tests/unparsing/qual_expr/expr_3/test.out @@ -0,0 +1 @@ +QualName'[others => False] diff --git a/testsuite/tests/unparsing/qual_expr/expr_3/test.yaml b/testsuite/tests/unparsing/qual_expr/expr_3/test.yaml new file mode 100644 index 000000000..b25785717 --- /dev/null +++ b/testsuite/tests/unparsing/qual_expr/expr_3/test.yaml @@ -0,0 +1,6 @@ +description: | + This test checks the formatting of a qualified expression. + It is expected the declaration stays on a single line. + +driver: unparser +rule: expr diff --git a/testsuite/tests/unparsing/qual_expr/long/doc-baseline.json b/testsuite/tests/unparsing/qual_expr/long/doc-baseline.json new file mode 100644 index 000000000..bcf8eb750 --- /dev/null +++ b/testsuite/tests/unparsing/qual_expr/long/doc-baseline.json @@ -0,0 +1,184 @@ +{ + "id": 23, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 22, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "VeeeeeeeeeeeeeeeeeeeerrrrrrrrrrryLooooooooooooooooooooonnnnnnnngQualName'" + }, + { + "id": 21, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 20, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": true, + "hard": false + } + }, + { + "id": 19, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 18, + "kind": "list", + "list": [ + { + "id": 2, + "kind": "text", + "text": "[" + }, + { + "id": 16, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 1 + }, + "alignContents": { + "id": 15, + "kind": "list", + "list": [ + { + "id": 14, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 13, + "kind": "list", + "list": [ + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 3, + "kind": "text", + "text": "Val1" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 7, + "kind": "text", + "text": "," + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "innerRoot" + }, + "alignContents": { + "id": 9, + "kind": "text", + "text": "Val2" + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + } + } + }, + { + "id": 17, + "kind": "text", + "text": "]" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/qual_expr/long/input.ada b/testsuite/tests/unparsing/qual_expr/long/input.ada new file mode 100644 index 000000000..5d82cac22 --- /dev/null +++ b/testsuite/tests/unparsing/qual_expr/long/input.ada @@ -0,0 +1 @@ +VeeeeeeeeeeeeeeeeeeeerrrrrrrrrrryLooooooooooooooooooooonnnnnnnngQualName'[Val1,Val2] diff --git a/testsuite/tests/unparsing/qual_expr/long/test.out b/testsuite/tests/unparsing/qual_expr/long/test.out new file mode 100644 index 000000000..975affff4 --- /dev/null +++ b/testsuite/tests/unparsing/qual_expr/long/test.out @@ -0,0 +1,2 @@ +VeeeeeeeeeeeeeeeeeeeerrrrrrrrrrryLooooooooooooooooooooonnnnnnnngQualName' + [Val1, Val2] diff --git a/testsuite/tests/unparsing/qual_expr/long/test.yaml b/testsuite/tests/unparsing/qual_expr/long/test.yaml new file mode 100644 index 000000000..18e28548c --- /dev/null +++ b/testsuite/tests/unparsing/qual_expr/long/test.yaml @@ -0,0 +1,7 @@ +description: | + This test checks the formatting of a qualified expression. + It is expected the declaration breaks after `'` and the new + line be indented. + +driver: unparser +rule: expr