From 437522f5e189e2e514a79e9b991b51462a09004e Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Fri, 4 Nov 2016 13:05:28 -0700 Subject: [PATCH] Remove need for Params syntax --- src/DiffSummary.hs | 1 - src/Language/Ruby.hs | 9 +++------ src/Renderer/JSON.hs | 1 - src/Syntax.hs | 2 -- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index f7652f98a..22861dea9 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -244,7 +244,6 @@ toTermName source term = case unwrap term of Just expr -> termNameFromSource expr Nothing -> fromMaybe "branch" $ (toCategoryName . category) . extract <$> head children S.Rescue args _ -> intercalate ", " $ toTermName' <$> args - S.Params args -> mconcat $ toTermName' <$> args where toTermName' = toTermName source termNameFromChildren term children = termNameFromRange (unionRangesFrom (range term) (range <$> children)) termNameFromSource term = termNameFromRange (range term) diff --git a/src/Language/Ruby.hs b/src/Language/Ruby.hs index ee397346b..533fcc642 100644 --- a/src/Language/Ruby.hs +++ b/src/Language/Ruby.hs @@ -43,7 +43,6 @@ termConstructor source sourceSpan name range children ("conditional_assignment", _ ) -> S.Error children ("conditional", condition : cases) -> S.Ternary condition cases ("conditional", _ ) -> S.Error children - ("formal_parameters", _) -> S.Params children ("function_call", _) -> case runCofree <$> children of [ _ :< S.MemberAccess{..}, _ :< S.Args args ] -> S.MethodCall memberId property args [ _ :< S.MemberAccess{..} ] -> S.MethodCall memberId property [] @@ -63,11 +62,9 @@ termConstructor source sourceSpan name range children ("math_assignment", _ ) -> S.Error children ("member_access", [ base, property ]) -> S.MemberAccess base property ("member_access", _ ) -> S.Error children - ("method_declaration", _) -> case runCofree <$> children of - [ identifier, params@(_ :< S.Params _) ] -> S.Method (cofree identifier) (toList params) [] - [ identifier ] -> S.Method (cofree identifier) [] [] - ( identifier : params@(_ :< S.Params _ ) : exprs) -> S.Method (cofree identifier) (toList params) (cofree <$> exprs) - ( identifier : exprs ) -> S.Method (cofree identifier) [] (cofree <$> exprs) + ("method_declaration", _) -> case children of + identifier : params : body | category (extract params) == Params -> S.Method identifier (toList (unwrap params)) body + identifier : body -> S.Method identifier [] body _ -> S.Error children ("module_declaration", identifier : body ) -> S.Module identifier body ("module_declaration", _ ) -> S.Error children diff --git a/src/Renderer/JSON.hs b/src/Renderer/JSON.hs index bd3b5fe71..60c675efa 100644 --- a/src/Renderer/JSON.hs +++ b/src/Renderer/JSON.hs @@ -132,5 +132,4 @@ syntaxToTermField syntax = case syntax of S.Unless expr clauses -> [ "unless" .= expr ] <> childrenFields clauses S.BlockExpression condition expressions -> [ "condition" .= condition ] <> childrenFields expressions S.Rescue args expressions -> [ "args" .= args ] <> childrenFields expressions - S.Params c -> childrenFields c where childrenFields c = [ "children" .= c ] diff --git a/src/Syntax.hs b/src/Syntax.hs index 92109c506..a9279aa4a 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -88,8 +88,6 @@ data Syntax a f | BlockExpression (Maybe f) [f] -- | A rescue block has a list of arguments to rescue and a list of expressions. | Rescue [f] [f] - -- | Parameters in a method/function definition - | Params [f] deriving (Eq, Foldable, Functor, Generic, Generic1, Mergeable, Ord, Show, Traversable, ToJSON)