mirror of
https://github.com/github/semantic.git
synced 2024-11-28 10:15:55 +03:00
Fall back to line by line diffing.
This commit is contained in:
parent
214c3cb2b4
commit
c1d85ae7ef
@ -124,7 +124,7 @@ func lines(input: String) -> Term {
|
||||
return Term(Info(range: 0..<input.utf16.count, categories: []), .Indexed(lines))
|
||||
}
|
||||
|
||||
func parserForType(type: String) -> (String throws -> Term)? {
|
||||
func parserForType(type: String) -> String throws -> Term {
|
||||
switch type {
|
||||
case "json":
|
||||
return { (input: String) throws -> Term in
|
||||
@ -136,7 +136,10 @@ func parserForType(type: String) -> (String throws -> Term)? {
|
||||
}
|
||||
}
|
||||
default:
|
||||
return Source.languagesByType[type].map(termWithInput)
|
||||
if let parser = Source.languagesByType[type].map(termWithInput) {
|
||||
return parser
|
||||
}
|
||||
return lines
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,7 +149,7 @@ guard let bSource = try arguments[2].map(Source.init) else { throw "need source
|
||||
let jsonURL = NSURL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true).URLByAppendingPathComponent("diff.json")
|
||||
guard let uiPath = NSBundle.mainBundle().infoDictionary?["PathToUISource"] as? String else { throw "need ui path" }
|
||||
guard aSource.type == bSource.type else { throw "can’t compare files of different types" }
|
||||
guard let parser = parserForType(aSource.type) else { throw "don’t know how to parse files of type \(aSource.type)" }
|
||||
let parser = parserForType(aSource.type)
|
||||
|
||||
let a = try parser(aSource.contents)
|
||||
let b = try parser(bSource.contents)
|
||||
|
Loading…
Reference in New Issue
Block a user