mirror of
https://github.com/github/semantic.git
synced 2024-11-28 18:23:44 +03:00
Remove Term.Empty.
This commit is contained in:
parent
17271ff2ce
commit
c3e8d9a801
@ -4,17 +4,15 @@ public enum Diff: Comparable, CustomDebugStringConvertible, CustomDocConvertible
|
||||
indirect case Copy(Syntax<Diff>)
|
||||
|
||||
public static func Insert(term: Term) -> Diff {
|
||||
return .Patch(.Empty, term)
|
||||
return .Patch(Term(.Empty), term)
|
||||
}
|
||||
|
||||
public static func Delete(term: Term) -> Diff {
|
||||
return .Patch(term, .Empty)
|
||||
return .Patch(term, Term(.Empty))
|
||||
}
|
||||
|
||||
public init(_ term: Term) {
|
||||
switch term {
|
||||
case .Empty:
|
||||
self = .Empty
|
||||
case let .Roll(s):
|
||||
self = .Copy(s.map(Diff.init))
|
||||
}
|
||||
@ -55,12 +53,7 @@ public enum Diff: Comparable, CustomDebugStringConvertible, CustomDocConvertible
|
||||
}
|
||||
|
||||
public init(_ a: Term, _ b: Term) {
|
||||
switch (a, b) {
|
||||
case (.Empty, .Empty):
|
||||
self = .Empty
|
||||
|
||||
case let (.Roll(a), .Roll(b)):
|
||||
switch (a, b) {
|
||||
switch (a.syntax, b.syntax) {
|
||||
case let (.Apply(a, aa), .Apply(b, bb)):
|
||||
self = .Copy(.Apply(Diff(a, b), Diff.diff(aa, bb)))
|
||||
|
||||
@ -80,11 +73,7 @@ public enum Diff: Comparable, CustomDebugStringConvertible, CustomDocConvertible
|
||||
self = .Copy(.Group(Diff(n1, n2), Diff.diff(v1, v2)))
|
||||
|
||||
default:
|
||||
self = .Patch(Term(a), Term(b))
|
||||
}
|
||||
|
||||
default:
|
||||
self = Patch(a, b)
|
||||
self = .Patch(a, b)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,5 @@
|
||||
public func == (left: Term, right: Term) -> Bool {
|
||||
switch (left, right) {
|
||||
case (.Empty, .Empty):
|
||||
return true
|
||||
case let (.Roll(s), .Roll(t)):
|
||||
return s == t
|
||||
|
||||
default:
|
||||
return false
|
||||
}
|
||||
return left.syntax == right.syntax
|
||||
}
|
||||
|
||||
public func == <F: Equatable> (left: Syntax<F>, right: Syntax<F>) -> Bool {
|
||||
|
@ -3,13 +3,17 @@ public enum Term: CustomDebugStringConvertible, CustomDocConvertible, CustomStri
|
||||
self = .Roll(out)
|
||||
}
|
||||
|
||||
case Empty
|
||||
indirect case Roll(Syntax<Term>)
|
||||
|
||||
public var syntax: Syntax<Term> {
|
||||
switch self {
|
||||
case let .Roll(syntax):
|
||||
return syntax
|
||||
}
|
||||
}
|
||||
|
||||
public var debugDescription: String {
|
||||
switch self {
|
||||
case .Empty:
|
||||
return ".Empty"
|
||||
case let .Roll(s):
|
||||
return s.debugDescription
|
||||
}
|
||||
@ -17,8 +21,6 @@ public enum Term: CustomDebugStringConvertible, CustomDocConvertible, CustomStri
|
||||
|
||||
public var doc: Doc {
|
||||
switch self {
|
||||
case .Empty:
|
||||
return .Empty
|
||||
case let .Roll(s):
|
||||
return s.doc
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user