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

Flatten the type declaration pattern.

This commit is contained in:
Rob Rix 2017-01-23 13:14:42 -05:00
parent 9e61d8a2eb
commit 9a98bd6c8e

View File

@ -25,7 +25,7 @@ termAssignment source (range :. category :. sourceSpan :. Nil) children = Just $
(For, [body]) | Other "block" <- Info.category (extract body) -> withDefaultInfo $ S.For [] (toList (unwrap body))
(For, [forClause, body]) | Other "for_clause" <- Info.category (extract forClause) -> withDefaultInfo $ S.For (toList (unwrap forClause)) (toList (unwrap body))
(For, [rangeClause, body]) | Other "range_clause" <- Info.category (extract rangeClause) -> withDefaultInfo $ S.For (toList (unwrap rangeClause)) (toList (unwrap body))
(TypeDecl, _) -> toTypeDecl children
(TypeDecl, [identifier, ty]) -> withDefaultInfo $ S.TypeDecl identifier ty
(StructTy, _) -> toStructTy children
(FieldDecl, _) -> toFieldDecl children
(Switch, _) ->
@ -113,10 +113,6 @@ termAssignment source (range :. category :. sourceSpan :. Nil) children = Just $
blocks' = foldMap (toList . unwrap) blocks
in withDefaultInfo (S.If clauses' blocks')
toTypeDecl = \case
[identifier, ty] -> withDefaultInfo $ S.TypeDecl identifier ty
rest -> withRanges range Error rest $ S.Error rest
toImports imports =
withDefaultInfo $ S.Indexed (imports >>= toImport)
where