1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 16:02:43 +03:00

Unwrap expression statements in for loops.

This commit is contained in:
Rob Rix 2017-08-11 10:11:34 -04:00
parent 048b7874d1
commit ffa33bbe0f

View File

@ -69,7 +69,7 @@ termAssignment _ category children =
| S.Indexed _ <- unwrap statements
-> Just $ S.Export Nothing (toList (unwrap statements))
| otherwise -> Just $ S.Export (Just statements) []
(For, _:_) -> Just $ S.For (init children) [last children]
(For, _:_) -> Just $ S.For (init children >>= unwrapExpressionStatements) [last children]
(Function, children) -> case break ((== ExpressionStatements) . Info.category . extract) children of
(inits, [body]) -> case inits of
[id, callSignature] -> Just $ S.Function id (toList (unwrap callSignature)) (toList (unwrap body))
@ -79,6 +79,9 @@ termAssignment _ category children =
(Ty, children) -> Just $ S.Ty children
(Interface, children) -> toInterface children
_ -> Nothing
where unwrapExpressionStatements term
| Info.category (extract term) == ExpressionStatements = toList (unwrap term)
| otherwise = [term]
categoryForTypeScriptName :: Text -> Category
categoryForTypeScriptName category = case category of