mirror of
https://github.com/github/semantic.git
synced 2024-12-26 00:12:29 +03:00
Map to source ranges.
This commit is contained in:
parent
76a67a7d8e
commit
97a7a105d2
@ -40,7 +40,7 @@ if let a = arguments[1] {
|
||||
ts_document_parse(document)
|
||||
let root = ts_document_root_node(document)
|
||||
|
||||
let term = Cofree<String, TSNode>
|
||||
let term: Cofree<String, Range<Int>> = Cofree
|
||||
.ana { node in
|
||||
let count = ts_node_child_count(node)
|
||||
guard count > 0 else {
|
||||
@ -48,6 +48,10 @@ if let a = arguments[1] {
|
||||
}
|
||||
return .Indexed((0..<count).map { ts_node_child(node, $0) })
|
||||
} (root)
|
||||
.map {
|
||||
let start = ts_node_pos($0).chars
|
||||
return start..<(start + ts_node_size($0).chars)
|
||||
}
|
||||
|
||||
print(term)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user