Skip to content

Commit

Permalink
Merge branch 'mku/raise_stmt' into 'master'
Browse files Browse the repository at this point in the history
Unparsing: Add RaiseStmt and RaiseExpr config

Closes #1371

See merge request eng/libadalang/libadalang!1629
  • Loading branch information
CKMonika committed Apr 19, 2024
2 parents 2d6b738 + fc5cada commit b951e15
Show file tree
Hide file tree
Showing 25 changed files with 436 additions and 0 deletions.
78 changes: 78 additions & 0 deletions extensions/default_unparsing_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
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
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError with "a looooooooooooong too bad message";
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
raise VeeeeeeeeeeeeryyyyyyyyLoooongNotImplementedError
with "a looooooooooooong too bad message";
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions testsuite/tests/unparsing/raise_stmt/simple/doc-baseline.json
Original file line number Diff line number Diff line change
@@ -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
}
}
1 change: 1 addition & 0 deletions testsuite/tests/unparsing/raise_stmt/simple/input.ada
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
raise;
1 change: 1 addition & 0 deletions testsuite/tests/unparsing/raise_stmt/simple/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
raise;
6 changes: 6 additions & 0 deletions testsuite/tests/unparsing/raise_stmt/simple/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 statement.
It is expected the statement stays on a single line.
driver: unparser
rule: raise_stmt
Loading

0 comments on commit b951e15

Please sign in to comment.