diff --git a/src/Category.hs b/src/Category.hs index a63f9a544..999706a55 100644 --- a/src/Category.hs +++ b/src/Category.hs @@ -132,8 +132,9 @@ data Category | Ensure | Rescue | RescueModifier - | When | RescuedException + | RescueArgs + | When | Negate deriving (Eq, Generic, Ord, Show) @@ -201,8 +202,9 @@ instance Arbitrary Category where , pure Ensure , pure Rescue , pure RescueModifier - , pure When , pure RescuedException + , pure RescueArgs + , pure When , pure Negate , Other <$> arbitrary ] diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index c14fd613e..2fbe5f28c 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -388,6 +388,7 @@ instance HasCategory Category where C.RescueModifier -> "rescue modifier" C.When -> "when comparison" C.RescuedException -> "last exception" + C.RescueArgs -> "arguments" C.Negate -> "negate" instance HasField fields Category => HasCategory (SyntaxTerm leaf fields) where diff --git a/src/Language/Ruby.hs b/src/Language/Ruby.hs index 3a58f17fd..b2406dae4 100644 --- a/src/Language/Ruby.hs +++ b/src/Language/Ruby.hs @@ -102,10 +102,10 @@ termConstructor source sourceSpan name range children ("module_declaration", _ ) -> S.Error children ("rescue_block", _ ) -> case children of args : lastException : rest - | Args <- category (extract args) + | RescueArgs <- category (extract args) , RescuedException <- category (extract lastException) -> S.Rescue (toList (unwrap args) <> [lastException]) rest lastException : rest | RescuedException <- category (extract lastException) -> S.Rescue [lastException] rest - args : body | Args <- category (extract args) -> S.Rescue (toList (unwrap args)) body + args : body | RescueArgs <- category (extract args) -> S.Rescue (toList (unwrap args)) body body -> S.Rescue [] body ("rescue_modifier", [lhs, rhs] ) -> S.Rescue [lhs] [rhs] ("rescue_modifier", _ ) -> S.Error children @@ -165,7 +165,6 @@ categoryForRubyName = \case "if_statement" -> If "integer" -> IntegerLiteral "interpolation" -> Interpolation - "rescued_exception" -> RescuedException "math_assignment" -> MathAssignment "member_access" -> MemberAccess "method_declaration" -> Method @@ -175,8 +174,10 @@ categoryForRubyName = \case "program" -> Program "regex" -> Regex "relational" -> RelationalOperator -- relational operator, e.g. ==, !=, ===, <=>, =~, !~. + "rescue_arguments" -> RescueArgs "rescue_block" -> Rescue "rescue_modifier" -> RescueModifier + "rescued_exception" -> RescuedException "return_statement" -> Return "shift" -> BitwiseOperator -- bitwise shift, e.g <<, >>. "string" -> StringLiteral diff --git a/src/Renderer/Split.hs b/src/Renderer/Split.hs index 3bc86c1c0..c4fc7bf9d 100644 --- a/src/Renderer/Split.hs +++ b/src/Renderer/Split.hs @@ -97,6 +97,7 @@ styleName category = "category-" <> case category of C.RescueModifier -> "rescue_modifier" C.When -> "when_block" C.RescuedException -> "last_exception" + C.RescueArgs -> "rescue_args" C.Negate -> "negate" -- | Pick the class name for a split patch.