mirror of
https://github.com/github/semantic.git
synced 2025-01-08 16:39:47 +03:00
Move safeRange into the Range module.
This commit is contained in:
parent
49b6984d49
commit
e630169833
@ -109,10 +109,6 @@ splitAnnotatedByLines sources ranges categories syntax = case syntax of
|
||||
makeRanges :: Both Int -> Both Int -> Both Range
|
||||
makeRanges a b = runBothWith safeRange <$> sequenceA (both a b)
|
||||
|
||||
-- | Constructs a Range such that its end is clamped to its start.
|
||||
safeRange :: Int -> Int -> Range
|
||||
safeRange start end = Range start (max start end)
|
||||
|
||||
-- | Produces the starting indices of a diff.
|
||||
diffRanges :: Diff leaf Info -> Both (Maybe Range)
|
||||
diffRanges (Free (Annotated infos _)) = Just . characterRange <$> infos
|
||||
|
@ -15,6 +15,10 @@ data Range = Range { start :: !Int, end :: !Int }
|
||||
rangeAt :: Int -> Range
|
||||
rangeAt a = Range a a
|
||||
|
||||
-- | Constructs a Range such that its end is clamped to its start.
|
||||
safeRange :: Int -> Int -> Range
|
||||
safeRange start end = Range start (max start end)
|
||||
|
||||
-- | Return the length of the range.
|
||||
rangeLength :: Range -> Int
|
||||
rangeLength range = end range - start range
|
||||
|
Loading…
Reference in New Issue
Block a user