1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 15:35:14 +03:00

Construct keyed nodes when appropriate.

This commit is contained in:
Rob Rix 2015-12-16 16:02:59 -05:00
parent 829e443af8
commit ec674a572a

View File

@ -55,7 +55,11 @@ constructorForProductions :: Set.Set String -> Set.Set String -> Constructor
constructorForProductions keyed fixed source info@(Info range categories) = (info :<) . construct constructorForProductions keyed fixed source info@(Info range categories) = (info :<) . construct
where construct [] = Leaf (substring range source) where construct [] = Leaf (substring range source)
construct children | not . Set.null $ Set.intersection fixed categories = Fixed $ fmap snd children construct children | not . Set.null $ Set.intersection fixed categories = Fixed $ fmap snd children
construct children | not . Set.null $ Set.intersection keyed categories = Keyed . Map.fromList $ assignKey <$> children
construct children = Indexed $ fmap snd children construct children = Indexed $ fmap snd children
assignKey ("pair", node@(_ :< Fixed (key : _))) = (getSubstring key, node)
assignKey (_, node) = (getSubstring node, node)
getSubstring (Info range _ :< _) = substring range source
languageForType :: String -> Maybe (Ptr TSLanguage) languageForType :: String -> Maybe (Ptr TSLanguage)
languageForType mediaType = case mediaType of languageForType mediaType = case mediaType of