1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00

Pull the URLs into guard clauses.

This commit is contained in:
Rob Rix 2015-10-29 15:36:42 -04:00
parent 7f0d18934c
commit a16e0ede56

View File

@ -73,7 +73,9 @@ func termWithInput(language: TSLanguage)(_ string: String) -> Term? {
}
let arguments = BoundsCheckedArray(array: Process.arguments)
if let aURL = arguments[1].flatMap(NSURL.init), aString = readFile(aURL), bURL = arguments[2].flatMap(NSURL.init), bString = readFile(bURL), c = arguments[3], ui = arguments[4] {
guard let aURL = arguments[1].flatMap(NSURL.init) else { throw "need state A" }
guard let bURL = arguments[2].flatMap(NSURL.init) else { throw "need state B" }
if let aString = readFile(aURL), bString = readFile(bURL), c = arguments[3], ui = arguments[4] {
guard let aType = aURL.pathExtension, bType = bURL.pathExtension else { throw "cant tell what type we have here" }
guard aType == bType else { throw "cant compare files of different types" }
guard let language = languagesByFileExtension[aType] else { throw "dont know how to parse files of type \(aType)" }