diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index 73a4208d3..c506f5d3c 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -4528,6 +4528,84 @@ ] } }, + "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", + "document": [ + { + "kind": "text", + "text": "raise" + }, + { + "kind": "recurse_field", + "field": "f_exception_name" + }, + { + "kind": "recurse_field", + "field": "f_error_message" + }, + { + "kind": "text", + "text": ";" + } + ] + }, + "fields": { + "f_error_message": { + "kind": "align", + "width": 2, + "contents": { + "kind": "group", + "document": [ + "line", + { + "kind": "text", + "text": "with" + }, + "whitespace", + "recurse" + ] + } + } + } + }, "RangeSpec": { "node": { "kind": "align", 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 new file mode 100644 index 000000000..e0438cff3 --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/doc-baseline.json @@ -0,0 +1,68 @@ +{ + "id": 8, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 7, + "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 + } + } + } + }, + { + "id": 6, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/input.ada b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/input.ada new file mode 100644 index 000000000..492c80130 --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/input.ada @@ -0,0 +1 @@ +raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError with "a looooooooooooong too bad message"; 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 new file mode 100644 index 000000000..885925357 --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.out @@ -0,0 +1,2 @@ +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 new file mode 100644 index 000000000..c0605b1fc --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/long_with_expr_and_message/test.yaml @@ -0,0 +1,8 @@ +description: | + This test checks the formatting of a raise statement + with the line length exceeded. + 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/simple/doc-baseline.json b/testsuite/tests/unparsing/raise_stmt/simple/doc-baseline.json new file mode 100644 index 000000000..823bc2f69 --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/simple/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;" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/raise_stmt/simple/input.ada b/testsuite/tests/unparsing/raise_stmt/simple/input.ada new file mode 100644 index 000000000..4a0db4915 --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/simple/input.ada @@ -0,0 +1 @@ +raise; diff --git a/testsuite/tests/unparsing/raise_stmt/simple/test.out b/testsuite/tests/unparsing/raise_stmt/simple/test.out new file mode 100644 index 000000000..4a0db4915 --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/simple/test.out @@ -0,0 +1 @@ +raise; diff --git a/testsuite/tests/unparsing/raise_stmt/simple/test.yaml b/testsuite/tests/unparsing/raise_stmt/simple/test.yaml new file mode 100644 index 000000000..2831acb3e --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/simple/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 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 new file mode 100644 index 000000000..d9623e49a --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/doc-baseline.json @@ -0,0 +1,68 @@ +{ + "id": 8, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 7, + "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 + } + } + } + }, + { + "id": 6, + "kind": "text", + "text": ";" + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/input.ada b/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/input.ada new file mode 100644 index 000000000..113445afc --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/input.ada @@ -0,0 +1 @@ +raise NotImplementedError with "too bad"; diff --git a/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/test.out b/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/test.out new file mode 100644 index 000000000..113445afc --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/test.out @@ -0,0 +1 @@ +raise NotImplementedError with "too bad"; diff --git a/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/test.yaml b/testsuite/tests/unparsing/raise_stmt/with_expr_and_message/test.yaml new file mode 100644 index 000000000..2831acb3e --- /dev/null +++ b/testsuite/tests/unparsing/raise_stmt/with_expr_and_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 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