1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 04:51:57 +03:00

Allow variable & const declarations to fall through.

This commit is contained in:
Rob Rix 2017-01-23 14:15:42 -05:00
parent e1df6cc471
commit f55dd77f18

View File

@ -61,13 +61,11 @@ termAssignment source (range :. category :. sourceSpan :. Nil) children = case (
(TypeAssertion, [a, b]) -> withDefaultInfo $ S.TypeAssertion a b
(TypeConversion, [a, b]) -> withDefaultInfo $ S.TypeConversion a b
-- TODO: Handle multiple var specs
(Other "var_declaration", _) -> toVarDecls children
(VarAssignment, _) | Just assignment <- toVarAssignment children -> Just assignment
(VarDecl, _) | Just assignment <- toVarAssignment children -> Just assignment
(If, _) -> toIfStatement children
(FunctionCall, [id]) -> withDefaultInfo $ S.FunctionCall id []
(FunctionCall, id : rest) -> withDefaultInfo $ S.FunctionCall id rest
(Other "const_declaration", _) -> toConsts children
(AnonymousFunction, [params, _, body]) | [params'] <- toList (unwrap params)
-> withDefaultInfo $ S.AnonymousFunction (toList (unwrap params')) (toList (unwrap body))
(PointerTy, [ty]) -> withDefaultInfo $ S.Ty ty
@ -94,10 +92,6 @@ termAssignment source (range :. category :. sourceSpan :. Nil) children = case (
blocks' = foldMap (toList . unwrap) blocks
in withDefaultInfo (S.If clauses' blocks')
toVarDecls children = withDefaultInfo (S.Indexed children)
toConsts constSpecs = withDefaultInfo (S.Indexed constSpecs)
toVarAssignment = \case
[idList, ty] | Info.category (extract ty) == Identifier ->
let ids = toList (unwrap idList)