From a8f1d7e51d0804855101ad964437bb0b1c9613f5 Mon Sep 17 00:00:00 2001 From: Maksim Kurnikov Date: Thu, 27 Jun 2024 11:36:57 +0300 Subject: [PATCH] fix formatting for item spec parameter lists --- .../org/move/ide/formatter/impl/utils.kt | 5 ++-- .../org/move/ide/formatter/FormatterTest.kt | 1 + .../function_parameters.move | 27 +++++++++++++++++++ .../function_parameters_after.move | 27 +++++++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 src/test/resources/org/move/ide/formatter.fixtures/function_parameters.move create mode 100644 src/test/resources/org/move/ide/formatter.fixtures/function_parameters_after.move diff --git a/src/main/kotlin/org/move/ide/formatter/impl/utils.kt b/src/main/kotlin/org/move/ide/formatter/impl/utils.kt index 34a936afc..a35507fdb 100644 --- a/src/main/kotlin/org/move/ide/formatter/impl/utils.kt +++ b/src/main/kotlin/org/move/ide/formatter/impl/utils.kt @@ -21,9 +21,10 @@ val ONE_LINE_ITEMS = ts(USE_STMT, CONST) val PAREN_DELIMITED_BLOCKS = ts( PARENS_EXPR, TUPLE_PAT, TUPLE_TYPE, TUPLE_LIT_EXPR, CONDITION, - FUNCTION_PARAMETER_LIST, VALUE_ARGUMENT_LIST, ATTR_ITEM_LIST + FUNCTION_PARAMETER_LIST, VALUE_ARGUMENT_LIST, ATTR_ITEM_LIST, + ITEM_SPEC_FUNCTION_PARAMETER_LIST ) -val ANGLE_DELIMITED_BLOCKS = ts(TYPE_PARAMETER_LIST, TYPE_ARGUMENT_LIST) +val ANGLE_DELIMITED_BLOCKS = ts(TYPE_PARAMETER_LIST, TYPE_ARGUMENT_LIST, ITEM_SPEC_TYPE_PARAMETER_LIST) val BRACKET_DELIMITED_BLOCKS = ts(VECTOR_LIT_ITEMS) val STRUCT_LITERAL_BLOCKS = ts(STRUCT_PAT_FIELDS_BLOCK, STRUCT_LIT_FIELDS_BLOCK) diff --git a/src/test/kotlin/org/move/ide/formatter/FormatterTest.kt b/src/test/kotlin/org/move/ide/formatter/FormatterTest.kt index 3d641f361..09ee8a418 100644 --- a/src/test/kotlin/org/move/ide/formatter/FormatterTest.kt +++ b/src/test/kotlin/org/move/ide/formatter/FormatterTest.kt @@ -8,6 +8,7 @@ class FormatterTest : MvFormatterTestBase() { fun `test address block`() = doTest() fun `test operators`() = doTest() fun `test functions`() = doTest() + fun `test function parameters`() = doTest() fun `test specs`() = doTest() fun `test structs`() = doTest() fun `test inner block`() = doTest() diff --git a/src/test/resources/org/move/ide/formatter.fixtures/function_parameters.move b/src/test/resources/org/move/ide/formatter.fixtures/function_parameters.move new file mode 100644 index 000000000..4e3b911d0 --- /dev/null +++ b/src/test/resources/org/move/ide/formatter.fixtures/function_parameters.move @@ -0,0 +1,27 @@ +module 0x1::function_parameters { + fun prologue( + a: u8, + b: u8, + c: u8, + ): u8 {} + + spec prologue( + a: u8, + b: u8, + c: u8, + ): u8 {} + + spec fun prologue( + a: u8, + b: u8, + c: u8, + ): u8 {} + + spec module { + fun prologue( + a: u8, + b: u8, + c: u8, + ): u8 {} + } +} diff --git a/src/test/resources/org/move/ide/formatter.fixtures/function_parameters_after.move b/src/test/resources/org/move/ide/formatter.fixtures/function_parameters_after.move new file mode 100644 index 000000000..f2015123e --- /dev/null +++ b/src/test/resources/org/move/ide/formatter.fixtures/function_parameters_after.move @@ -0,0 +1,27 @@ +module 0x1::function_parameters { + fun prologue( + a: u8, + b: u8, + c: u8, + ): u8 {} + + spec prologue( + a: u8, + b: u8, + c: u8, + ): u8 {} + + spec fun prologue( + a: u8, + b: u8, + c: u8, + ): u8 {} + + spec module { + fun prologue( + a: u8, + b: u8, + c: u8, + ): u8 {} + } +}