Class: TreeSitter::Tree
- Inherits:
-
Object
- Object
- TreeSitter::Tree
- Defined in:
- ext/tree_sitter/tree.c
Class Method Summary collapse
Instance Method Summary collapse
-
#copy ⇒ Object
Class methods.
- #edit(edit) ⇒ Object
- #language ⇒ Object
- #print_dot_graph(file) ⇒ Object
- #root_node ⇒ Object
Class Method Details
.changed_ranges(old_tree, new_tree) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'ext/tree_sitter/tree.c', line 82 static VALUE tree_changed_ranges(VALUE _self, VALUE old_tree, VALUE new_tree) { TSTree *old = unwrap(old_tree)->data; TSTree *new = unwrap(new_tree)->data; uint32_t length; TSRange *ranges = ts_tree_get_changed_ranges(old, new, &length); VALUE res = rb_ary_new_capa(length); for (uint32_t i = 0; i < length; i++) { rb_ary_push(res, new_range(&ranges[i])); } if (ranges) { free(ranges); } return res; } |
.finalizer ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'ext/tree_sitter/tree.c', line 109 static VALUE tree_finalizer(VALUE _self) { VALUE rc = rb_cv_get(cTree, "@@rc"); VALUE keys = rb_funcall(rc, rb_intern("keys"), 0); long len = RARRAY_LEN(keys); for (long i = 0; i < len; ++i) { VALUE curr = RARRAY_AREF(keys, i); unsigned int val = NUM2UINT(rb_hash_lookup(rc, curr)); if (val > 0) { ts_tree_delete((TSTree *)NUM2ULONG(curr)); } rb_hash_delete(rc, curr); } return Qnil; } |
Instance Method Details
#copy ⇒ Object
Class methods
#edit(edit) ⇒ Object
76 77 78 79 80 |
# File 'ext/tree_sitter/tree.c', line 76 static VALUE tree_edit(VALUE self, VALUE edit) { TSInputEdit in = value_to_input_edit(edit); ts_tree_edit(SELF, &in); return Qnil; } |
#language ⇒ Object
72 73 74 |
# File 'ext/tree_sitter/tree.c', line 72 static VALUE tree_language(VALUE self) { return new_language(ts_tree_language(SELF)); } |
#print_dot_graph(file) ⇒ Object
100 101 102 103 104 105 106 107 |
# File 'ext/tree_sitter/tree.c', line 100 static VALUE tree_print_dot_graph(VALUE self, VALUE file) { Check_Type(file, T_STRING); char *path = StringValueCStr(file); FILE *fd = fopen(path, "w+"); ts_tree_print_dot_graph(SELF, fd); fclose(fd); return Qnil; } |
#root_node ⇒ Object
68 69 70 |
# File 'ext/tree_sitter/tree.c', line 68 static VALUE tree_root_node(VALUE self) { return new_node_by_val(ts_tree_root_node(SELF)); } |