mirror of
https://github.com/github/semantic.git
synced 2024-11-29 11:02:26 +03:00
parent
17191dd8ab
commit
db63777dd9
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user