From 21fbaa5f1c7bd8ebf7eae189994fec3efaddf4f5 Mon Sep 17 00:00:00 2001 From: Joao Azevedo Date: Thu, 1 Aug 2024 10:21:57 +0000 Subject: [PATCH] Improve TypeAccessDef on SubpSpec nodes --- extensions/default_unparsing_config.json | 10 ++++++++-- .../access_type/long_not_null_access/input.ada | 5 +++++ .../access_type/long_not_null_access/test.out | 6 ++++++ .../access_type/long_not_null_access/test.yaml | 6 ++++++ .../access_type/not_null_access/input.ada | 1 - .../access_type/not_null_access/test.out | 1 - .../access_type/not_null_access/test.yaml | 7 ------- .../access_type/short_not_null_access/input.ada | 6 ++++++ .../access_type/short_not_null_access/test.out | 5 +++++ .../access_type/short_not_null_access/test.yaml | 5 +++++ .../type_access_def/long_subtype_indication/test.out | 3 ++- .../long_subtype_indication/test.yaml | 12 ++++++------ 12 files changed, 49 insertions(+), 18 deletions(-) create mode 100644 testsuite/tests/unparsing/anonymous_type_decl/access_type/long_not_null_access/input.ada create mode 100644 testsuite/tests/unparsing/anonymous_type_decl/access_type/long_not_null_access/test.out create mode 100644 testsuite/tests/unparsing/anonymous_type_decl/access_type/long_not_null_access/test.yaml delete mode 100644 testsuite/tests/unparsing/anonymous_type_decl/access_type/not_null_access/input.ada delete mode 100644 testsuite/tests/unparsing/anonymous_type_decl/access_type/not_null_access/test.out delete mode 100644 testsuite/tests/unparsing/anonymous_type_decl/access_type/not_null_access/test.yaml create mode 100644 testsuite/tests/unparsing/anonymous_type_decl/access_type/short_not_null_access/input.ada create mode 100644 testsuite/tests/unparsing/anonymous_type_decl/access_type/short_not_null_access/test.out create mode 100644 testsuite/tests/unparsing/anonymous_type_decl/access_type/short_not_null_access/test.yaml diff --git a/extensions/default_unparsing_config.json b/extensions/default_unparsing_config.json index 73a5bc690..fcdd5dddc 100644 --- a/extensions/default_unparsing_config.json +++ b/extensions/default_unparsing_config.json @@ -5833,8 +5833,14 @@ "field": "f_has_constant" }, { - "kind": "recurse_field", - "field": "f_subtype_indication" + "kind": "continuationLineIndent", + "contents": [ + "line", + { + "kind": "recurse_field", + "field": "f_subtype_indication" + } + ] } ] } diff --git a/testsuite/tests/unparsing/anonymous_type_decl/access_type/long_not_null_access/input.ada b/testsuite/tests/unparsing/anonymous_type_decl/access_type/long_not_null_access/input.ada new file mode 100644 index 000000000..4af6189f2 --- /dev/null +++ b/testsuite/tests/unparsing/anonymous_type_decl/access_type/long_not_null_access/input.ada @@ -0,0 +1,5 @@ +procedure Initialize + (Self : in out Default_Message_Handler'Class; + Handler : + not null access LSP.Server_Message_Visitors.Server_Message_Visitor'Classss; + Priority : LSP.Server_Jobs.Job_Priority := LSP.Server_Jobs.Fence); diff --git a/testsuite/tests/unparsing/anonymous_type_decl/access_type/long_not_null_access/test.out b/testsuite/tests/unparsing/anonymous_type_decl/access_type/long_not_null_access/test.out new file mode 100644 index 000000000..425957686 --- /dev/null +++ b/testsuite/tests/unparsing/anonymous_type_decl/access_type/long_not_null_access/test.out @@ -0,0 +1,6 @@ +procedure Initialize + (Self : in out Default_Message_Handler'Class; + Handler : + not null access + LSP.Server_Message_Visitors.Server_Message_Visitor'Classss; + Priority : LSP.Server_Jobs.Job_Priority := LSP.Server_Jobs.Fence); diff --git a/testsuite/tests/unparsing/anonymous_type_decl/access_type/long_not_null_access/test.yaml b/testsuite/tests/unparsing/anonymous_type_decl/access_type/long_not_null_access/test.yaml new file mode 100644 index 000000000..d8c810364 --- /dev/null +++ b/testsuite/tests/unparsing/anonymous_type_decl/access_type/long_not_null_access/test.yaml @@ -0,0 +1,6 @@ +driver: unparser +rule: subp_decl +description: | + This test checks the formatting of a long not null anonymous access type + declaration. It is expected a line break after the `access` token and that + `f_subtype_indication` is continuation line indented. diff --git a/testsuite/tests/unparsing/anonymous_type_decl/access_type/not_null_access/input.ada b/testsuite/tests/unparsing/anonymous_type_decl/access_type/not_null_access/input.ada deleted file mode 100644 index c85ef6365..000000000 --- a/testsuite/tests/unparsing/anonymous_type_decl/access_type/not_null_access/input.ada +++ /dev/null @@ -1 +0,0 @@ -not null access Bbbbbbbbbbbbbbb diff --git a/testsuite/tests/unparsing/anonymous_type_decl/access_type/not_null_access/test.out b/testsuite/tests/unparsing/anonymous_type_decl/access_type/not_null_access/test.out deleted file mode 100644 index c85ef6365..000000000 --- a/testsuite/tests/unparsing/anonymous_type_decl/access_type/not_null_access/test.out +++ /dev/null @@ -1 +0,0 @@ -not null access Bbbbbbbbbbbbbbb diff --git a/testsuite/tests/unparsing/anonymous_type_decl/access_type/not_null_access/test.yaml b/testsuite/tests/unparsing/anonymous_type_decl/access_type/not_null_access/test.yaml deleted file mode 100644 index 7e0c26842..000000000 --- a/testsuite/tests/unparsing/anonymous_type_decl/access_type/not_null_access/test.yaml +++ /dev/null @@ -1,7 +0,0 @@ -description: | - This test checks the formatting of a simple not null - anonymous access type declaration. - It is expected the declaration stays on a single line. - -driver: unparser -rule: anonymous_type_decl diff --git a/testsuite/tests/unparsing/anonymous_type_decl/access_type/short_not_null_access/input.ada b/testsuite/tests/unparsing/anonymous_type_decl/access_type/short_not_null_access/input.ada new file mode 100644 index 000000000..a45e0b59d --- /dev/null +++ b/testsuite/tests/unparsing/anonymous_type_decl/access_type/short_not_null_access/input.ada @@ -0,0 +1,6 @@ +procedure Initialize + (Self : in out Default_Message_Handler'Class; + Handler : + not null access LSP.Server_Message_Visitors.Server_Message_Visitor'Class; + Priority : LSP.Server_Jobs.Job_Priority := LSP.Server_Jobs.Fence); + diff --git a/testsuite/tests/unparsing/anonymous_type_decl/access_type/short_not_null_access/test.out b/testsuite/tests/unparsing/anonymous_type_decl/access_type/short_not_null_access/test.out new file mode 100644 index 000000000..7b392e04e --- /dev/null +++ b/testsuite/tests/unparsing/anonymous_type_decl/access_type/short_not_null_access/test.out @@ -0,0 +1,5 @@ +procedure Initialize + (Self : in out Default_Message_Handler'Class; + Handler : + not null access LSP.Server_Message_Visitors.Server_Message_Visitor'Class; + Priority : LSP.Server_Jobs.Job_Priority := LSP.Server_Jobs.Fence); diff --git a/testsuite/tests/unparsing/anonymous_type_decl/access_type/short_not_null_access/test.yaml b/testsuite/tests/unparsing/anonymous_type_decl/access_type/short_not_null_access/test.yaml new file mode 100644 index 000000000..40c65b199 --- /dev/null +++ b/testsuite/tests/unparsing/anonymous_type_decl/access_type/short_not_null_access/test.yaml @@ -0,0 +1,5 @@ +driver: unparser +rule: subp_decl +description: | + This test checks the formatting of a simple not null anonymous access type + declaration. It is expected the declaration stays on a single line. diff --git a/testsuite/tests/unparsing/type_def/type_access_def/long_subtype_indication/test.out b/testsuite/tests/unparsing/type_def/type_access_def/long_subtype_indication/test.out index 00eceb746..c7f691611 100644 --- a/testsuite/tests/unparsing/type_def/type_access_def/long_subtype_indication/test.out +++ b/testsuite/tests/unparsing/type_def/type_access_def/long_subtype_indication/test.out @@ -1,2 +1,3 @@ type Aaaaaaaa is - access BBBBBBBBBBBbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; + access + BBBBBBBBBBBbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; diff --git a/testsuite/tests/unparsing/type_def/type_access_def/long_subtype_indication/test.yaml b/testsuite/tests/unparsing/type_def/type_access_def/long_subtype_indication/test.yaml index 9e7675bf5..54078c7c8 100644 --- a/testsuite/tests/unparsing/type_def/type_access_def/long_subtype_indication/test.yaml +++ b/testsuite/tests/unparsing/type_def/type_access_def/long_subtype_indication/test.yaml @@ -1,8 +1,8 @@ -description: | - This test checks the formatting of a simple access type declaration - having a long subtype indication. - It is expected the declaration be splitted after `is` keyword and - the new line be indented with a line continuation indentation. - driver: unparser rule: type_decl +description: | + This test checks the formatting of a simple access type declaration having a + long subtype indication. It is expected the declaration be splitted after + `is` keyword and the new line be indented with a line continuation + indentation. It is also expected a line break before `f_subtype_indication` + and for it to also be continuation line indented.