mirror of
https://github.com/github/semantic.git
synced 2024-12-22 06:11:49 +03:00
Remove need for Params syntax
This commit is contained in:
parent
4ff0ccf653
commit
437522f5e1
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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 ]
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user