1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 23:11:50 +03:00

Extract and rename pairWithNothing.

This commit is contained in:
Rob Rix 2016-03-15 08:54:35 -04:00
parent d1b8a94b75
commit c3fa0eb986

View File

@ -86,14 +86,16 @@ childLines :: (Copointed c, Functor c, Applicative f, Coalescent (f (Line (Maybe
childLines sources child (followingLines, next) | or $ (>) . end <$> childRanges <*> next = (followingLines, next)
| otherwise =
((placeChildAndRangeInContainer <$> copoint child)
<> tsequenceL (pure mempty) (fromList . pairWithNothing <$> trailingContextLines)
<> tsequenceL (pure mempty) (fromList . makeContextLines <$> trailingContextLines)
<> followingLines, start <$> childRanges)
where pairWithNothing = fmap (fmap ((,) Nothing))
placeChildAndRangeInContainer = fmap (fmap (first (Just . (<$ child))))
where placeChildAndRangeInContainer = fmap (fmap (first (Just . (<$ child))))
trailingContextLines = linesInRangeOfSource <$> rangeUntilNext <*> sources
rangeUntilNext = (Range <$> (end <$> childRanges) <*> next)
childRanges = unionLineRangesFrom <$> (rangeAt <$> next) <*> sequenceA (copoint child)
makeContextLines :: [Line Range] -> [Line (Maybe a, Range)]
makeContextLines = fmap (fmap ((,) Nothing))
-- | Produce open/closed lines for the portion of the source spanned by a range.
linesInRangeOfSource :: Range -> Source Char -> [Line Range]
linesInRangeOfSource range source = pureBy (openRange source) <$> actualLineRanges range source