1
1
mirror of https://github.com/github/semantic.git synced 2025-01-04 21:47:07 +03:00

Simplify the definition of getRange.

This commit is contained in:
Rob Rix 2016-03-03 08:37:56 -05:00
parent da941ccf06
commit 48aacb98bc

View File

@ -94,10 +94,9 @@ splitAnnotatedByLines sources ranges categories syntax = case syntax of
wrap :: Copointed f => ([f (SplitDiff leaf Info)] -> Syntax leaf (SplitDiff leaf Info)) -> Set.Set Category -> [(Range, Maybe (f (SplitDiff leaf Info)))] -> SplitDiff leaf Info
wrap constructor categories children = Free . Annotated (Info (unionRanges $ Prelude.fst <$> children) categories) . constructor . catMaybes $ Prelude.snd <$> children
getRange :: Copointed f => f (SplitDiff leaf Info) -> Range
getRange diff = case copoint diff of
(Pure patch) -> characterRange (copoint (getSplitTerm patch))
(Free (Annotated info _)) -> characterRange info
getRange :: SplitDiff leaf Info -> Range
getRange (Pure patch) = characterRange (copoint (getSplitTerm patch))
getRange (Free (Annotated info _)) = characterRange info
getInfo :: SplitDiff leaf Info -> Info
getInfo (Pure patch) = copoint (getSplitTerm patch)