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

Try to compute the name from the contents of the string.

This commit is contained in:
Rob Rix 2015-10-28 17:41:02 -04:00
parent 28ddedb967
commit f7f45444e0

View File

@ -85,7 +85,8 @@ func termWithInput(string: String) -> Term? {
})
case .Object:
return try .Keyed(Dictionary(elements: node.namedChildren.map {
guard let name = try $0.namedChildren.first?.name(document) else { throw E() }
guard let range = $0.namedChildren.first?.range else { throw E() }
guard let name = String(string.utf16[String.UTF16View.Index(_offset: range.startIndex)..<String.UTF16View.Index(_offset: range.endIndex)]) else { throw E() }
return try (name, ($0, $0.category(document)))
}))
default: