mirror of
https://github.com/github/semantic.git
synced 2024-11-29 02:44:36 +03:00
Get patch ranges using unPatch.
This commit is contained in:
parent
6389f7bbc6
commit
4d57b20f76
@ -117,9 +117,7 @@ splitAnnotatedByLines sources ranges categories syntax = case syntax of
|
||||
-- | Produces the starting indices of a diff.
|
||||
diffRanges :: Diff leaf Info -> Both (Maybe Range)
|
||||
diffRanges (Free (Annotated infos _)) = Just . characterRange <$> infos
|
||||
diffRanges (Pure (Delete (Info r1 _ :< _))) = Both (Just r1, Nothing)
|
||||
diffRanges (Pure (Insert (Info r2 _ :< _))) = Both (Just r2, Nothing)
|
||||
diffRanges (Pure (Replace (Info r1 _ :< _) (Info r2 _ :< _))) = Both (Just r1, Just r2)
|
||||
diffRanges (Pure patch) = fmap (characterRange . extract) <$> unPatch patch
|
||||
|
||||
-- | Returns a function that takes an Either, applies either the left or right
|
||||
-- | MaybeOpen, and returns Nothing or the original either.
|
||||
|
Loading…
Reference in New Issue
Block a user