From 022e61cc1bcad08d69848909f7f87f0a389a316b Mon Sep 17 00:00:00 2001 From: Monika Kurovszky Date: Fri, 12 Apr 2024 14:55:45 +0200 Subject: [PATCH] Add AttributeDefClause and AttributeRef configs --- extensions/default_unparsing_config.json | 54 ++++++++++++++ .../attribute_def_clause/doc-baseline.json | 74 +++++++++++++++++++ .../unparsing/attribute_def_clause/input.ada | 1 + .../unparsing/attribute_def_clause/test.out | 1 + .../unparsing/attribute_def_clause/test.yaml | 7 ++ 5 files changed, 137 insertions(+) create mode 100644 testsuite/tests/unparsing/attribute_def_clause/doc-baseline.json create mode 100644 testsuite/tests/unparsing/attribute_def_clause/input.ada create mode 100644 testsuite/tests/unparsing/attribute_def_clause/test.out create mode 100644 testsuite/tests/unparsing/attribute_def_clause/test.yaml diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index d8bafe245..ed2c4a014 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -410,6 +410,60 @@ } } }, + "AttributeDefClause": { + "node": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "for" + }, + { + "kind": "recurse_field", + "field": "f_attribute_expr" + }, + { + "kind": "text", + "text": "use" + }, + { + "kind": "align", + "width": 2, + "contents": { + "kind": "recurse_field", + "field": "f_expr" + } + }, + { + "kind": "text", + "text": ";" + } + ] + } + }, + "AttributeRef": { + "node": { + "kind": "group", + "document": [ + { + "kind": "recurse_field", + "field": "f_prefix" + }, + { + "kind": "text", + "text": "'" + }, + { + "kind": "recurse_field", + "field": "f_attribute" + }, + { + "kind": "recurse_field", + "field": "f_args" + } + ] + } + }, "AssocList": { "sep": [ "recurse", diff --git a/testsuite/tests/unparsing/attribute_def_clause/doc-baseline.json b/testsuite/tests/unparsing/attribute_def_clause/doc-baseline.json new file mode 100644 index 000000000..013181523 --- /dev/null +++ b/testsuite/tests/unparsing/attribute_def_clause/doc-baseline.json @@ -0,0 +1,74 @@ +{ + "id": 10, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 9, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "for" + }, + { + "id": 3, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 2, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "text", + "text": " Small'Size" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 4, + "kind": "text", + "text": " use" + }, + { + "id": 7, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 6, + "kind": "list", + "list": [ + { + "id": 5, + "kind": "text", + "text": " 16" + } + ] + } + } + }, + { + "id": 8, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/attribute_def_clause/input.ada b/testsuite/tests/unparsing/attribute_def_clause/input.ada new file mode 100644 index 000000000..f4c597d52 --- /dev/null +++ b/testsuite/tests/unparsing/attribute_def_clause/input.ada @@ -0,0 +1 @@ +for Small'Size use 16; diff --git a/testsuite/tests/unparsing/attribute_def_clause/test.out b/testsuite/tests/unparsing/attribute_def_clause/test.out new file mode 100644 index 000000000..f4c597d52 --- /dev/null +++ b/testsuite/tests/unparsing/attribute_def_clause/test.out @@ -0,0 +1 @@ +for Small'Size use 16; diff --git a/testsuite/tests/unparsing/attribute_def_clause/test.yaml b/testsuite/tests/unparsing/attribute_def_clause/test.yaml new file mode 100644 index 000000000..edf23ccfa --- /dev/null +++ b/testsuite/tests/unparsing/attribute_def_clause/test.yaml @@ -0,0 +1,7 @@ +description: | + This test checks the formatting of an attribute definition + clause. + It is expected the declaration stays on a single line. + +driver: unparser +rule: aspect_clause