mirror of
https://github.com/github/semantic.git
synced 2024-11-24 08:54:07 +03:00
Return ranges from diffToRows.
This commit is contained in:
parent
ffcb4d9c98
commit
80dcd8efae
@ -25,12 +25,12 @@ split _ _ _ = return mempty
|
|||||||
|
|
||||||
data Row = Row (Maybe HTML) (Maybe HTML)
|
data Row = Row (Maybe HTML) (Maybe HTML)
|
||||||
|
|
||||||
diffToRows :: Diff a Info -> String -> String -> [Row]
|
diffToRows :: Diff a Info -> String -> String -> ([Row], Range, Range)
|
||||||
diffToRows (Free (Annotated (left, right) syntax)) = annotationAndSyntaxToRows (left, right) syntax
|
diffToRows (Free (Annotated (Info leftRange _ leftCategories, Info rightRange _ rightCategories) syntax)) before after = (annotationAndSyntaxToRows leftRange leftCategories rightRange rightCategories syntax before after, leftRange, rightRange)
|
||||||
|
|
||||||
-- | Given annotations, a syntax node, and before/after strings, returns a list of `Row`s representing the newline-separated diff.
|
-- | Given annotations, a syntax node, and before/after strings, returns a list of `Row`s representing the newline-separated diff.
|
||||||
annotationAndSyntaxToRows :: (Info, Info) -> Syntax a (Diff a Info) -> String -> String -> [Row]
|
annotationAndSyntaxToRows :: Range -> Set.Set Category -> Range -> Set.Set Category -> Syntax a (Diff a Info) -> String -> String -> [Row]
|
||||||
annotationAndSyntaxToRows (Info left _ leftCategories, Info right _ rightCategories) (Leaf _) before after = uncurry Row <$> zipMaybe leftElements rightElements
|
annotationAndSyntaxToRows left leftCategories right rightCategories (Leaf _) before after = uncurry Row <$> zipMaybe leftElements rightElements
|
||||||
where
|
where
|
||||||
leftElements = Span (classify leftCategories) <$> lines (substring left before)
|
leftElements = Span (classify leftCategories) <$> lines (substring left before)
|
||||||
rightElements = Span (classify rightCategories) <$> lines (substring right after)
|
rightElements = Span (classify rightCategories) <$> lines (substring right after)
|
||||||
|
Loading…
Reference in New Issue
Block a user