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:
parent
d1b8a94b75
commit
c3fa0eb986
@ -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)
|
childLines sources child (followingLines, next) | or $ (>) . end <$> childRanges <*> next = (followingLines, next)
|
||||||
| otherwise =
|
| otherwise =
|
||||||
((placeChildAndRangeInContainer <$> copoint child)
|
((placeChildAndRangeInContainer <$> copoint child)
|
||||||
<> tsequenceL (pure mempty) (fromList . pairWithNothing <$> trailingContextLines)
|
<> tsequenceL (pure mempty) (fromList . makeContextLines <$> trailingContextLines)
|
||||||
<> followingLines, start <$> childRanges)
|
<> followingLines, start <$> childRanges)
|
||||||
where pairWithNothing = fmap (fmap ((,) Nothing))
|
where placeChildAndRangeInContainer = fmap (fmap (first (Just . (<$ child))))
|
||||||
placeChildAndRangeInContainer = fmap (fmap (first (Just . (<$ child))))
|
|
||||||
trailingContextLines = linesInRangeOfSource <$> rangeUntilNext <*> sources
|
trailingContextLines = linesInRangeOfSource <$> rangeUntilNext <*> sources
|
||||||
rangeUntilNext = (Range <$> (end <$> childRanges) <*> next)
|
rangeUntilNext = (Range <$> (end <$> childRanges) <*> next)
|
||||||
childRanges = unionLineRangesFrom <$> (rangeAt <$> next) <*> sequenceA (copoint child)
|
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.
|
-- | Produce open/closed lines for the portion of the source spanned by a range.
|
||||||
linesInRangeOfSource :: Range -> Source Char -> [Line Range]
|
linesInRangeOfSource :: Range -> Source Char -> [Line Range]
|
||||||
linesInRangeOfSource range source = pureBy (openRange source) <$> actualLineRanges range source
|
linesInRangeOfSource range source = pureBy (openRange source) <$> actualLineRanges range source
|
||||||
|
Loading…
Reference in New Issue
Block a user