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

Remove need for Params syntax

This commit is contained in:
Timothy Clem 2016-11-04 13:05:28 -07:00
parent 4ff0ccf653
commit 437522f5e1
4 changed files with 3 additions and 10 deletions

View File

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

View File

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

View File

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

View File

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