Skip to content

Commit

Permalink
Add config and test for DeclExpr
Browse files Browse the repository at this point in the history
  • Loading branch information
joaopsazevedo committed Aug 6, 2024
1 parent 72ae80a commit 3a472c1
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 68 deletions.
169 changes: 101 additions & 68 deletions extensions/default_unparsing_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -614,29 +614,29 @@
"kind": "group",
"document": [
{
"kind": "group",
"document": [
{
"kind": "recurse_field",
"field": "f_left"
"kind": "group",
"document": [
{
"kind": "recurse_field",
"field": "f_left"
}
]
},
"line",
{
"kind": "recurse_field",
"field": "f_op"
},
"whitespace",
{
"kind": "innerRoot",
"contents": {
"kind": "recurse_field",
"field": "f_right"
},
"line",
{
"kind": "recurse_field",
"field": "f_op"
},
"whitespace",
{
"kind": "innerRoot",
"contents": {
"kind": "recurse_field",
"field": "f_right"
}
}
]
}
}
]
}
]
},
"matchers": [
Expand Down Expand Up @@ -1762,6 +1762,42 @@
]
}
},
"DeclExpr": {
"node": {
"kind": "group",
"document": [
{
"kind": "text",
"text": "declare"
},
{
"kind": "continuationLineIndent",
"contents": [
"hardline",
{
"kind": "recurse_field",
"field": "f_decls"
}
]
},
"hardline",
{
"kind": "text",
"text": "begin"
},
{
"kind": "continuationLineIndent",
"contents": [
"hardline",
{
"kind": "recurse_field",
"field": "f_expr"
}
]
}
]
}
},
"DeclList": {
"sep": [
"recurse",
Expand Down Expand Up @@ -3583,8 +3619,8 @@
"contents": {
"kind": "group",
"document": {
"kind": "recurse_field",
"field": "f_cond_expr"
"kind": "recurse_field",
"field": "f_cond_expr"
}
}
},
Expand Down Expand Up @@ -3649,14 +3685,14 @@
"recurse"
],
"else": [
{
"kind": "indent",
"contents": [
"hardlineWithoutBreakParent",
"recurse"
]
},
"hardlineWithoutBreakParent"
{
"kind": "indent",
"contents": [
"hardlineWithoutBreakParent",
"recurse"
]
},
"hardlineWithoutBreakParent"
]
}
]
Expand Down Expand Up @@ -4945,10 +4981,7 @@
},
"ParenExpr": {
"node": {
"kind": "align",
"width": " ",
"contents": {
"kind": "group",
"kind": "group",
"document": [
{
"kind": "text",
Expand Down Expand Up @@ -5439,7 +5472,7 @@
"kind": "group",
"document": [
"line",
"recurse"
"recurse"
]
}
}
Expand Down Expand Up @@ -5502,21 +5535,21 @@
{
"kind": "group",
"document": [
{
"kind": "text",
"text": "("
},
{
"kind": "align",
"width": " ",
"contents": {
"kind": "recurse_field",
"field": "f_args"
}
},
{
"kind": "text",
"text": ")"
{
"kind": "text",
"text": "("
},
{
"kind": "align",
"width": " ",
"contents": {
"kind": "recurse_field",
"field": "f_args"
}
},
{
"kind": "text",
"text": ")"
}
]
}
Expand Down Expand Up @@ -5681,24 +5714,24 @@
"document": []
},
{
"kind": "group",
"document": [
{
"kind": "recurse_field",
"field": "f_left"
},
"line",
{
"kind": "recurse_field",
"field": "f_op"
},
"whitespace",
{
"kind": "innerRoot",
"contents": {
"kind": "recurse_field",
"field": "f_right"
}
"kind": "group",
"document": [
{
"kind": "recurse_field",
"field": "f_left"
},
"line",
{
"kind": "recurse_field",
"field": "f_op"
},
"whitespace",
{
"kind": "innerRoot",
"contents": {
"kind": "recurse_field",
"field": "f_right"
}
}
]
}
Expand Down
8 changes: 8 additions & 0 deletions testsuite/tests/unparsing/decl_expr/input.ada
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function Is_Subp_Decl_An_Import_With_Expression
(Subp : Basic_Decl'Class) return Boolean
is (declare
Import_Aspect : constant Aspect :=
Subp.P_Get_Aspect (Langkit_Support.Text.To_Unbounded_Text ("Import"));
begin
Exists (Import_Aspect)
and then (To_Lower (+Value (Import_Aspect).Text) /= "false"));
8 changes: 8 additions & 0 deletions testsuite/tests/unparsing/decl_expr/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function Is_Subp_Decl_An_Import_With_Expression
(Subp : Basic_Decl'Class) return Boolean
is (declare
Import_Aspect : constant Aspect :=
Subp.P_Get_Aspect (Langkit_Support.Text.To_Unbounded_Text ("Import"));
begin
Exists (Import_Aspect)
and then (To_Lower (+Value (Import_Aspect).Text) /= "false"));
4 changes: 4 additions & 0 deletions testsuite/tests/unparsing/decl_expr/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
driver: unparser
rule: subp_decl
description: |
Test indentation of `f_decls` and `f_expr` on a `DeclExpr`.

0 comments on commit 3a472c1

Please sign in to comment.