diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index 9cb0818a9..0b57a6a49 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -1,6 +1,6 @@ { "node_configs": { - "ArrayTypeDef":{ + "ArrayTypeDef": { "node": { "kind": "group", "document": [ @@ -25,7 +25,7 @@ { "kind": "text", "text": "of" - }, + }, { "kind": "recurse_field", "field": "f_component_type" @@ -188,39 +188,39 @@ ] } }, - "ComponentDef":{ - "node":{ + "ComponentDef": { + "node": { "kind": "align", "width": 2, "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": "recurse_field", + "field": "f_has_aliased" + }, + { + "kind": "recurse_field", + "field": "f_has_constant" + }, + { + "kind": "recurse_field", + "field": "f_type_expr" + } ] } } }, - "ConstrainedArrayIndices":{ - "node":{ + "ConstrainedArrayIndices": { + "node": { "kind": "align", "width": 1, "contents": { "kind": "group", - "document": [ + "document": [ { - "kind" : "innerRoot", - "contents" : { + "kind": "innerRoot", + "contents": { "kind": "recurse_field", "field": "f_list" } @@ -229,52 +229,55 @@ } } }, - "ConstraintList":{ - "sep":["recurse", "line"] + "ConstraintList": { + "sep": [ + "recurse", + "line" + ] }, - "ConcreteTypeDecl":{ - "node":{ + "ConcreteTypeDecl": { + "node": { "kind": "align", "width": 2, "contents": { "kind": "group", "document": [ - { - "kind": "text", - "text": "type" - }, - "whitespace", - { - "kind": "recurse_field", - "field": "f_name" - }, - { - "kind": "recurse_field", - "field": "f_discriminants" - }, - "whitespace", - { - "kind": "text", - "text": "is" - }, - "line", - { - "kind": "recurse_field", - "field": "f_type_def" - }, - { - "kind": "recurse_field", - "field": "f_aspects" - }, - { - "kind": "text", - "text": ";" - } + { + "kind": "text", + "text": "type" + }, + "whitespace", + { + "kind": "recurse_field", + "field": "f_name" + }, + { + "kind": "recurse_field", + "field": "f_discriminants" + }, + "whitespace", + { + "kind": "text", + "text": "is" + }, + "line", + { + "kind": "recurse_field", + "field": "f_type_def" + }, + { + "kind": "recurse_field", + "field": "f_aspects" + }, + { + "kind": "text", + "text": ";" + } ] } } }, - "DecimalFixedPointDef":{ + "DecimalFixedPointDef": { "node": { "kind": "group", "document": [ @@ -299,20 +302,26 @@ }, { "kind": "recurse_field", - "field": "f_range" + "field": "f_range" } ] }, "fields": { "f_range": [ - "line", - { - "kind": "innerRoot", - "contents": "recurse" - } + "line", + { + "kind": "innerRoot", + "contents": "recurse" + } ] } }, + "DefiningNameList": { + "sep": [ + "recurse", + "line" + ] + }, "DottedName": { "node": { "kind": "innerRoot", @@ -329,35 +338,40 @@ "f_prefix": [ { "kind": "recurse_flatten", - "if": ["DottedName"] + "if": [ + "DottedName" + ] }, "softline" ] } }, - "EnumLiteralDeclList":{ - "sep":["recurse", "line"] + "EnumLiteralDeclList": { + "sep": [ + "recurse", + "line" + ] }, - "EnumTypeDef":{ + "EnumTypeDef": { "node": { "kind": "group", "document": [ { "kind": "text", "text": "(" - }, - { - "kind": "align", - "width": 1, - "contents" : { - "kind": "recurse_field", - "field": "f_enum_literals" - } - }, - { - "kind": "text", - "text": ")" - } + }, + { + "kind": "align", + "width": 1, + "contents": { + "kind": "recurse_field", + "field": "f_enum_literals" + } + }, + { + "kind": "text", + "text": ")" + } ] } }, @@ -411,7 +425,7 @@ "hardlineWithoutBreakParent" ] }, - "FloatingPointDef":{ + "FloatingPointDef": { "node": { "kind": "group", "document": [ @@ -518,10 +532,45 @@ ] } }, - "NameList":{ - "sep":["recurse", "line"] + "NameList": { + "sep": [ + "recurse", + "line" + ] + }, + "ModeIn": { + "node": [ + { + "kind": "text", + "text": "in" + }, + "whitespace" + ] + }, + "ModeInOut": { + "node": [ + { + "kind": "text", + "text": "in" + }, + "whitespace", + { + "kind": "text", + "text": "out" + }, + "whitespace" + ] + }, + "ModeOut": { + "node": [ + { + "kind": "text", + "text": "out" + }, + "whitespace" + ] }, - "OrdinaryFixedPointDef":{ + "OrdinaryFixedPointDef": { "node": { "kind": "group", "document": [ @@ -536,8 +585,8 @@ }, "line", { - "kind" : "innerRoot", - "contents" : { + "kind": "innerRoot", + "contents": { "kind": "recurse_field", "field": "f_range" } @@ -706,6 +755,136 @@ ] } }, + "Params": { + "node": { + "kind": "group", + "document": { + "kind": "align", + "width": 1, + "contents": [ + { + "kind": "text", + "text": "(" + }, + { + "kind": "innerRoot", + "contents": { + "kind": "recurse_field", + "field": "f_params" + } + }, + { + "kind": "text", + "text": ")" + } + ] + } + } + }, + "ParamSpec": { + "node": { + "kind": "group", + "document": [ + { + "kind": "group", + "document": [ + { + "kind": "group", + "document": { + "kind": "recurse_field", + "field": "f_ids" + } + }, + "whitespace", + { + "kind": "text", + "text": ":" + }, + { + "kind": "align", + "width": 2, + "contents": [ + "line", + { + "kind": "group", + "document": [ + { + "kind": "recurse_field", + "field": "f_has_aliased" + }, + { + "kind": "recurse_field", + "field": "f_mode" + }, + { + "kind": "recurse_field", + "field": "f_type_expr" + } + ] + } + ] + } + ], + "id": "name_and_type" + }, + { + "kind": "ifBreak", + "breakContents": { + "kind": "align", + "width": 4, + "contents": { + "kind": "group", + "document": [ + { + "kind": "recurse_field", + "field": "f_default_expr" + }, + { + "kind": "recurse_field", + "field": "f_aspects" + } + ] + } + }, + "flatContents": { + "kind": "align", + "width": 2, + "contents": { + "kind": "group", + "document": [ + { + "kind": "recurse_field", + "field": "f_default_expr" + }, + { + "kind": "recurse_field", + "field": "f_aspects" + } + ] + } + }, + "groupId": "name_and_type" + } + ] + }, + "fields": { + "f_default_expr": [ + "whitespace", + { + "kind": "text", + "text": ":=" + }, + "line", + "recurse" + ] + } + }, + "ParamSpecList": { + "sep": [ + "recurse", + "line" + ] + }, "ParenExpr": { "node": { "kind": "align", @@ -716,7 +895,7 @@ } } }, - "RangeSpec":{ + "RangeSpec": { "node": { "kind": "align", "width": 2, @@ -755,22 +934,22 @@ ] } }, - "SignedIntTypeDef":{ + "SignedIntTypeDef": { "node": { "kind": "recurse_field", "field": "f_range" } }, - "UnconstrainedArrayIndices":{ - "node":{ + "UnconstrainedArrayIndices": { + "node": { "kind": "align", "width": 1, "contents": { "kind": "group", - "document": [ + "document": [ { - "kind" : "innerRoot", - "contents" : { + "kind": "innerRoot", + "contents": { "kind": "recurse_field", "field": "f_types" } @@ -779,10 +958,13 @@ } } }, - "UnconstrainedArrayIndexList":{ - "sep":["recurse", "line"] + "UnconstrainedArrayIndexList": { + "sep": [ + "recurse", + "line" + ] }, - "UnconstrainedArrayIndex":{ + "UnconstrainedArrayIndex": { "node": { "kind": "group", "document": [ @@ -796,18 +978,21 @@ "text": "range" }, { - "kind": "recurse_field", - "field": "f_lower_bound" + "kind": "recurse_field", + "field": "f_lower_bound" }, "whitespace", { - "kind": "text", - "text": "<>" + "kind": "text", + "text": "<>" } ] }, "fields": { - "f_lower_bound": ["whitespace", "recurse"] + "f_lower_bound": [ + "whitespace", + "recurse" + ] } }, "UsePackageClause": { diff --git a/testsuite/tests/unparsing/param_spec/everything_long/doc-baseline.json b/testsuite/tests/unparsing/param_spec/everything_long/doc-baseline.json new file mode 100644 index 000000000..edb315289 --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/everything_long/doc-baseline.json @@ -0,0 +1,202 @@ +{ + "id": 25, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 24, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 9, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 0, + "kind": "text", + "text": "Fooooooooooooooooo" + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 2, + "kind": "text", + "text": " :" + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "text", + "text": "aliased in out not null access Baaaaaaaaaaaaaaaaaaaaaaar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 23, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 22, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 4 + }, + "alignContents": { + "id": 21, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 20, + "kind": "list", + "list": [ + { + "id": 17, + "kind": "text", + "text": " :=" + }, + { + "id": 18, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 19, + "kind": "text", + "text": "Baaaaaaaaaaaaaaaaz" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + "flatContents": { + "id": 16, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 15, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 14, + "kind": "list", + "list": [ + { + "id": 11, + "kind": "text", + "text": " :=" + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 13, + "kind": "text", + "text": "Baaaaaaaaaaaaaaaaz" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/param_spec/everything_long/input.ada b/testsuite/tests/unparsing/param_spec/everything_long/input.ada new file mode 100644 index 000000000..0a0750d11 --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/everything_long/input.ada @@ -0,0 +1 @@ +Fooooooooooooooooo : aliased in out not null access Baaaaaaaaaaaaaaaaaaaaaaar := Baaaaaaaaaaaaaaaaz diff --git a/testsuite/tests/unparsing/param_spec/everything_long/test.out b/testsuite/tests/unparsing/param_spec/everything_long/test.out new file mode 100644 index 000000000..55f082696 --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/everything_long/test.out @@ -0,0 +1,3 @@ +Fooooooooooooooooo : + aliased in out not null access Baaaaaaaaaaaaaaaaaaaaaaar := + Baaaaaaaaaaaaaaaaz diff --git a/testsuite/tests/unparsing/param_spec/everything_long/test.yaml b/testsuite/tests/unparsing/param_spec/everything_long/test.yaml new file mode 100644 index 000000000..4772630f4 --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/everything_long/test.yaml @@ -0,0 +1,6 @@ +driver: unparser +rule: param_spec +description: | + Test that when everything is long (ids, type expression and default + expression), line breaks and continuam line indentation are added after the + `:` and `:=`. diff --git a/testsuite/tests/unparsing/param_spec/long_default_expr/doc-baseline.json b/testsuite/tests/unparsing/param_spec/long_default_expr/doc-baseline.json new file mode 100644 index 000000000..581a4c092 --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/long_default_expr/doc-baseline.json @@ -0,0 +1,202 @@ +{ + "id": 25, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 24, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 9, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 0, + "kind": "text", + "text": "Foo" + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 2, + "kind": "text", + "text": " :" + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "text", + "text": "Bar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 23, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 22, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 4 + }, + "alignContents": { + "id": 21, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 20, + "kind": "list", + "list": [ + { + "id": 17, + "kind": "text", + "text": " :=" + }, + { + "id": 18, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 19, + "kind": "text", + "text": "Bazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + "flatContents": { + "id": 16, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 15, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 14, + "kind": "list", + "list": [ + { + "id": 11, + "kind": "text", + "text": " :=" + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 13, + "kind": "text", + "text": "Bazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/param_spec/long_default_expr/input.ada b/testsuite/tests/unparsing/param_spec/long_default_expr/input.ada new file mode 100644 index 000000000..e7842c56b --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/long_default_expr/input.ada @@ -0,0 +1 @@ +Foo : Bar := Bazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz diff --git a/testsuite/tests/unparsing/param_spec/long_default_expr/test.out b/testsuite/tests/unparsing/param_spec/long_default_expr/test.out new file mode 100644 index 000000000..600389530 --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/long_default_expr/test.out @@ -0,0 +1,2 @@ +Foo : Bar := + Bazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz diff --git a/testsuite/tests/unparsing/param_spec/long_default_expr/test.yaml b/testsuite/tests/unparsing/param_spec/long_default_expr/test.yaml new file mode 100644 index 000000000..09b57a04f --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/long_default_expr/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: param_spec +description: | + Test that when the default expression is long, a line break and continuation + line indentation is added after the `:=`. diff --git a/testsuite/tests/unparsing/param_spec/long_ids/doc-baseline.json b/testsuite/tests/unparsing/param_spec/long_ids/doc-baseline.json new file mode 100644 index 000000000..6a92fdbf5 --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/long_ids/doc-baseline.json @@ -0,0 +1,202 @@ +{ + "id": 25, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 24, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 9, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 0, + "kind": "text", + "text": "Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 2, + "kind": "text", + "text": " :" + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "text", + "text": "Bar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 23, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 22, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 4 + }, + "alignContents": { + "id": 21, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 20, + "kind": "list", + "list": [ + { + "id": 17, + "kind": "text", + "text": " :=" + }, + { + "id": 18, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 19, + "kind": "text", + "text": "Baz" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + "flatContents": { + "id": 16, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 15, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 14, + "kind": "list", + "list": [ + { + "id": 11, + "kind": "text", + "text": " :=" + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 13, + "kind": "text", + "text": "Baz" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/param_spec/long_ids/input.ada b/testsuite/tests/unparsing/param_spec/long_ids/input.ada new file mode 100644 index 000000000..c7cb3fa1e --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/long_ids/input.ada @@ -0,0 +1 @@ +Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo : Bar := Baz diff --git a/testsuite/tests/unparsing/param_spec/long_ids/test.out b/testsuite/tests/unparsing/param_spec/long_ids/test.out new file mode 100644 index 000000000..852c7fb60 --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/long_ids/test.out @@ -0,0 +1,2 @@ +Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo : + Bar := Baz diff --git a/testsuite/tests/unparsing/param_spec/long_ids/test.yaml b/testsuite/tests/unparsing/param_spec/long_ids/test.yaml new file mode 100644 index 000000000..5e914de9a --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/long_ids/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: param_spec +description: | + Test that when the parameters identifiers list is long, a line break and + continuation line indentation is added after the `:`. diff --git a/testsuite/tests/unparsing/param_spec/long_type_expr/doc-baseline.json b/testsuite/tests/unparsing/param_spec/long_type_expr/doc-baseline.json new file mode 100644 index 000000000..059428d0a --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/long_type_expr/doc-baseline.json @@ -0,0 +1,202 @@ +{ + "id": 25, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 24, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 9, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 0, + "kind": "text", + "text": "Fooo" + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 2, + "kind": "text", + "text": " :" + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "text", + "text": "Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 23, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 22, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 4 + }, + "alignContents": { + "id": 21, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 20, + "kind": "list", + "list": [ + { + "id": 17, + "kind": "text", + "text": " :=" + }, + { + "id": 18, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 19, + "kind": "text", + "text": "Baz" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + "flatContents": { + "id": 16, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 15, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 14, + "kind": "list", + "list": [ + { + "id": 11, + "kind": "text", + "text": " :=" + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 13, + "kind": "text", + "text": "Baz" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/param_spec/long_type_expr/input.ada b/testsuite/tests/unparsing/param_spec/long_type_expr/input.ada new file mode 100644 index 000000000..81491c516 --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/long_type_expr/input.ada @@ -0,0 +1 @@ +Fooo : Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar := Baz diff --git a/testsuite/tests/unparsing/param_spec/long_type_expr/test.out b/testsuite/tests/unparsing/param_spec/long_type_expr/test.out new file mode 100644 index 000000000..de5004187 --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/long_type_expr/test.out @@ -0,0 +1,2 @@ +Fooo : + Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar := Baz diff --git a/testsuite/tests/unparsing/param_spec/long_type_expr/test.yaml b/testsuite/tests/unparsing/param_spec/long_type_expr/test.yaml new file mode 100644 index 000000000..b0b6f2b97 --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/long_type_expr/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: param_spec +description: | + Test that when the type expression is long, a line break and continuation + line indentation is added after the `:`. diff --git a/testsuite/tests/unparsing/param_spec/short/doc-baseline.json b/testsuite/tests/unparsing/param_spec/short/doc-baseline.json new file mode 100644 index 000000000..fb7613666 --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/short/doc-baseline.json @@ -0,0 +1,162 @@ +{ + "id": 19, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 18, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 9, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 0, + "kind": "text", + "text": "Foo" + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 2, + "kind": "text", + "text": " :" + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "text", + "text": "Bar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 17, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 16, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 4 + }, + "alignContents": { + "id": 15, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 14, + "kind": "list", + "list": [ + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + "flatContents": { + "id": 13, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 12, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 11, + "kind": "list", + "list": [ + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/param_spec/short/input.ada b/testsuite/tests/unparsing/param_spec/short/input.ada new file mode 100644 index 000000000..effd1bca6 --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/short/input.ada @@ -0,0 +1 @@ +Foo:Bar diff --git a/testsuite/tests/unparsing/param_spec/short/test.out b/testsuite/tests/unparsing/param_spec/short/test.out new file mode 100644 index 000000000..a92f56a64 --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/short/test.out @@ -0,0 +1 @@ +Foo : Bar diff --git a/testsuite/tests/unparsing/param_spec/short/test.yaml b/testsuite/tests/unparsing/param_spec/short/test.yaml new file mode 100644 index 000000000..bd4676c96 --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/short/test.yaml @@ -0,0 +1,4 @@ +driver: unparser +rule: param_spec +description: | + Base test case for a short `ParamSpec`. diff --git a/testsuite/tests/unparsing/param_spec/short_full/doc-baseline.json b/testsuite/tests/unparsing/param_spec/short_full/doc-baseline.json new file mode 100644 index 000000000..a64feeec5 --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/short_full/doc-baseline.json @@ -0,0 +1,202 @@ +{ + "id": 25, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 24, + "kind": "list", + "list": [ + { + "id": 10, + "kind": "command", + "command": { + "command": "group", + "id": 1, + "groupContents": { + "id": 9, + "kind": "list", + "list": [ + { + "id": 1, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 0, + "kind": "text", + "text": "Foo" + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 2, + "kind": "text", + "text": " :" + }, + { + "id": 8, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 7, + "kind": "list", + "list": [ + { + "id": 3, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 6, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 5, + "kind": "list", + "list": [ + { + "id": 4, + "kind": "text", + "text": "Bar" + } + ] + }, + "break": false, + "expandedStates": null + } + } + ] + } + } + } + ] + }, + "break": false, + "expandedStates": null + } + }, + { + "id": 23, + "kind": "command", + "command": { + "command": "ifBreak", + "ifBreakGroupId": 1, + "breakContents": { + "id": 22, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 4 + }, + "alignContents": { + "id": 21, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 20, + "kind": "list", + "list": [ + { + "id": 17, + "kind": "text", + "text": " :=" + }, + { + "id": 18, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 19, + "kind": "text", + "text": "Baz" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + }, + "flatContents": { + "id": 16, + "kind": "command", + "command": { + "command": "align", + "alignData": { + "kind": "width", + "n": 2 + }, + "alignContents": { + "id": 15, + "kind": "command", + "command": { + "command": "group", + "id": 0, + "groupContents": { + "id": 14, + "kind": "list", + "list": [ + { + "id": 11, + "kind": "text", + "text": " :=" + }, + { + "id": 12, + "kind": "command", + "command": { + "command": "line", + "literal": false, + "soft": false, + "hard": false + } + }, + { + "id": 13, + "kind": "text", + "text": "Baz" + } + ] + }, + "break": false, + "expandedStates": null + } + } + } + } + } + } + ] + }, + "break": false, + "expandedStates": null + } +} diff --git a/testsuite/tests/unparsing/param_spec/short_full/input.ada b/testsuite/tests/unparsing/param_spec/short_full/input.ada new file mode 100644 index 000000000..7a732555b --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/short_full/input.ada @@ -0,0 +1 @@ +Foo:Bar:=Baz diff --git a/testsuite/tests/unparsing/param_spec/short_full/test.out b/testsuite/tests/unparsing/param_spec/short_full/test.out new file mode 100644 index 000000000..07d6ea14e --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/short_full/test.out @@ -0,0 +1 @@ +Foo : Bar := Baz diff --git a/testsuite/tests/unparsing/param_spec/short_full/test.yaml b/testsuite/tests/unparsing/param_spec/short_full/test.yaml new file mode 100644 index 000000000..f05a7feb8 --- /dev/null +++ b/testsuite/tests/unparsing/param_spec/short_full/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: param_spec +description: | + Base test case for a short full (name + type + default expression) + `ParamSpec`.