1
1
mirror of https://github.com/github/semantic.git synced 2024-11-29 11:02:26 +03:00

Represent Insert/Delete explicitly in Patch.

Fixes #60.
This commit is contained in:
Rob Rix 2015-10-06 16:31:44 -04:00
parent 17191dd8ab
commit db63777dd9

View File

@ -1,19 +1,17 @@
/// A patch to some part of a `Syntax` tree.
public enum Patch<A> {
case Replace(Fix<A>?, Fix<A>?)
public static func Insert(term: Fix<A>) -> Patch {
return .Replace(nil, term)
}
public static func Delete(term: Fix<A>) -> Patch {
return .Replace(term, nil)
}
case Replace(Fix<A>, Fix<A>)
case Insert(Fix<A>)
case Delete(Fix<A>)
public var state: (before: Fix<A>?, after: Fix<A>?) {
switch self {
case let .Replace(a, b):
return (a, b)
case let .Insert(b):
return (nil, b)
case let .Delete(a):
return (a, nil)
}
}
}