1
1
mirror of https://github.com/github/semantic.git synced 2024-12-28 09:21:35 +03:00

Make leaves within the parent’s substring.

This commit is contained in:
Rob Rix 2015-12-14 12:39:56 -05:00
parent dbce74368f
commit bac6b696a5

View File

@ -65,7 +65,7 @@ replaceLeavesWithWordBranches :: String -> Term String Info -> Term String Info
replaceLeavesWithWordBranches source term = replaceIn source 0 term
where
replaceIn source startIndex (info@(Info range lineRange categories) :< syntax) | range <- offsetRange (negate startIndex) range = info :< case syntax of
Leaf _ | ranges <- rangesOfWordsFrom (start range) (substring range source), length ranges > 1 -> Indexed $ makeLeaf source startIndex lineRange categories <$> ranges
Leaf _ | ranges <- rangesOfWordsFrom (start range) (substring range source), length ranges > 1 -> Indexed $ makeLeaf (substring range source) startIndex lineRange categories <$> ranges
Indexed i -> Indexed $ replaceIn (substring range source) (start range) <$> i
Fixed f -> Fixed $ replaceIn (substring range source) (start range) <$> f
Keyed k -> Keyed $ replaceIn (substring range source) (start range) <$> k