1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 13:02:37 +03:00

Simplify how we combine graphs in replacements.

This commit is contained in:
Rob Rix 2018-02-07 13:21:39 -05:00
parent 4cf569a798
commit cfadd23a5a

View File

@ -29,8 +29,8 @@ diffAlgebra d i as = case d of
Merge t -> termAlgebra t i as
Patch (Delete t1) -> termAlgebra t1 i ("color" := "red" : as)
Patch (Insert t2) -> termAlgebra t2 i ("color" := "green" : as)
Patch (Replace t1 t2) -> let r1 = termAlgebra t1 i ("color" := "red" : as)
in r1 <> termAlgebra t2 (succ (maximum (i : toList (stateGraph r1)))) ("color" := "green" : as)
Patch (Replace t1 t2) -> let r1 = termAlgebra t1 i ("color" := "red" : as)
in r1 <> termAlgebra t2 (maximum (stateGraph r1)) ("color" := "green" : as)
termAlgebra :: (ConstructorName syntax, Foldable syntax) => TermF syntax ann (Int -> [Attribute B.ByteString] -> State) -> Int -> [Attribute B.ByteString] -> State
termAlgebra t i defaultAttrs = State