diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index cff9f626e..e1ba52121 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -4036,6 +4036,55 @@ } } }, + "ProtectedBodyStub": { + "node": { + "kind": "group", + "document": [ + { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "protected" + }, + "whitespace", + { + "kind": "text", + "text": "body" + }, + "whitespace", + { + "kind": "recurse_field", + "field": "f_name" + }, + "line", + { + "kind": "text", + "text": "is" + }, + { + "kind": "text", + "text": "separate" + } + ] + }, + { + "kind": "recurse_field", + "field": "f_aspects" + }, + { + "kind": "text", + "text": ";" + } + ] + }, + "fields": { + "f_aspects": [ + "hardlineWithoutBreakParent", + "recurse" + ] + } + }, "ProtectedDef": { "node": { "kind": "group", diff --git a/testsuite/tests/unparsing/protected_body_stub/long/doc-baseline.json b/testsuite/tests/unparsing/protected_body_stub/long/doc-baseline.json new file mode 100644 index 000000000..7333851e7 --- /dev/null +++ b/testsuite/tests/unparsing/protected_body_stub/long/doc-baseline.json @@ -0,0 +1,57 @@ +{ + "id": 7, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 6, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "protected body veeeeeerrrrrrrrrrrrrrrrrrrrrrrry_loooooooooooooooooonnnnnnnng_name" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "is separate" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 5, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/protected_body_stub/long/input.ada b/testsuite/tests/unparsing/protected_body_stub/long/input.ada new file mode 100644 index 000000000..aec1d50cd --- /dev/null +++ b/testsuite/tests/unparsing/protected_body_stub/long/input.ada @@ -0,0 +1,4 @@ +protected body veeeeeerrrrrrrrrrrrrrrrrrrrrrrry_loooooooooooooooooonnnnnnnng_name is separate; + + + diff --git a/testsuite/tests/unparsing/protected_body_stub/long/test.out b/testsuite/tests/unparsing/protected_body_stub/long/test.out new file mode 100644 index 000000000..4cfefb28a --- /dev/null +++ b/testsuite/tests/unparsing/protected_body_stub/long/test.out @@ -0,0 +1,2 @@ +protected body veeeeeerrrrrrrrrrrrrrrrrrrrrrrry_loooooooooooooooooonnnnnnnng_name +is separate; diff --git a/testsuite/tests/unparsing/protected_body_stub/long/test.yaml b/testsuite/tests/unparsing/protected_body_stub/long/test.yaml new file mode 100644 index 000000000..03f1c0876 --- /dev/null +++ b/testsuite/tests/unparsing/protected_body_stub/long/test.yaml @@ -0,0 +1,7 @@ +description: | + This test checks the formatting of protected body stub. + It is expected the declaration breaks before `is` + keyword and `protected` and `is` keywords be aligned. + +driver: unparser +rule: protected_body_stub diff --git a/testsuite/tests/unparsing/protected_body_stub/short/doc-baseline.json b/testsuite/tests/unparsing/protected_body_stub/short/doc-baseline.json new file mode 100644 index 000000000..5d64fa888 --- /dev/null +++ b/testsuite/tests/unparsing/protected_body_stub/short/doc-baseline.json @@ -0,0 +1,57 @@ +{ + "id": 7, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 6, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "protected body PB" + }, + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "is separate" + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 5, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/protected_body_stub/short/input.ada b/testsuite/tests/unparsing/protected_body_stub/short/input.ada new file mode 100644 index 000000000..f9843fd2f --- /dev/null +++ b/testsuite/tests/unparsing/protected_body_stub/short/input.ada @@ -0,0 +1 @@ +protected body PB is separate; diff --git a/testsuite/tests/unparsing/protected_body_stub/short/test.out b/testsuite/tests/unparsing/protected_body_stub/short/test.out new file mode 100644 index 000000000..f9843fd2f --- /dev/null +++ b/testsuite/tests/unparsing/protected_body_stub/short/test.out @@ -0,0 +1 @@ +protected body PB is separate; diff --git a/testsuite/tests/unparsing/protected_body_stub/short/test.yaml b/testsuite/tests/unparsing/protected_body_stub/short/test.yaml new file mode 100644 index 000000000..06067b9e7 --- /dev/null +++ b/testsuite/tests/unparsing/protected_body_stub/short/test.yaml @@ -0,0 +1,6 @@ +description: | + This test checks the formatting of protected body stub. + It is expected the declaration stays on a single line. + +driver: unparser +rule: protected_body_stub