Skip to content

Commit e218c58

Browse files
authored
Merge branch 'smacker:master' into master
2 parents d043309 + 2c4b54e commit e218c58

File tree

16 files changed

+445597
-639769
lines changed

16 files changed

+445597
-639769
lines changed

bindings.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ type Input struct {
8080
Encoding InputEncoding
8181
}
8282

83-
var ErrOperationLimit = errors.New("operation limit was hit")
84-
var ErrNoLanguage = errors.New("cannot parse without language")
83+
var (
84+
ErrOperationLimit = errors.New("operation limit was hit")
85+
ErrNoLanguage = errors.New("cannot parse without language")
86+
)
8587

8688
// Parse produces new Tree from content using old tree
8789
//
@@ -217,6 +219,9 @@ func (p *Parser) Debug() {
217219
}
218220

219221
// Close should be called to ensure that all the memory used by the parse is freed.
222+
//
223+
// As the constructor in go-tree-sitter would set this func call through runtime.SetFinalizer,
224+
// parser.Close() will be called by Go's garbage collector and users would not have to call this manually.
220225
func (p *Parser) Close() {
221226
if !p.isClosed {
222227
C.ts_parser_delete(p.c)
@@ -296,6 +301,9 @@ func (t *Tree) cachedNode(ptr C.TSNode) *Node {
296301
}
297302

298303
// Close should be called to ensure that all the memory used by the tree is freed.
304+
//
305+
// As the constructor in go-tree-sitter would set this func call through runtime.SetFinalizer,
306+
// parser.Close() will be called by Go's garbage collector and users would not have to call this manually.
299307
func (t *BaseTree) Close() {
300308
if !t.isClosed {
301309
C.ts_tree_delete(t.c)
@@ -523,7 +531,7 @@ func (n Node) ChildByFieldName(name string) *Node {
523531

524532
// FieldNameForChild returns the field name of the child at the given index, or "" if not named.
525533
func (n Node) FieldNameForChild(idx int) string {
526-
return C.GoString(C.ts_node_field_name_for_child(n.c, C.uint32_t(idx)))
534+
return C.GoString(C.ts_node_field_name_for_child(n.c, C.uint32_t(idx)))
527535
}
528536

529537
// NextSibling returns the node's next sibling.
@@ -597,6 +605,9 @@ func NewTreeCursor(n *Node) *TreeCursor {
597605

598606
// Close should be called to ensure that all the memory used by the tree cursor
599607
// is freed.
608+
//
609+
// As the constructor in go-tree-sitter would set this func call through runtime.SetFinalizer,
610+
// parser.Close() will be called by Go's garbage collector and users would not have to call this manually.
600611
func (c *TreeCursor) Close() {
601612
if !c.isClosed {
602613
C.ts_tree_cursor_delete(c.c)
@@ -732,6 +743,9 @@ func NewQuery(pattern []byte, lang *Language) (*Query, error) {
732743
}
733744

734745
// Close should be called to ensure that all the memory used by the query is freed.
746+
//
747+
// As the constructor in go-tree-sitter would set this func call through runtime.SetFinalizer,
748+
// parser.Close() will be called by Go's garbage collector and users would not have to call this manually.
735749
func (q *Query) Close() {
736750
if !q.isClosed {
737751
C.ts_query_delete(q.c)
@@ -834,8 +848,10 @@ func (qc *QueryCursor) SetPointRange(startPoint Point, endPoint Point) {
834848
C.ts_query_cursor_set_point_range(qc.c, cStartPoint, cEndPoint)
835849
}
836850

837-
// Close should be called to ensure that all the memory used by the query
838-
// cursor is freed.
851+
// Close should be called to ensure that all the memory used by the query cursor is freed.
852+
//
853+
// As the constructor in go-tree-sitter would set this func call through runtime.SetFinalizer,
854+
// parser.Close() will be called by Go's garbage collector and users would not have to call this manually.
839855
func (qc *QueryCursor) Close() {
840856
if !qc.isClosed {
841857
C.ts_query_cursor_delete(qc.c)

0 commit comments

Comments
 (0)