Skip to content

Commit

Permalink
Add RaiseExpr config
Browse files Browse the repository at this point in the history
  • Loading branch information
CKMonika committed Apr 18, 2024
1 parent fe1ef30 commit fc5cada
Show file tree
Hide file tree
Showing 17 changed files with 293 additions and 54 deletions.
53 changes: 49 additions & 4 deletions extensions/default_unparsing_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
]
}
}
}
},
Expand Down
63 changes: 63 additions & 0 deletions testsuite/tests/unparsing/raise_expr/long/doc-baseline.json
Original file line number Diff line number Diff line change
@@ -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
}
}
1 change: 1 addition & 0 deletions testsuite/tests/unparsing/raise_expr/long/input.ada
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError with "a looooooooooooong too bad message"
2 changes: 2 additions & 0 deletions testsuite/tests/unparsing/raise_expr/long/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError
with "a looooooooooooong too bad message"
8 changes: 8 additions & 0 deletions testsuite/tests/unparsing/raise_expr/long/test.yaml
Original file line number Diff line number Diff line change
@@ -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
63 changes: 63 additions & 0 deletions testsuite/tests/unparsing/raise_expr/short/doc-baseline.json
Original file line number Diff line number Diff line change
@@ -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
}
}
1 change: 1 addition & 0 deletions testsuite/tests/unparsing/raise_expr/short/input.ada
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
raise NotImplementedError with "too bad"
1 change: 1 addition & 0 deletions testsuite/tests/unparsing/raise_expr/short/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
raise NotImplementedError with "too bad"
6 changes: 6 additions & 0 deletions testsuite/tests/unparsing/raise_expr/short/test.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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": ";"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError with
"a looooooooooooong too bad message";
raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError
with "a looooooooooooong too bad message";
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit fc5cada

Please sign in to comment.