diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index e7de6e213..c506f5d3c 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -4528,6 +4528,43 @@ ] } }, + "RaiseExpr": { + "node": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "raise" + }, + { + "kind": "recurse_field", + "field": "f_exception_name" + }, + { + "kind": "recurse_field", + "field": "f_error_message" + } + ] + }, + "fields": { + "f_error_message": { + "kind": "align", + "width": 2, + "contents": { + "kind": "group", + "document": [ + "line", + { + "kind": "text", + "text": "with" + }, + "whitespace", + "recurse" + ] + } + } + } + }, "RaiseStmt": { "node": { "kind": "group", @@ -4554,10 +4591,18 @@ "f_error_message": { "kind": "align", "width": 2, - "contents": [ - "line", - "recurse" - ] + "contents": { + "kind": "group", + "document": [ + "line", + { + "kind": "text", + "text": "with" + }, + "whitespace", + "recurse" + ] + } } } }, diff --git a/testsuite/tests/unparsing/raise_expr/long/doc-baseline.json b/testsuite/tests/unparsing/raise_expr/long/doc-baseline.json new file mode 100644 index 000000000..424df0a39 --- /dev/null +++ b/testsuite/tests/unparsing/raise_expr/long/doc-baseline.json @@ -0,0 +1,63 @@ +{ + "id": 7, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 6, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError" + }, + { + "id": 5, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 4, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "with \"a looooooooooooong too bad message\"" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/raise_expr/long/input.ada b/testsuite/tests/unparsing/raise_expr/long/input.ada new file mode 100644 index 000000000..c76642be7 --- /dev/null +++ b/testsuite/tests/unparsing/raise_expr/long/input.ada @@ -0,0 +1 @@ +raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError with "a looooooooooooong too bad message" diff --git a/testsuite/tests/unparsing/raise_expr/long/test.out b/testsuite/tests/unparsing/raise_expr/long/test.out new file mode 100644 index 000000000..41a442ad7 --- /dev/null +++ b/testsuite/tests/unparsing/raise_expr/long/test.out @@ -0,0 +1,2 @@ +raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError + with "a looooooooooooong too bad message" diff --git a/testsuite/tests/unparsing/raise_expr/long/test.yaml b/testsuite/tests/unparsing/raise_expr/long/test.yaml new file mode 100644 index 000000000..de72d70b3 --- /dev/null +++ b/testsuite/tests/unparsing/raise_expr/long/test.yaml @@ -0,0 +1,8 @@ +description: | + This test checks the formatting of a raise expression + with the line length exceeded. + It is expected the expression breaks before the `with` + keyword and the new line be indented. + +driver: unparser +rule: raise_expr diff --git a/testsuite/tests/unparsing/raise_expr/short/doc-baseline.json b/testsuite/tests/unparsing/raise_expr/short/doc-baseline.json new file mode 100644 index 000000000..b119dab88 --- /dev/null +++ b/testsuite/tests/unparsing/raise_expr/short/doc-baseline.json @@ -0,0 +1,63 @@ +{ + "id": 7, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 6, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "raise NotImplementedError" + }, + { + "id": 5, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 4, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "with \"too bad\"" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/raise_expr/short/input.ada b/testsuite/tests/unparsing/raise_expr/short/input.ada new file mode 100644 index 000000000..d4c91b530 --- /dev/null +++ b/testsuite/tests/unparsing/raise_expr/short/input.ada @@ -0,0 +1 @@ +raise NotImplementedError with "too bad" diff --git a/testsuite/tests/unparsing/raise_expr/short/test.out b/testsuite/tests/unparsing/raise_expr/short/test.out new file mode 100644 index 000000000..d4c91b530 --- /dev/null +++ b/testsuite/tests/unparsing/raise_expr/short/test.out @@ -0,0 +1 @@ +raise NotImplementedError with "too bad" diff --git a/testsuite/tests/unparsing/raise_expr/short/test.yaml b/testsuite/tests/unparsing/raise_expr/short/test.yaml new file mode 100644 index 000000000..f88b55ea5 --- /dev/null +++ b/testsuite/tests/unparsing/raise_expr/short/test.yaml @@ -0,0 +1,6 @@ +description: | + This test checks the formatting of a raise expression. + It is expected the expression stays on a single line. + +driver: unparser +rule: raise_expr diff --git a/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/doc-baseline.json b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/doc-baseline.json index f888afdea..e0438cff3 100644 --- a/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/doc-baseline.json +++ b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/doc-baseline.json @@ -1,20 +1,20 @@ { - "id": 7, + "id": 8, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 6, + "id": 7, "kind": "list", "list": [ { "id": 0, "kind": "text", - "text": "raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError with" + "text": "raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError" }, { - "id": 4, + "id": 5, "kind": "command", "command": { "command": "align", @@ -23,30 +23,40 @@ "n": 2 }, "alignContents": { - "id": 3, - "kind": "list", - "list": [ - { - "id": 1, - "kind": "command", - "command": { - "command": "line", - "literal": false, - "soft": false, - "hard": false - } + "id": 4, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "with \"a looooooooooooong too bad message\"" + } + ] }, - { - "id": 2, - "kind": "text", - "text": "\"a looooooooooooong too bad message\"" - } - ] + "break": false, + "expandedStates": null + } } } }, { - "id": 5, + "id": 6, "kind": "text", "text": ";" } diff --git a/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.out b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.out index bd8c4fff6..885925357 100644 --- a/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.out +++ b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.out @@ -1,2 +1,2 @@ -raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError with - "a looooooooooooong too bad message"; +raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError + with "a looooooooooooong too bad message"; diff --git a/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.yaml b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.yaml index db7960af9..c0605b1fc 100644 --- a/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.yaml +++ b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.yaml @@ -1,8 +1,8 @@ description: | This test checks the formatting of a raise statement with the line length exceeded. - It is expected the statement breaks after `with` keyword - and the new line is indented. + It is expected the statement breaks before the `with` + keyword and the new line be indented. driver: unparser rule: raise_stmt diff --git a/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/doc-baseline.json b/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/doc-baseline.json index ec32b1540..d9623e49a 100644 --- a/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/doc-baseline.json +++ b/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/doc-baseline.json @@ -1,20 +1,20 @@ { - "id": 7, + "id": 8, "kind": "command", "command": { "command": "group", "id": 0, "groupContents": { - "id": 6, + "id": 7, "kind": "list", "list": [ { "id": 0, "kind": "text", - "text": "raise NotImplementedError with" + "text": "raise NotImplementedError" }, { - "id": 4, + "id": 5, "kind": "command", "command": { "command": "align", @@ -23,30 +23,40 @@ "n": 2 }, "alignContents": { - "id": 3, - "kind": "list", - "list": [ - { - "id": 1, - "kind": "command", - "command": { - "command": "line", - "literal": false, - "soft": false, - "hard": false - } + "id": 4, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 3, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 2, + "kind": "text", + "text": "with \"too bad\"" + } + ] }, - { - "id": 2, - "kind": "text", - "text": "\"too bad\"" - } - ] + "break": false, + "expandedStates": null + } } } }, { - "id": 5, + "id": 6, "kind": "text", "text": ";" } diff --git a/testsuite/tests/unparsing/raise_stmt/without_message/doc-baseline.json b/testsuite/tests/unparsing/raise_stmt/without_message/doc-baseline.json new file mode 100644 index 000000000..6032c162c --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/without_message/doc-baseline.json @@ -0,0 +1,21 @@ +{ + "id": 2, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 1, + "kind": "list", + "list": [ + { + "id": 0, + "kind": "text", + "text": "raise MyException;" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/raise_stmt/without_message/input.ada b/testsuite/tests/unparsing/raise_stmt/without_message/input.ada new file mode 100644 index 000000000..48aa4dae4 --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/without_message/input.ada @@ -0,0 +1 @@ +raise MyException; diff --git a/testsuite/tests/unparsing/raise_stmt/without_message/test.out b/testsuite/tests/unparsing/raise_stmt/without_message/test.out new file mode 100644 index 000000000..48aa4dae4 --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/without_message/test.out @@ -0,0 +1 @@ +raise MyException; diff --git a/testsuite/tests/unparsing/raise_stmt/without_message/test.yaml b/testsuite/tests/unparsing/raise_stmt/without_message/test.yaml new file mode 100644 index 000000000..2831acb3e --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/without_message/test.yaml @@ -0,0 +1,6 @@ +description: | + This test checks the formatting of a raise statement. + It is expected the statement stays on a single line. + +driver: unparser +rule: raise_stmt