mirror of
https://github.com/github/semantic.git
synced 2025-01-03 13:02:37 +03:00
intersects
takes a single line.
This commit is contained in:
parent
c79773ceea
commit
23a2e300ae
@ -143,7 +143,7 @@ group2 ranges children | Just (headRanges, tailRanges) <- unconsThese ranges
|
|||||||
, (child:restOfChildren) <- children
|
, (child:restOfChildren) <- children
|
||||||
, (firstLine:rest) <- child
|
, (firstLine:rest) <- child
|
||||||
, ~(l, r) <- split firstLine
|
, ~(l, r) <- split firstLine
|
||||||
= case fromThese False False . runJoin $ intersects headRanges child of
|
= case fromThese False False . runJoin $ intersects headRanges firstLine of
|
||||||
(True, True) -> let (moreRanges, moreChildren, remainingLines) = group2 tailRanges (rest:restOfChildren) in
|
(True, True) -> let (moreRanges, moreChildren, remainingLines) = group2 tailRanges (rest:restOfChildren) in
|
||||||
(moreRanges, moreChildren, pairRangesWithLine headRanges (pure <$> firstLine) : remainingLines)
|
(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
|
(True, False) -> let (moreRanges, moreChildren, remainingLines) = group2 (modifyJoin (bimap (drop 1) (if null r then id else drop 1)) ranges) ((r ++ rest):restOfChildren) in
|
||||||
@ -179,9 +179,8 @@ getRange :: SplitDiff leaf Info -> Range
|
|||||||
getRange (Free (Annotated (Info range _) _)) = range
|
getRange (Free (Annotated (Info range _) _)) = range
|
||||||
getRange (Pure patch) | Info range _ :< _ <- getSplitTerm patch = range
|
getRange (Pure patch) | Info range _ :< _ <- getSplitTerm patch = range
|
||||||
|
|
||||||
intersects :: Join These Range -> AlignedDiff leaf -> Join These Bool
|
intersects :: Join These Range -> Join These (SplitDiff leaf Info) -> Join These Bool
|
||||||
intersects ranges childLines | (line:_) <- childLines = fromMaybe (False <$ line) $ intersectsChild <$> ranges `applyThese` line
|
intersects ranges line = fromMaybe (False <$ line) $ intersectsChild <$> ranges `applyThese` line
|
||||||
| otherwise = False <$ ranges
|
|
||||||
|
|
||||||
intersectsChild :: Range -> SplitDiff leaf Info -> Bool
|
intersectsChild :: Range -> SplitDiff leaf Info -> Bool
|
||||||
intersectsChild range child = end (getRange child) <= end range
|
intersectsChild range child = end (getRange child) <= end range
|
||||||
|
Loading…
Reference in New Issue
Block a user