1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 14:21:31 +03:00

Track changes to ruby rescue productions

This commit is contained in:
Timothy Clem 2016-11-09 10:48:22 -08:00
parent 8d0297d89f
commit 8d9e864b0a
4 changed files with 10 additions and 5 deletions

View File

@ -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
]

View File

@ -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

View File

@ -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

View File

@ -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.