1
1
mirror of https://github.com/github/semantic.git synced 2024-12-18 20:31:55 +03:00

Match on syntax inside annotatedToRows.

This commit is contained in:
Rob Rix 2015-12-10 17:27:23 -05:00
parent 00826a1a82
commit 92d5d9cf4f

View File

@ -146,8 +146,9 @@ termToLines (Info range _ categories :< syntax) source = (rows syntax, range)
-- | Given an Annotated and before/after strings, returns a list of `Row`s representing the newline-separated diff.
annotatedToRows :: Annotated a (Info, Info) (Diff a Info) -> String -> String -> ([Row], (Range, Range))
annotatedToRows (Annotated (Info left _ leftCategories, Info right _ rightCategories) (Leaf _)) before after = (zipWithMaybe rowFromMaybeRows leftElements rightElements, (left, right))
annotatedToRows (Annotated (Info left _ leftCategories, Info right _ rightCategories) syntax) before after = (rows syntax, (left, right))
where
rows (Leaf _) = zipWithMaybe rowFromMaybeRows leftElements rightElements
leftElements = (elementAndBreak $ Span (classify leftCategories)) =<< actualLines (substring left before)
rightElements = (elementAndBreak $ Span (classify rightCategories)) =<< actualLines (substring right after)