1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 23:42:31 +03:00

Use a computed property.

This commit is contained in:
Rob Rix 2015-10-30 17:21:47 -04:00
parent ec579b2053
commit 49f8e54409

View File

@ -19,14 +19,14 @@ typealias Parser = String throws -> Term
struct Source {
init(_ argument: String) throws {
let URL = NSURL(string: argument) ?? NSURL(fileURLWithPath: argument)
guard let type = URL.pathExtension ?? URL.fragment else { throw "cannot tell the type of \(URL)" }
self.URL = URL
self.type = type
contents = try NSString(contentsOfURL: URL, encoding: NSUTF8StringEncoding) as String
}
let URL: NSURL
let type: String
var type: String {
return URL.pathExtension ?? URL.fragment ?? ""
}
let contents: String
private static let languagesByType: [String:TSLanguage] = [