mirror of
https://github.com/github/semantic.git
synced 2024-11-28 10:15:55 +03:00
Add a method returning the node’s name as a Swift string.
This commit is contained in:
parent
3b757bd1e7
commit
56a87154de
@ -3,6 +3,12 @@
|
||||
typealias TSDocument = COpaquePointer
|
||||
|
||||
extension TSNode {
|
||||
func name(document: TSDocument) throws -> String {
|
||||
struct E: ErrorType {}
|
||||
guard let name = String.fromCString(ts_node_name(self, document)) else { throw E() }
|
||||
return name
|
||||
}
|
||||
|
||||
var children: AnyRandomAccessCollection<TSNode> {
|
||||
return AnyRandomAccessCollection(ChildrenCollection(node: self, count: ts_node_child_count, child: ts_node_child))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user