1
1
mirror of https://github.com/github/semantic.git synced 2024-12-03 22:54:16 +03:00
semantic/prototype/doubt-swift/main.swift
2015-09-23 17:37:29 -04:00

24 lines
551 B
Swift

import Doubt
import SourceKittenFramework
let arguments = BoundsCheckedArray(array: Process.arguments)
extension Term {
init?(path: String) {
guard path != "/dev/null" else {
self = .Empty
return
}
guard let term = File(path: path)
.map(Structure.init)
.map({ $0.dictionary })
.map(toAnyObject)
.flatMap({ JSON(object: $0).map { Term(path: path, JSON: $0) } }) else { return nil }
self = term
}
}
if let a = arguments[1].flatMap(Term.init), b = arguments[2].flatMap(Term.init) {
print(String(reflecting: Diff(a, b)))
}