1
1
mirror of https://github.com/github/semantic.git synced 2025-01-02 20:41:38 +03:00

Skip empty children.

This commit is contained in:
Rob Rix 2016-05-26 15:41:26 -04:00
parent cfe15a5afa
commit d148286cc0

View File

@ -170,9 +170,12 @@ headRangesOf :: Both [Range] -> Maybe (Join These Range)
headRangesOf ranges = sequenceL (listToMaybe <$> Join (runBothWith These ranges))
linesOf :: (Copointed c, Functor c) => (term -> Range) -> [c [Join These term]] -> Both [Range] -> [Join These (Range, [c term])]
linesOf getRange children ranges = let (intersections, remaining) = alignChildren getRange children headRanges
Just headRanges = headRangesOf ranges
joined = Join (runBothWith These intersections) in
linesOf getRange children ranges
| (first:rest) <- children
, null (copoint first) = linesOf getRange rest ranges
| otherwise = let (intersections, remaining) = alignChildren getRange children headRanges
Just headRanges = headRangesOf ranges
joined = Join (runBothWith These intersections) in
fromJust ((,) <$> headRanges `applyThese` joined) : linesOf getRange remaining (modifyJoin (uncurry bimap (advancePast (sequenceL (fmap copoint <$> joined)))) ranges)
-- | Given a list of aligned children, produce lists of their intersecting first lines, and a list of the remaining lines/nonintersecting first lines.