diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index fcdd5dddc..3e00abeed 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -105,6 +105,29 @@ "text": ";" } ] + }, + "fields": { + "f_entry_index_expr": [ + { + "kind": "group", + "document": [ + "line", + { + "kind": "text", + "text": "(" + }, + { + "kind": "align", + "width": " ", + "contents": "recurse" + }, + { + "kind": "text", + "text": ")" + } + ] + } + ] } }, "AcceptStmtBody": { @@ -120,26 +143,31 @@ "kind": "group", "document": [ { - "kind": "text", - "text": "accept" - }, - "whitespace", - { - "kind": "recurse_field", - "field": "f_body_decl" - }, - { - "kind": "recurse_field", - "field": "f_entry_index_expr" - }, - { - "kind": "recurse_field", - "field": "f_params" - }, - "line", - { - "kind": "text", - "text": "do" + "kind": "group", + "document": [ + { + "kind": "text", + "text": "accept" + }, + "whitespace", + { + "kind": "recurse_field", + "field": "f_body_decl" + }, + { + "kind": "recurse_field", + "field": "f_entry_index_expr" + }, + { + "kind": "recurse_field", + "field": "f_params" + }, + "line", + { + "kind": "text", + "text": "do" + } + ] }, { "kind": "recurse_field", @@ -150,7 +178,6 @@ "kind": "text", "text": "end" }, - "whitespace", { "kind": "recurse_field", "field": "f_end_name" @@ -162,24 +189,7 @@ ] }, "fields": { - "f_entry_index_expr": [ - "whitespace", - { - "kind": "group", - "document": [ - { - "kind": "text", - "text": "(" - }, - "recurse", - { - "kind": "text", - "text": ")" - } - ] - } - ], - "f_params": [ + "f_end_name": [ "whitespace", "recurse" ] @@ -226,14 +236,23 @@ }, "fields": { "f_ancestor_expr": { - "kind": "continuationLineIndent", - "contents": [ + "kind": "group", + "document": [ "recurse", + "line", { - "kind": "text", - "text": "with" - }, - "line" + "kind": "continuationLineIndent", + "contents": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "with" + }, + "line" + ] + } + } ] } } @@ -706,27 +725,61 @@ "kind": "group", "document": [ { - "kind": "recurse_field", - "field": "f_name" - }, - "line", - { - "kind": "text", - "text": "(" + "kind": "group", + "document": { + "kind": "recurse_field", + "field": "f_name" + }, + "id": "call_name" }, { - "kind": "innerRoot", - "contents": { - "kind": "group", - "document": { - "kind": "recurse_field", - "field": "f_suffix" + "kind": "ifBreak", + "flatContents": [ + "line", + { + "kind": "text", + "text": "(" + }, + { + "kind": "innerRoot", + "contents": { + "kind": "group", + "document": { + "kind": "recurse_field", + "field": "f_suffix" + } + } + }, + { + "kind": "text", + "text": ")" } - } - }, - { - "kind": "text", - "text": ")" + ], + "breakContents": { + "kind": "indent", + "contents": [ + "line", + { + "kind": "text", + "text": "(" + }, + { + "kind": "innerRoot", + "contents": { + "kind": "group", + "document": { + "kind": "recurse_field", + "field": "f_suffix" + } + } + }, + { + "kind": "text", + "text": ")" + } + ] + }, + "groupId": "call_name" } ] } @@ -1047,10 +1100,10 @@ { "kind": "group", "document": [ - "line", { "kind": "continuationLineIndent", "contents": [ + "line", { "kind": "recurse_field", "field": "f_component_def" @@ -1112,24 +1165,21 @@ }, "ComponentDef": { "node": { - "kind": "continuationLineIndent", - "contents": { - "kind": "group", - "document": [ - { - "kind": "recurse_field", - "field": "f_has_aliased" - }, - { - "kind": "recurse_field", - "field": "f_has_constant" - }, - { - "kind": "recurse_field", - "field": "f_type_expr" - } - ] - } + "kind": "group", + "document": [ + { + "kind": "recurse_field", + "field": "f_has_aliased" + }, + { + "kind": "recurse_field", + "field": "f_has_constant" + }, + { + "kind": "recurse_field", + "field": "f_type_expr" + } + ] } }, "ComponentList": { @@ -1169,14 +1219,17 @@ "node": { "kind": "group", "document": [ - "line", { "kind": "text", "text": "(" }, { - "kind": "recurse_field", - "field": "f_constraints" + "kind": "align", + "width": " ", + "contents": { + "kind": "recurse_field", + "field": "f_constraints" + } }, { "kind": "text", @@ -1448,6 +1501,12 @@ ] } }, + "ConstrainedArrayIndices": { + "node": { + "kind": "group", + "document": "recurse" + } + }, "ConstraintList": { "sep": [ "recurse", @@ -1936,6 +1995,21 @@ ] } }, + "EntryCompletionFormalParams": { + "node": { + "kind": "recurse_field", + "field": "f_params" + }, + "fields": { + "f_params": { + "kind": "continuationLineIndent", + "contents": [ + "line", + "recurse" + ] + } + } + }, "EntryDecl": { "node": { "kind": "group", @@ -2100,41 +2174,51 @@ } }, "ElsifExprPart": { - "node": { - "kind": "group", - "document": [ - { - "kind": "text", - "text": "elsif" - }, - "whitespace", - { - "kind": "continuationLineIndent", - "contents": { - "kind": "recurse_field", - "field": "f_cond_expr" - } - }, - "line", - { - "kind": "continuationLineIndent", - "contents": { + "node": [ + { + "kind": "group", + "document": [ + { "kind": "group", "document": [ { "kind": "text", - "text": "then" + "text": "elsif" + }, + "whitespace", + { + "kind": "continuationLineIndent", + "contents": { + "kind": "recurse_field", + "field": "f_cond_expr" + } }, "line", { - "kind": "recurse_field", - "field": "f_then_expr" + "kind": "text", + "text": "then" } ] + }, + { + "kind": "group", + "document": { + "kind": "continuationLineIndent", + "contents": { + "kind": "group", + "document": [ + "line", + { + "kind": "recurse_field", + "field": "f_then_expr" + } + ] + } + } } - } - ] - } + ] + } + ] }, "ElsifStmtPart": { "node": { @@ -2181,8 +2265,8 @@ }, "ElsifExprPartList": { "sep": [ - "hardline", - "recurse" + "recurse", + "line" ] }, "ExceptionDecl": { @@ -3239,33 +3323,44 @@ "kind": "group", "document": [ { - "kind": "text", - "text": "if" - }, - "whitespace", - { - "kind": "continuationLineIndent", - "contents": { - "kind": "recurse_field", - "field": "f_cond_expr" - } + "kind": "group", + "document": [ + { + "kind": "text", + "text": "if" + }, + "whitespace", + { + "kind": "group", + "document": { + "kind": "continuationLineIndent", + "contents": { + "kind": "recurse_field", + "field": "f_cond_expr" + } + } + }, + "line", + { + "kind": "text", + "text": "then" + } + ] }, - "line", { - "kind": "continuationLineIndent", - "contents": { - "kind": "group", - "document": [ - { - "kind": "text", - "text": "then" - }, - "line", - { - "kind": "recurse_field", - "field": "f_then_expr" - } - ] + "kind": "group", + "document": { + "kind": "continuationLineIndent", + "contents": { + "kind": "group", + "document": [ + "line", + { + "kind": "recurse_field", + "field": "f_then_expr" + } + ] + } } } ] @@ -3293,17 +3388,22 @@ "line", { "kind": "group", - "document": { - "kind": "continuationLineIndent", - "contents": [ - { - "kind": "text", - "text": "else" - }, - "line", - "recurse" - ] - } + "document": [ + { + "kind": "text", + "text": "else" + }, + { + "kind": "group", + "document": { + "kind": "continuationLineIndent", + "contents": [ + "line", + "recurse" + ] + } + } + ] } ] } @@ -3577,6 +3677,36 @@ ] } }, + "IteratedAssoc": { + "node": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "for" + }, + "whitespace", + { + "kind": "recurse_field", + "field": "f_spec" + }, + { + "kind": "recurse_field", + "field": "f_key_expr" + }, + "line", + { + "kind": "text", + "text": "=>" + }, + "whitespace", + { + "kind": "recurse_field", + "field": "f_r_expr" + } + ] + } + }, "KnownDiscriminantPart": { "node": { "kind": "group", @@ -3674,6 +3804,72 @@ "line" ] }, + "NullRecordAggregate": { + "node": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "(" + }, + { + "kind": "align", + "width": " ", + "contents": [ + { + "kind": "recurse_field", + "field": "f_ancestor_expr" + }, + "whitespace", + { + "kind": "text", + "text": "null" + }, + "whitespace", + { + "kind": "text", + "text": "record" + }, + { + "kind": "recurse_field", + "field": "f_assocs" + } + ] + }, + { + "kind": "text", + "text": ")" + } + ] + }, + "fields": { + "f_ancestor_expr": [ + { + "kind": "group", + "document": "recurse" + }, + "line", + { + "kind": "text", + "text": "with" + } + ] + }, + "f_assocs": [ + "line", + { + "kind": "text", + "text": "with" + }, + { + "kind": "continuationLineIndent", + "contents": [ + "line", + "recurse" + ] + } + ] + }, "NullRecordDef": { "node": { "kind": "group", @@ -3745,33 +3941,19 @@ }, "ModeIn": { "node": [ - { - "kind": "text", - "text": "in" - }, + "recurse", "whitespace" ] }, "ModeInOut": { "node": [ - { - "kind": "text", - "text": "in" - }, - "whitespace", - { - "kind": "text", - "text": "out" - }, + "recurse", "whitespace" ] }, "ModeOut": { "node": [ - { - "kind": "text", - "text": "out" - }, + "recurse", "whitespace" ] }, @@ -3958,16 +4140,76 @@ "kind": "group", "document": [ { - "kind": "recurse_field", - "field": "f_has_aliased" + "kind": "ifKind", + "field": "f_has_aliased", + "default": { + "kind": "recurse_field", + "field": "f_has_aliased" + }, + "null": { + "kind": "recurse_field", + "field": "f_has_aliased" + }, + "matchers": [ + { + "kind": "AliasedPresent", + "document": [ + { + "kind": "recurse_field", + "field": "f_has_aliased" + }, + "whitespace" + ] + } + ] }, { - "kind": "recurse_field", - "field": "f_has_constant" + "kind": "ifKind", + "field": "f_has_constant", + "default": { + "kind": "recurse_field", + "field": "f_has_constant" + }, + "null": { + "kind": "recurse_field", + "field": "f_has_constant" + }, + "matchers": [ + { + "kind": "ConstantPresent", + "document": [ + { + "kind": "recurse_field", + "field": "f_has_constant" + }, + "whitespace" + ] + } + ] }, { - "kind": "recurse_field", - "field": "f_mode" + "kind": "ifKind", + "field": "f_mode", + "default": [ + { + "kind": "recurse_field", + "field": "f_mode" + }, + "whitespace" + ], + "null": { + "kind": "recurse_field", + "field": "f_mode" + }, + "matchers": [ + { + "kind": "ModeDefault", + "document": { + "kind": "recurse_field", + "field": "f_mode" + } + } + ] }, { "kind": "recurse_field", @@ -4048,6 +4290,10 @@ }, "groupId": "type" } + ], + "f_aspects": [ + "line", + "recurse" ] } }, @@ -4348,10 +4594,13 @@ "field": "f_designator" }, { - "kind": "group", - "document": { - "kind": "recurse_field", - "field": "f_r_expr" + "kind": "innerRoot", + "contents": { + "kind": "group", + "document": { + "kind": "recurse_field", + "field": "f_r_expr" + } } } ], @@ -4919,11 +5168,21 @@ "document": [ "line", { - "kind": "text", - "text": "with" - }, - "whitespace", - "recurse" + "kind": "group", + "document": [ + { + "kind": "text", + "text": "with" + }, + { + "kind": "continuationLineIndent", + "contents": [ + "line", + "recurse" + ] + } + ] + } ] } } @@ -5172,6 +5431,114 @@ ] } }, + "SelectStmt": { + "node": { + "kind": "group", + "document": [ + { + "kind": "text", + "text": "select" + }, + { + "kind": "indent", + "contents": [ + "hardline", + { + "kind": "recurse_field", + "field": "f_guards" + } + ] + }, + { + "kind": "recurse_field", + "field": "f_else_stmts" + }, + { + "kind": "recurse_field", + "field": "f_abort_stmts" + }, + "hardline", + { + "kind": "text", + "text": "end" + }, + "whitespace", + { + "kind": "text", + "text": "select" + }, + { + "kind": "text", + "text": ";" + } + ] + }, + "fields": { + "f_else_stmts": [ + "hardline", + { + "kind": "text", + "text": "else" + }, + { + "kind": "indent", + "contents": [ + "hardline", + "recurse" + ] + } + ], + "f_abort_stmts": [ + "hardline", + { + "kind": "text", + "text": "then" + }, + "whitespace", + { + "kind": "text", + "text": "abort" + }, + { + "kind": "indent", + "contents": [ + "hardline", + "recurse" + ] + } + ] + } + }, + "SelectWhenPart": { + "node": [ + { + "kind": "recurse_field", + "field": "f_cond_expr" + }, + { + "kind": "recurse_field", + "field": "f_stmts" + } + ], + "fields": { + "f_cond_expr": [ + "recurse", + "hardline" + ] + } + }, + "SelectWhenPartList": { + "sep": [ + { + "kind": "dedent", + "contents": [ + "hardline", + "recurse" + ] + }, + "hardline" + ] + }, "SingleProtectedDecl": { "node": { "kind": "group", @@ -5561,6 +5928,42 @@ } } }, + "SubtypeIndication": { + "node": { + "kind": "group", + "document": [ + { + "kind": "recurse_field", + "field": "f_has_not_null" + }, + { + "kind": "group", + "document": { + "kind": "innerRoot", + "contents": [ + { + "kind": "recurse_field", + "field": "f_name" + }, + { + "kind": "recurse_field", + "field": "f_constraint" + } + ] + } + } + ] + }, + "fields": { + "f_constraint": { + "kind": "continuationLineIndent", + "contents": [ + "line", + "recurse" + ] + } + } + }, "Subunit": { "node": { "kind": "group", @@ -5569,6 +5972,7 @@ "kind": "text", "text": "separate" }, + "whitespace", { "kind": "text", "text": "(" @@ -5594,27 +5998,32 @@ "kind": "group", "document": [ { - "kind": "text", - "text": "task" - }, - "whitespace", - { - "kind": "text", - "text": "body" - }, - "whitespace", - { - "kind": "recurse_field", - "field": "f_name" - }, - { - "kind": "recurse_field", - "field": "f_aspects" - }, - "hardlineWithoutBreakParent", - { - "kind": "text", - "text": "is" + "kind": "group", + "document": [ + { + "kind": "text", + "text": "task" + }, + "whitespace", + { + "kind": "text", + "text": "body" + }, + "whitespace", + { + "kind": "recurse_field", + "field": "f_name" + }, + { + "kind": "recurse_field", + "field": "f_aspects" + }, + "line", + { + "kind": "text", + "text": "is" + } + ] }, { "kind": "recurse_field", @@ -5783,9 +6192,15 @@ ] }, { - "kind": "ifBreak", - "flatContents": "line", - "breakContents": "hardlineWithoutBreakParent" + "kind": "ifKind", + "field": "f_definition", + "default": { + "kind": "ifBreak", + "flatContents": "line", + "breakContents": "hardlineWithoutBreakParent" + }, + "null": [], + "matchers": [] } ] }, diff --git a/testsuite/tests/unparsing/aggregate/long_complete/test.out b/testsuite/tests/unparsing/aggregate/long_complete/test.out index cd0a96512..eac868769 100644 --- a/testsuite/tests/unparsing/aggregate/long_complete/test.out +++ b/testsuite/tests/unparsing/aggregate/long_complete/test.out @@ -1,4 +1,5 @@ Foo := - (Baaaar with + (Baaaar + with Qux => Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, Baaaz => Bazzzzzzzz); diff --git a/testsuite/tests/unparsing/call_stmt/concatenation/input.ada b/testsuite/tests/unparsing/call_stmt/concatenation/input.ada new file mode 100644 index 000000000..bc286c023 --- /dev/null +++ b/testsuite/tests/unparsing/call_stmt/concatenation/input.ada @@ -0,0 +1,11 @@ +Add_Attribute + (Package_Name => +"IDE", + Attribute_Name => +"Connection_Tool", + Description => + "Executable used to interface with a " + & "remote target when debugging. GNAT Studio currently supports " + & "OpenOCD, st-util or pyOCD. You can leave this attribute empty " + & "if you are using a custom tool spawned outside of GNAT Studio'.", + Index_Type => PRA.No_Index, + Value => Single, + Value_Case_Sensitive => True); diff --git a/testsuite/tests/unparsing/call_stmt/concatenation/test.out b/testsuite/tests/unparsing/call_stmt/concatenation/test.out new file mode 100644 index 000000000..fe8bac5da --- /dev/null +++ b/testsuite/tests/unparsing/call_stmt/concatenation/test.out @@ -0,0 +1,11 @@ +Add_Attribute + (Package_Name => +"IDE", + Attribute_Name => +"Connection_Tool", + Description => + "Executable used to interface with a " + & "remote target when debugging. GNAT Studio currently supports " + & "OpenOCD, st-util or pyOCD. You can leave this attribute empty " + & "if you are using a custom tool spawned outside of GNAT Studio'.", + Index_Type => PRA.No_Index, + Value => Single, + Value_Case_Sensitive => True); diff --git a/testsuite/tests/unparsing/call_stmt/concatenation/test.yaml b/testsuite/tests/unparsing/call_stmt/concatenation/test.yaml new file mode 100644 index 000000000..7f1d7fdc0 --- /dev/null +++ b/testsuite/tests/unparsing/call_stmt/concatenation/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: stmt +description: | + Test that multiple `ConcatOp`s inside `CallStmt` are correctly indented. diff --git a/testsuite/tests/unparsing/object_decl/long_multi_line_type_expr/input.ada b/testsuite/tests/unparsing/object_decl/long_multi_line_type_expr/input.ada new file mode 100644 index 000000000..c1100368b --- /dev/null +++ b/testsuite/tests/unparsing/object_decl/long_multi_line_type_expr/input.ada @@ -0,0 +1,5 @@ +Foooo : + constant Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar + (Cooooooooooooooooooooooooooooorge) := + Baaaaaaaaaaaaaaaaaaaaaaaaaz; + diff --git a/testsuite/tests/unparsing/object_decl/long_multi_line_type_expr/test.out b/testsuite/tests/unparsing/object_decl/long_multi_line_type_expr/test.out new file mode 100644 index 000000000..3d7c0270a --- /dev/null +++ b/testsuite/tests/unparsing/object_decl/long_multi_line_type_expr/test.out @@ -0,0 +1,4 @@ +Foooo : + constant Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar + (Cooooooooooooooooooooooooooooorge) := + Baaaaaaaaaaaaaaaaaaaaaaaaaz; diff --git a/testsuite/tests/unparsing/object_decl/long_multi_line_type_expr/test.yaml b/testsuite/tests/unparsing/object_decl/long_multi_line_type_expr/test.yaml new file mode 100644 index 000000000..fe4815e75 --- /dev/null +++ b/testsuite/tests/unparsing/object_decl/long_multi_line_type_expr/test.yaml @@ -0,0 +1,7 @@ +driver: unparser +rule: object_decl +description: | + Test that when `f_type_expr` is long, a line break and continuation line + indentation is added after the `:`. + Also test that if `f_type_expr` is multi line, its indentation is relative + to where it starts. diff --git a/testsuite/tests/unparsing/raise_expr/long_error_message_concatenation/input.ada b/testsuite/tests/unparsing/raise_expr/long_error_message_concatenation/input.ada new file mode 100644 index 000000000..8b90ffc12 --- /dev/null +++ b/testsuite/tests/unparsing/raise_expr/long_error_message_concatenation/input.ada @@ -0,0 +1 @@ +raise Some_Exception with "AAAAAAAAAAAAAAAAAAAAAAAA" & "AAAAAAAAAAAAAAAAAAAAAAAA" & "AAAAAAAAAAAAAAAAAAAAAAAA" & "AAAAAAAAAAAAAAAAAAAAAAAA" diff --git a/testsuite/tests/unparsing/raise_expr/long_error_message_concatenation/test.out b/testsuite/tests/unparsing/raise_expr/long_error_message_concatenation/test.out new file mode 100644 index 000000000..d9d8ade21 --- /dev/null +++ b/testsuite/tests/unparsing/raise_expr/long_error_message_concatenation/test.out @@ -0,0 +1,6 @@ +raise Some_Exception + with + "AAAAAAAAAAAAAAAAAAAAAAAA" + & "AAAAAAAAAAAAAAAAAAAAAAAA" + & "AAAAAAAAAAAAAAAAAAAAAAAA" + & "AAAAAAAAAAAAAAAAAAAAAAAA" diff --git a/testsuite/tests/unparsing/raise_expr/long_error_message_concatenation/test.yaml b/testsuite/tests/unparsing/raise_expr/long_error_message_concatenation/test.yaml new file mode 100644 index 000000000..84c341b96 --- /dev/null +++ b/testsuite/tests/unparsing/raise_expr/long_error_message_concatenation/test.yaml @@ -0,0 +1,7 @@ +driver: unparser +rule: raise_expr +description: | + This test checks the formatting of a `RaiseExpr` that has a long + `f_error_message` which consists of concatenations. + It is expected `f_error_message` to be continuation line indented relative to + `with`. diff --git a/testsuite/tests/unparsing/select_stmt/accept_and_guard_delay/input.ada b/testsuite/tests/unparsing/select_stmt/accept_and_guard_delay/input.ada new file mode 100644 index 000000000..91da33b68 --- /dev/null +++ b/testsuite/tests/unparsing/select_stmt/accept_and_guard_delay/input.ada @@ -0,0 +1,6 @@ +select + accept Driver_Awake_Signal; +or + delay 30.0 * Seconds; + Stop_The_Train; +end select; diff --git a/testsuite/tests/unparsing/select_stmt/accept_and_guard_delay/test.out b/testsuite/tests/unparsing/select_stmt/accept_and_guard_delay/test.out new file mode 100644 index 000000000..91da33b68 --- /dev/null +++ b/testsuite/tests/unparsing/select_stmt/accept_and_guard_delay/test.out @@ -0,0 +1,6 @@ +select + accept Driver_Awake_Signal; +or + delay 30.0 * Seconds; + Stop_The_Train; +end select; diff --git a/testsuite/tests/unparsing/select_stmt/accept_and_guard_delay/test.yaml b/testsuite/tests/unparsing/select_stmt/accept_and_guard_delay/test.yaml new file mode 100644 index 000000000..498e8bad2 --- /dev/null +++ b/testsuite/tests/unparsing/select_stmt/accept_and_guard_delay/test.yaml @@ -0,0 +1,7 @@ +driver: unparser +rule: stmt +description: | + Test a `SelectStmt` node with a single element `f_guards` and single line + `AcceptStmt`. + It is expected that the `or` keyword is in its own line with the same + indentation as the `select` keyword. diff --git a/testsuite/tests/unparsing/select_stmt/multi_line_accept_and_guard/input.ada b/testsuite/tests/unparsing/select_stmt/multi_line_accept_and_guard/input.ada new file mode 100644 index 000000000..c5826e5f9 --- /dev/null +++ b/testsuite/tests/unparsing/select_stmt/multi_line_accept_and_guard/input.ada @@ -0,0 +1,24 @@ +select + accept Start + (Data_To_Monitor : Data_To_Monitor_Access; + Directories : GNATCOLL.VFS.File_Array) + do + Data := Data_To_Monitor; + + Monitor := new LSP_Monitor; + Monitor.The_Server := Data_To_Monitor.Server; + + Dirs := new File_Array (1 .. Directories'Length); + Free_Index := 1; + for Dir of Directories loop + if Dir.Is_Directory then + Dirs (Free_Index) := Dir; + Free_Index := Free_Index + 1; + end if; + end loop; + end Start; +or + accept Stop do + Stop_Requested := True; + end Stop; +end select; diff --git a/testsuite/tests/unparsing/select_stmt/multi_line_accept_and_guard/test.out b/testsuite/tests/unparsing/select_stmt/multi_line_accept_and_guard/test.out new file mode 100644 index 000000000..c5826e5f9 --- /dev/null +++ b/testsuite/tests/unparsing/select_stmt/multi_line_accept_and_guard/test.out @@ -0,0 +1,24 @@ +select + accept Start + (Data_To_Monitor : Data_To_Monitor_Access; + Directories : GNATCOLL.VFS.File_Array) + do + Data := Data_To_Monitor; + + Monitor := new LSP_Monitor; + Monitor.The_Server := Data_To_Monitor.Server; + + Dirs := new File_Array (1 .. Directories'Length); + Free_Index := 1; + for Dir of Directories loop + if Dir.Is_Directory then + Dirs (Free_Index) := Dir; + Free_Index := Free_Index + 1; + end if; + end loop; + end Start; +or + accept Stop do + Stop_Requested := True; + end Stop; +end select; diff --git a/testsuite/tests/unparsing/select_stmt/multi_line_accept_and_guard/test.yaml b/testsuite/tests/unparsing/select_stmt/multi_line_accept_and_guard/test.yaml new file mode 100644 index 000000000..46d6871f3 --- /dev/null +++ b/testsuite/tests/unparsing/select_stmt/multi_line_accept_and_guard/test.yaml @@ -0,0 +1,7 @@ +driver: unparser +rule: stmt +description: | + Test a `SelectStmt` node with a single element `f_guards` and multi line + `AcceptStmt`. + It is expected that the `or` keyword is in its own line with the same + indentation as the `select` keyword. diff --git a/testsuite/tests/unparsing/select_stmt/multiple_guards/input.ada b/testsuite/tests/unparsing/select_stmt/multiple_guards/input.ada new file mode 100644 index 000000000..5b6a3afa0 --- /dev/null +++ b/testsuite/tests/unparsing/select_stmt/multiple_guards/input.ada @@ -0,0 +1,17 @@ +task body Server is + Current_Work_Item : Work_Item; +begin + loop + select + accept Next_Work_Item (WI : in Work_Item) do + Current_Work_Item := WI; + end; + Process_Work_Item (Current_Work_Item); + or + accept Shut_Down; + exit; -- Premature shut down requested + or + terminate; -- Normal shutdown at end of scope + end select; + end loop; +end Server; diff --git a/testsuite/tests/unparsing/select_stmt/multiple_guards/test.out b/testsuite/tests/unparsing/select_stmt/multiple_guards/test.out new file mode 100644 index 000000000..5b6a3afa0 --- /dev/null +++ b/testsuite/tests/unparsing/select_stmt/multiple_guards/test.out @@ -0,0 +1,17 @@ +task body Server is + Current_Work_Item : Work_Item; +begin + loop + select + accept Next_Work_Item (WI : in Work_Item) do + Current_Work_Item := WI; + end; + Process_Work_Item (Current_Work_Item); + or + accept Shut_Down; + exit; -- Premature shut down requested + or + terminate; -- Normal shutdown at end of scope + end select; + end loop; +end Server; diff --git a/testsuite/tests/unparsing/select_stmt/multiple_guards/test.yaml b/testsuite/tests/unparsing/select_stmt/multiple_guards/test.yaml new file mode 100644 index 000000000..05dec9e4f --- /dev/null +++ b/testsuite/tests/unparsing/select_stmt/multiple_guards/test.yaml @@ -0,0 +1,6 @@ +driver: unparser +rule: task_body +description: | + Test a `SelectStmt` node with an `f_guards` of multiple guards. + It is expected that the `or` keywords are on their own lines with the same + indentation as the `select` keyword. diff --git a/testsuite/tests/unparsing/select_stmt/with_else/input.ada b/testsuite/tests/unparsing/select_stmt/with_else/input.ada new file mode 100644 index 000000000..516a48bf0 --- /dev/null +++ b/testsuite/tests/unparsing/select_stmt/with_else/input.ada @@ -0,0 +1,12 @@ +procedure Spin (R : in out Resource) is +begin + loop + select + Controller.Request (Medium) (Some_Item); + R.Seize; + return; + else + null; -- busy waiting + end select; + end loop; +end; diff --git a/testsuite/tests/unparsing/select_stmt/with_else/test.out b/testsuite/tests/unparsing/select_stmt/with_else/test.out new file mode 100644 index 000000000..516a48bf0 --- /dev/null +++ b/testsuite/tests/unparsing/select_stmt/with_else/test.out @@ -0,0 +1,12 @@ +procedure Spin (R : in out Resource) is +begin + loop + select + Controller.Request (Medium) (Some_Item); + R.Seize; + return; + else + null; -- busy waiting + end select; + end loop; +end; diff --git a/testsuite/tests/unparsing/select_stmt/with_else/test.yaml b/testsuite/tests/unparsing/select_stmt/with_else/test.yaml new file mode 100644 index 000000000..6cfeb1b7d --- /dev/null +++ b/testsuite/tests/unparsing/select_stmt/with_else/test.yaml @@ -0,0 +1,6 @@ +driver: unparser +rule: subp_body +description: | + Test a `SelectStmt` node with a non null `f_else_stmts`. + It is expected that the `else` keyword is in its own line with the same + indentation as the `select` keyword. diff --git a/testsuite/tests/unparsing/subunit/test.out b/testsuite/tests/unparsing/subunit/test.out index a7d4b73df..90b42a0d1 100644 --- a/testsuite/tests/unparsing/subunit/test.out +++ b/testsuite/tests/unparsing/subunit/test.out @@ -1,4 +1,4 @@ -separate(Parent) +separate (Parent) procedure Inner is begin Foo; diff --git a/testsuite/tests/unparsing/type_def/array_type_def/constrained_array/long_multiple_constraints/input.ada b/testsuite/tests/unparsing/type_def/array_type_def/constrained_array/long_multiple_constraints/input.ada new file mode 100644 index 000000000..d1827ef87 --- /dev/null +++ b/testsuite/tests/unparsing/type_def/array_type_def/constrained_array/long_multiple_constraints/input.ada @@ -0,0 +1,3 @@ +type LCS_Array is + array (Natural range 0 .. Old_Length, Natural range 0 .. New_Length, Natural range 0 .. New_Length) + of Integer; diff --git a/testsuite/tests/unparsing/type_def/array_type_def/constrained_array/long_multiple_constraints/test.out b/testsuite/tests/unparsing/type_def/array_type_def/constrained_array/long_multiple_constraints/test.out new file mode 100644 index 000000000..864776a79 --- /dev/null +++ b/testsuite/tests/unparsing/type_def/array_type_def/constrained_array/long_multiple_constraints/test.out @@ -0,0 +1,5 @@ +type LCS_Array is + array (Natural range 0 .. Old_Length, + Natural range 0 .. New_Length, + Natural range 0 .. New_Length) + of Integer; diff --git a/testsuite/tests/unparsing/type_def/array_type_def/constrained_array/long_multiple_constraints/test.yaml b/testsuite/tests/unparsing/type_def/array_type_def/constrained_array/long_multiple_constraints/test.yaml new file mode 100644 index 000000000..645b84629 --- /dev/null +++ b/testsuite/tests/unparsing/type_def/array_type_def/constrained_array/long_multiple_constraints/test.yaml @@ -0,0 +1,6 @@ +driver: unparser +rule: type_decl +description: | + This test checks the formatting of a constrained array that has multiple + long constraints. It is expected the constraint list to be splitted in + multiple lines.