diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index c704900c9..d4e40c552 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -29,6 +29,44 @@ } } }, + "AbstractSubpDecl": { + "node": { + "kind": "group", + "document": [ + { + "kind": "recurse_field", + "field": "f_overriding" + }, + { + "kind": "recurse_field", + "field": "f_subp_spec" + }, + "line", + { + "kind": "text", + "text": "is" + }, + { + "kind": "text", + "text": "abstract" + }, + { + "kind": "recurse_field", + "field": "f_aspects" + }, + { + "kind": "text", + "text": ";" + } + ] + }, + "fields": { + "f_aspects": [ + "hardlineWithoutBreakParent", + "recurse" + ] + } + }, "AcceptStmt": { "node": { "kind": "group", @@ -228,7 +266,6 @@ "kind": "text", "text": "new" }, - "whitespace", { "kind": "recurse_field", "field": "f_subpool" @@ -239,6 +276,20 @@ "field": "f_type_or_expr" } ] + }, + "fields": { + "f_subpool": [ + "whitespace", + { + "kind": "text", + "text": "(" + }, + "recurse", + { + "kind": "text", + "text": ")" + } + ] } }, "AlternativesList": { @@ -617,8 +668,11 @@ "text": "(" }, { - "kind": "recurse_field", - "field": "f_suffix" + "kind": "innerRoot", + "contents": { + "kind": "recurse_field", + "field": "f_suffix" + } }, { "kind": "text", @@ -1047,6 +1101,59 @@ } } }, + "CompositeConstraint": { + "node": { + "kind": "group", + "document": [ + "line", + { + "kind": "text", + "text": "(" + }, + { + "kind": "recurse_field", + "field": "f_constraints" + }, + { + "kind": "text", + "text": ")" + } + ] + } + }, + "CompositeConstraintAssoc": { + "node": { + "kind": "group", + "document": [ + { + "kind": "recurse_field", + "field": "f_ids" + }, + { + "kind": "innerRoot", + "contents": { + "kind": "recurse_field", + "field": "f_constraint_expr" + } + } + ] + }, + "fields": { + "f_ids": { + "kind": "align", + "width": 2, + "contents": [ + "recurse", + "whitespace", + { + "kind": "text", + "text": "=>" + }, + "line" + ] + } + } + }, "ConcatOp": { "node": { "kind": "group", @@ -2476,7 +2583,6 @@ "kind": "recurse_field", "field": "f_iter_expr" }, - "line", { "kind": "recurse_field", "field": "f_iter_filter" @@ -2484,6 +2590,12 @@ ] } ] + }, + "fields": { + "f_iter_filter": [ + "line", + "recurse" + ] } }, "ForLoopStmt": { @@ -5748,4 +5860,4 @@ } }, "max_empty_lines": 1 -} +} \ No newline at end of file diff --git a/testsuite/tests/unparsing/call_stmt/input.ada b/testsuite/tests/unparsing/call_stmt/long/input.ada similarity index 100% rename from testsuite/tests/unparsing/call_stmt/input.ada rename to testsuite/tests/unparsing/call_stmt/long/input.ada diff --git a/testsuite/tests/unparsing/call_stmt/test.out b/testsuite/tests/unparsing/call_stmt/long/test.out similarity index 100% rename from testsuite/tests/unparsing/call_stmt/test.out rename to testsuite/tests/unparsing/call_stmt/long/test.out diff --git a/testsuite/tests/unparsing/call_stmt/test.yaml b/testsuite/tests/unparsing/call_stmt/long/test.yaml similarity index 100% rename from testsuite/tests/unparsing/call_stmt/test.yaml rename to testsuite/tests/unparsing/call_stmt/long/test.yaml diff --git a/testsuite/tests/unparsing/call_stmt/param_align/input.ada b/testsuite/tests/unparsing/call_stmt/param_align/input.ada new file mode 100644 index 000000000..f061956da --- /dev/null +++ b/testsuite/tests/unparsing/call_stmt/param_align/input.ada @@ -0,0 +1,5 @@ +Foo + (AAAA => Foo_1, + BB => Foo_2, + CCCCCCC => Foo_3, + DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD => 7); diff --git a/testsuite/tests/unparsing/call_stmt/param_align/test.out b/testsuite/tests/unparsing/call_stmt/param_align/test.out new file mode 100644 index 000000000..02a4249bd --- /dev/null +++ b/testsuite/tests/unparsing/call_stmt/param_align/test.out @@ -0,0 +1,5 @@ +Foo + (AAAA => Foo_1, + BB => Foo_2, + CCCCCCC => Foo_3, + DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD => 7); diff --git a/testsuite/tests/unparsing/call_stmt/param_align/test.yaml b/testsuite/tests/unparsing/call_stmt/param_align/test.yaml new file mode 100644 index 000000000..40e6e6572 --- /dev/null +++ b/testsuite/tests/unparsing/call_stmt/param_align/test.yaml @@ -0,0 +1,6 @@ +driver: unparser +rule: stmt +description: | + Base test for a `CallStmt`. Tests that if the statement is too long, the + underlying `CallExpr` breaks. Additionally, this test checks this behaviour + when the `;` is at the line length limit. diff --git a/testsuite/tests/unparsing/for_loop_stmt/array_init/input.ada b/testsuite/tests/unparsing/for_loop_stmt/array_init/input.ada new file mode 100644 index 000000000..89044f00f --- /dev/null +++ b/testsuite/tests/unparsing/for_loop_stmt/array_init/input.ada @@ -0,0 +1,3 @@ + for I in My_Tasks'Range loop + My_Tasks (I).Start (I); + end loop; diff --git a/testsuite/tests/unparsing/for_loop_stmt/array_init/test.out b/testsuite/tests/unparsing/for_loop_stmt/array_init/test.out new file mode 100644 index 000000000..719b2d9b6 --- /dev/null +++ b/testsuite/tests/unparsing/for_loop_stmt/array_init/test.out @@ -0,0 +1,3 @@ +for I in My_Tasks'Range loop + My_Tasks (I).Start (I); +end loop; diff --git a/testsuite/tests/unparsing/for_loop_stmt/array_init/test.yaml b/testsuite/tests/unparsing/for_loop_stmt/array_init/test.yaml new file mode 100644 index 000000000..b85264fde --- /dev/null +++ b/testsuite/tests/unparsing/for_loop_stmt/array_init/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: stmt +description: | + Test that no line breaks are added. diff --git a/testsuite/tests/unparsing/object_decl/with_composite_constraints/input.ada b/testsuite/tests/unparsing/object_decl/with_composite_constraints/input.ada new file mode 100644 index 000000000..3c9ff21c2 --- /dev/null +++ b/testsuite/tests/unparsing/object_decl/with_composite_constraints/input.ada @@ -0,0 +1 @@ +Max : not null Person_Name := new Person(Sex=>M); diff --git a/testsuite/tests/unparsing/object_decl/with_composite_constraints/test.out b/testsuite/tests/unparsing/object_decl/with_composite_constraints/test.out new file mode 100644 index 000000000..65d849f2d --- /dev/null +++ b/testsuite/tests/unparsing/object_decl/with_composite_constraints/test.out @@ -0,0 +1 @@ +Max : not null Person_Name := new Person (Sex => M); diff --git a/testsuite/tests/unparsing/object_decl/with_composite_constraints/test.yaml b/testsuite/tests/unparsing/object_decl/with_composite_constraints/test.yaml new file mode 100644 index 000000000..cf3e2c7d5 --- /dev/null +++ b/testsuite/tests/unparsing/object_decl/with_composite_constraints/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: object_decl +description: | + Base test case for a short `ObjectDecl`. diff --git a/testsuite/tests/unparsing/single_protected_decl/test.out b/testsuite/tests/unparsing/single_protected_decl/test.out index e02f8ade8..d9a1f0814 100644 --- a/testsuite/tests/unparsing/single_protected_decl/test.out +++ b/testsuite/tests/unparsing/single_protected_decl/test.out @@ -2,5 +2,5 @@ protected Shared_Array is function Component (N : in Index) return Item; procedure Set_Component (N : in Index; E : in Item); private - Table : Item_Array(Index) := (others => Null_Item); + Table : Item_Array (Index) := (others => Null_Item); end Shared_Array; diff --git a/testsuite/tests/unparsing/subp_decl/abstract/input.ada b/testsuite/tests/unparsing/subp_decl/abstract/input.ada new file mode 100644 index 000000000..c0e80968c --- /dev/null +++ b/testsuite/tests/unparsing/subp_decl/abstract/input.ada @@ -0,0 +1,3 @@ + procedure Take(Element : out Element_Type; + From : in out Set) is abstract; + diff --git a/testsuite/tests/unparsing/subp_decl/abstract/test.out b/testsuite/tests/unparsing/subp_decl/abstract/test.out new file mode 100644 index 000000000..704fafd5e --- /dev/null +++ b/testsuite/tests/unparsing/subp_decl/abstract/test.out @@ -0,0 +1 @@ +procedure Take (Element : out Element_Type; From : in out Set) is abstract; diff --git a/testsuite/tests/unparsing/subp_decl/abstract/test.yaml b/testsuite/tests/unparsing/subp_decl/abstract/test.yaml new file mode 100644 index 000000000..9f2c02a97 --- /dev/null +++ b/testsuite/tests/unparsing/subp_decl/abstract/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: subp_decl +description: | + Test that no line break is added after the `f_overriding` fields when the + declaration fits in one line.