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:
parent
4ff0ccf653
commit
437522f5e1
@ -244,7 +244,6 @@ toTermName source term = case unwrap term of
|
|||||||
Just expr -> termNameFromSource expr
|
Just expr -> termNameFromSource expr
|
||||||
Nothing -> fromMaybe "branch" $ (toCategoryName . category) . extract <$> head children
|
Nothing -> fromMaybe "branch" $ (toCategoryName . category) . extract <$> head children
|
||||||
S.Rescue args _ -> intercalate ", " $ toTermName' <$> args
|
S.Rescue args _ -> intercalate ", " $ toTermName' <$> args
|
||||||
S.Params args -> mconcat $ toTermName' <$> args
|
|
||||||
where toTermName' = toTermName source
|
where toTermName' = toTermName source
|
||||||
termNameFromChildren term children = termNameFromRange (unionRangesFrom (range term) (range <$> children))
|
termNameFromChildren term children = termNameFromRange (unionRangesFrom (range term) (range <$> children))
|
||||||
termNameFromSource term = termNameFromRange (range term)
|
termNameFromSource term = termNameFromRange (range term)
|
||||||
|
@ -43,7 +43,6 @@ termConstructor source sourceSpan name range children
|
|||||||
("conditional_assignment", _ ) -> S.Error children
|
("conditional_assignment", _ ) -> S.Error children
|
||||||
("conditional", condition : cases) -> S.Ternary condition cases
|
("conditional", condition : cases) -> S.Ternary condition cases
|
||||||
("conditional", _ ) -> S.Error children
|
("conditional", _ ) -> S.Error children
|
||||||
("formal_parameters", _) -> S.Params children
|
|
||||||
("function_call", _) -> case runCofree <$> children of
|
("function_call", _) -> case runCofree <$> children of
|
||||||
[ _ :< S.MemberAccess{..}, _ :< S.Args args ] -> S.MethodCall memberId property args
|
[ _ :< S.MemberAccess{..}, _ :< S.Args args ] -> S.MethodCall memberId property args
|
||||||
[ _ :< S.MemberAccess{..} ] -> S.MethodCall memberId property []
|
[ _ :< S.MemberAccess{..} ] -> S.MethodCall memberId property []
|
||||||
@ -63,11 +62,9 @@ termConstructor source sourceSpan name range children
|
|||||||
("math_assignment", _ ) -> S.Error children
|
("math_assignment", _ ) -> S.Error children
|
||||||
("member_access", [ base, property ]) -> S.MemberAccess base property
|
("member_access", [ base, property ]) -> S.MemberAccess base property
|
||||||
("member_access", _ ) -> S.Error children
|
("member_access", _ ) -> S.Error children
|
||||||
("method_declaration", _) -> case runCofree <$> children of
|
("method_declaration", _) -> case children of
|
||||||
[ identifier, params@(_ :< S.Params _) ] -> S.Method (cofree identifier) (toList params) []
|
identifier : params : body | category (extract params) == Params -> S.Method identifier (toList (unwrap params)) body
|
||||||
[ identifier ] -> S.Method (cofree identifier) [] []
|
identifier : body -> S.Method identifier [] body
|
||||||
( identifier : params@(_ :< S.Params _ ) : exprs) -> S.Method (cofree identifier) (toList params) (cofree <$> exprs)
|
|
||||||
( identifier : exprs ) -> S.Method (cofree identifier) [] (cofree <$> exprs)
|
|
||||||
_ -> S.Error children
|
_ -> S.Error children
|
||||||
("module_declaration", identifier : body ) -> S.Module identifier body
|
("module_declaration", identifier : body ) -> S.Module identifier body
|
||||||
("module_declaration", _ ) -> S.Error children
|
("module_declaration", _ ) -> S.Error children
|
||||||
|
@ -132,5 +132,4 @@ syntaxToTermField syntax = case syntax of
|
|||||||
S.Unless expr clauses -> [ "unless" .= expr ] <> childrenFields clauses
|
S.Unless expr clauses -> [ "unless" .= expr ] <> childrenFields clauses
|
||||||
S.BlockExpression condition expressions -> [ "condition" .= condition ] <> childrenFields expressions
|
S.BlockExpression condition expressions -> [ "condition" .= condition ] <> childrenFields expressions
|
||||||
S.Rescue args expressions -> [ "args" .= args ] <> childrenFields expressions
|
S.Rescue args expressions -> [ "args" .= args ] <> childrenFields expressions
|
||||||
S.Params c -> childrenFields c
|
|
||||||
where childrenFields c = [ "children" .= c ]
|
where childrenFields c = [ "children" .= c ]
|
||||||
|
@ -88,8 +88,6 @@ data Syntax a f
|
|||||||
| BlockExpression (Maybe f) [f]
|
| BlockExpression (Maybe f) [f]
|
||||||
-- | A rescue block has a list of arguments to rescue and a list of expressions.
|
-- | A rescue block has a list of arguments to rescue and a list of expressions.
|
||||||
| Rescue [f] [f]
|
| Rescue [f] [f]
|
||||||
-- | Parameters in a method/function definition
|
|
||||||
| Params [f]
|
|
||||||
deriving (Eq, Foldable, Functor, Generic, Generic1, Mergeable, Ord, Show, Traversable, ToJSON)
|
deriving (Eq, Foldable, Functor, Generic, Generic1, Mergeable, Ord, Show, Traversable, ToJSON)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user