mirror of
https://github.com/github/semantic.git
synced 2024-12-26 00:12:29 +03:00
Deal with comments inside object literals.
This commit is contained in:
parent
dc148e31cb
commit
746723963c
@ -55,9 +55,14 @@ func termWithInput(string: String) -> Term? {
|
|||||||
})
|
})
|
||||||
case "object":
|
case "object":
|
||||||
return try .Keyed(Dictionary(elements: node.namedChildren.map {
|
return try .Keyed(Dictionary(elements: node.namedChildren.map {
|
||||||
guard let range = $0.namedChildren.first?.range else { throw E() }
|
switch try $0.category(document) {
|
||||||
guard let name = String(string.utf16[String.UTF16View.Index(_offset: range.startIndex)..<String.UTF16View.Index(_offset: range.endIndex)]) else { throw E() }
|
case "pair":
|
||||||
return try (name, ($0, $0.category(document)))
|
let range = $0.namedChildren[0].range
|
||||||
|
guard let name = String(string.utf16[String.UTF16View.Index(_offset: range.startIndex)..<String.UTF16View.Index(_offset: range.endIndex)]) else { throw "could not make a string from utf16 range '\(range)'" }
|
||||||
|
return (name, ($0, "pair"))
|
||||||
|
default:
|
||||||
|
return try (String($0.range), ($0, $0.category(document)))
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
default:
|
default:
|
||||||
return try .Indexed(node.namedChildren.map {
|
return try .Indexed(node.namedChildren.map {
|
||||||
|
Loading…
Reference in New Issue
Block a user