1
1
mirror of https://github.com/github/semantic.git synced 2025-01-04 21:47:07 +03:00

Define splitTermByLines over Indexed terms.

This commit is contained in:
Rob Rix 2015-12-21 14:57:33 -05:00
parent 8fa370cb62
commit 426d83a60a

View File

@ -152,6 +152,8 @@ diffToRows (Pure (Replace a b)) _ before after = (replacedRows, (leftRange, righ
splitTermByLines :: Term a Info -> String -> ([Line (Term a Info)], Range)
splitTermByLines (Info range categories :< syntax) source = flip (,) range $ case syntax of
Leaf a -> adjoin $ Line True . (:[]) . (:< Leaf a) . (`Info` categories) <$> actualLineRanges range source
Indexed children -> let (lines, previous) = foldl (childLines Indexed) ([], start range) children in
adjoin $ lines ++ contextLines Indexed (Range previous $ end range) source
where adjoin = reverse . foldl (adjoinLinesBy $ openTerm source) []
contextLines constructor range source = Line True . (:[]) . (:< constructor []) . (`Info` categories) <$> actualLineRanges range source
childLines constructor (lines, previous) child = let (childLines, childRange) = splitTermByLines child source in