1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 09:15:01 +03:00

Use starts/ends.

This commit is contained in:
Rob Rix 2015-12-04 10:48:04 -05:00
parent f76335f38a
commit 563973e210

View File

@ -46,13 +46,13 @@ annotatedToRows (Annotated (Info left _ leftCategories, Info right _ rightCatego
annotatedToRows (Annotated (Info left _ leftCategories, Info right _ rightCategories) (Indexed i)) before after = (bimap (Ul $ classify leftCategories) (Ul $ classify rightCategories) <$> rows, (left, right))
where
rows = appendRemainder $ foldl sumRows ([], (start left, start right)) i
rows = appendRemainder $ foldl sumRows ([], starts left right) i
appendRemainder (rows, (previousLeft, previousRight)) = adjoinRows rows contextRows
where
contextRows = uncurry rowFromMaybeRows <$> zipMaybe leftElements rightElements
leftElements = Text <$> lines (substring (Range previousLeft $ end left) before)
rightElements = Text <$> lines (substring (Range previousRight $ end right) after)
sumRows (rows, (previousLeft, previousRight)) child = (rows `adjoinRows` contextRows `adjoinRows` childRows, (end leftChildRange, end rightChildRange))
sumRows (rows, (previousLeft, previousRight)) child = (rows `adjoinRows` contextRows `adjoinRows` childRows, ends leftChildRange rightChildRange)
where
(childRows, (leftChildRange, rightChildRange)) = diffToRows child before after
contextRows = uncurry rowFromMaybeRows <$> zipMaybe leftElements rightElements