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

Revert "Rewrite group2 in terms of spanIntersecting."

This reverts commit 3f808c548a6980b2ae35ec2fb7ea1dd249707668.
This commit is contained in:
Rob Rix 2016-04-11 12:06:02 -04:00
parent 48264b1cb3
commit 2f241803af

View File

@ -140,10 +140,16 @@ groupChildrenByLine ranges children | not (and $ null <$> ranges)
group2 :: Join These [Range] -> [AlignedDiff leaf] -> (Join These [Range], [AlignedDiff leaf], [Join These (Range, [SplitDiff leaf Info])])
group2 ranges children | Just (headRanges, tailRanges) <- unconsThese ranges
, ~(group, l, r, rest) <- spanThese (intersects headRanges) children
, merged <- pairRangesWithLine headRanges $ fmap catMaybes (Join (uncurry These (unalign (runJoin <$> join group))))
, ~(moreRanges, moreChildren, remainingLines) <- group2 (modifyJoin (bimap (if null l && not (null r) then id else drop 1) (if null r && not (null l) then id else drop 1)) ranges) (l ++ r ++ rest)
= (moreRanges, moreChildren, merged : remainingLines)
, ((firstLine:rest):restOfChildren) <- children
, ~(l, r) <- split firstLine
= case fromThese False False . runJoin $ intersects headRanges firstLine of
(True, True) -> let (moreRanges, moreChildren, remainingLines) = group2 tailRanges (rest:restOfChildren) in
(moreRanges, moreChildren, pairRangesWithLine headRanges (pure <$> firstLine) : remainingLines)
(True, False) -> let (moreRanges, moreChildren, remainingLines) = group2 (modifyJoin (bimap (drop 1) (if null r then id else drop 1)) ranges) ((r ++ rest):restOfChildren) in
(moreRanges, moreChildren, pairRangesWithLine headRanges (mask firstLine $ modifyJoin (uncurry These . fromThese [] []) $ pure <$> head l) : remainingLines)
(False, True) -> let (moreRanges, moreChildren, remainingLines) = group2 (modifyJoin (bimap (if null l then id else drop 1) (drop 1)) ranges) ((l ++ rest):restOfChildren) in
(moreRanges, moreChildren, pairRangesWithLine headRanges (mask firstLine $ modifyJoin (uncurry These . fromThese [] []) $ pure <$> head r) : remainingLines)
_ -> (tailRanges, children, [ flip (,) [] <$> headRanges ])
| ([]:rest) <- children = group2 ranges rest
| otherwise = ([] <$ ranges, children, fmap (flip (,) []) <$> sequenceL ranges)