ruby_tree_sitter 0.20.8.2-x86_64-darwin-20 → 1.0.0-x86_64-darwin-20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +2 -1
  3. data/README.md +32 -18
  4. data/ext/tree_sitter/extconf.rb +1 -43
  5. data/ext/tree_sitter/input.c +1 -0
  6. data/ext/tree_sitter/language.c +131 -46
  7. data/ext/tree_sitter/logger.c +28 -12
  8. data/ext/tree_sitter/node.c +438 -130
  9. data/ext/tree_sitter/parser.c +232 -37
  10. data/ext/tree_sitter/query.c +197 -72
  11. data/ext/tree_sitter/query_cursor.c +140 -28
  12. data/ext/tree_sitter/repo.rb +121 -0
  13. data/ext/tree_sitter/tree.c +118 -34
  14. data/ext/tree_sitter/tree_cursor.c +205 -33
  15. data/ext/tree_sitter/tree_sitter.c +12 -0
  16. data/lib/tree_sitter/node.rb +43 -9
  17. data/lib/tree_sitter/tree_sitter.bundle +0 -0
  18. data/lib/tree_sitter/version.rb +4 -2
  19. data/lib/tree_sitter.rb +1 -0
  20. data/lib/tree_stand/ast_modifier.rb +30 -0
  21. data/lib/tree_stand/breadth_first_visitor.rb +54 -0
  22. data/lib/tree_stand/config.rb +13 -0
  23. data/lib/tree_stand/node.rb +224 -0
  24. data/lib/tree_stand/parser.rb +67 -0
  25. data/lib/tree_stand/range.rb +55 -0
  26. data/lib/tree_stand/tree.rb +123 -0
  27. data/lib/tree_stand/utils/printer.rb +73 -0
  28. data/lib/tree_stand/version.rb +7 -0
  29. data/lib/tree_stand/visitor.rb +127 -0
  30. data/lib/tree_stand/visitors/tree_walker.rb +37 -0
  31. data/lib/tree_stand.rb +48 -0
  32. data/tree_sitter.gemspec +15 -12
  33. metadata +37 -107
  34. data/test/README.md +0 -15
  35. data/test/test_helper.rb +0 -9
  36. data/test/tree_sitter/js_test.rb +0 -48
  37. data/test/tree_sitter/language_test.rb +0 -73
  38. data/test/tree_sitter/logger_test.rb +0 -70
  39. data/test/tree_sitter/node_test.rb +0 -355
  40. data/test/tree_sitter/parser_test.rb +0 -140
  41. data/test/tree_sitter/query_test.rb +0 -153
  42. data/test/tree_sitter/tree_cursor_test.rb +0 -83
  43. data/test/tree_sitter/tree_test.rb +0 -51
@@ -38,26 +38,22 @@ VALUE new_node_by_val(TSNode ptr) {
38
38
 
39
39
  DATA_FROM_VALUE(TSNode, node)
40
40
 
41
- static VALUE node_type(VALUE self) { return safe_symbol(ts_node_type(SELF)); }
42
-
43
- static VALUE node_symbol(VALUE self) { return UINT2NUM(ts_node_symbol(SELF)); }
44
-
45
- static VALUE node_start_byte(VALUE self) {
46
- return UINT2NUM(ts_node_start_byte(SELF));
47
- }
48
-
49
- static VALUE node_start_point(VALUE self) {
50
- return new_point_by_val(ts_node_start_point(SELF));
51
- }
52
-
53
- static VALUE node_end_byte(VALUE self) {
54
- return UINT2NUM(ts_node_end_byte(SELF));
55
- }
56
-
57
- static VALUE node_end_point(VALUE self) {
58
- return new_point_by_val(ts_node_end_point(SELF));
41
+ /**
42
+ * Check if two nodes are identical.
43
+ *
44
+ * @param other [Node]
45
+ *
46
+ * @return [Boolean]
47
+ */
48
+ static VALUE node_eq(VALUE self, VALUE other) {
49
+ return ts_node_eq(SELF, unwrap(other)->data) ? Qtrue : Qfalse;
59
50
  }
60
51
 
52
+ /**
53
+ * Get an S-expression representing the node as a string.
54
+ *
55
+ * @return [String]
56
+ */
61
57
  static VALUE node_string(VALUE self) {
62
58
  char *str = ts_node_string(SELF);
63
59
  VALUE res = safe_str(str);
@@ -67,34 +63,82 @@ static VALUE node_string(VALUE self) {
67
63
  return res;
68
64
  }
69
65
 
70
- static VALUE node_is_null(VALUE self) {
71
- return ts_node_is_null(SELF) ? Qtrue : Qfalse;
66
+ /**
67
+ * Check if a syntax node has been edited.
68
+ *
69
+ * @return [Boolean]
70
+ */
71
+ static VALUE node_has_changes(VALUE self) {
72
+ return ts_node_has_changes(SELF) ? Qtrue : Qfalse;
72
73
  }
73
74
 
74
- static VALUE node_is_named(VALUE self) {
75
- return ts_node_is_named(SELF) ? Qtrue : Qfalse;
75
+ /**
76
+ * Check if the node is a syntax error or contains any syntax errors.
77
+ *
78
+ * @return [Boolean]
79
+ */
80
+ static VALUE node_has_error(VALUE self) {
81
+ return ts_node_has_error(SELF) ? Qtrue : Qfalse;
76
82
  }
77
83
 
78
- static VALUE node_is_missing(VALUE self) {
79
- return ts_node_is_missing(SELF) ? Qtrue : Qfalse;
84
+ /**
85
+ * Check if the node is a syntax error.
86
+ *
87
+ * @return [Boolean]
88
+ */
89
+ VALUE node_is_error(VALUE self) {
90
+ return ts_node_is_error(SELF) ? Qtrue : Qfalse;
80
91
  }
81
92
 
82
- static VALUE node_is_extra(VALUE self) {
83
- return ts_node_is_extra(SELF) ? Qtrue : Qfalse;
93
+ /**
94
+ * Check if the node is *named*. Named nodes correspond to named rules in the
95
+ * grammar, whereas *anonymous* nodes correspond to string literals in the
96
+ * grammar.
97
+ *
98
+ * @return [Boolean]
99
+ */
100
+ static VALUE node_is_named(VALUE self) {
101
+ return ts_node_is_named(SELF) ? Qtrue : Qfalse;
84
102
  }
85
103
 
86
- static VALUE node_has_changes(VALUE self) {
87
- return ts_node_has_changes(SELF) ? Qtrue : Qfalse;
104
+ /**
105
+ * Check if the node is null. Functions like {Node#child} and
106
+ * {Node#next_sibling} will return a null node to indicate that no such node
107
+ * was found.
108
+ *
109
+ * @return [Boolean]
110
+ */
111
+ static VALUE node_is_null(VALUE self) {
112
+ return ts_node_is_null(SELF) ? Qtrue : Qfalse;
88
113
  }
89
114
 
90
- static VALUE node_has_error(VALUE self) {
91
- return ts_node_has_error(SELF) ? Qtrue : Qfalse;
115
+ /**
116
+ * Check if the node is *extra*. Extra nodes represent things like comments,
117
+ * which are not required the grammar, but can appear anywhere.
118
+ *
119
+ * @return [Boolean]
120
+ */
121
+ static VALUE node_is_extra(VALUE self) {
122
+ return ts_node_is_extra(SELF) ? Qtrue : Qfalse;
92
123
  }
93
-
94
- static VALUE node_parent(VALUE self) {
95
- return new_node_by_val(ts_node_parent(SELF));
124
+ /**
125
+ * Check if the node is *missing*. Missing nodes are inserted by the parser in
126
+ * order to recover from certain kinds of syntax errors.
127
+ *
128
+ * @return [Boolean]
129
+ */
130
+ static VALUE node_is_missing(VALUE self) {
131
+ return ts_node_is_missing(SELF) ? Qtrue : Qfalse;
96
132
  }
97
133
 
134
+ /**
135
+ * Get the node's child at the given index, where zero represents the first
136
+ * child.
137
+ *
138
+ * @raise [IndexError] if out of range.
139
+ *
140
+ * @return [Node]
141
+ */
98
142
  static VALUE node_child(VALUE self, VALUE idx) {
99
143
  TSNode node = SELF;
100
144
  uint32_t index = NUM2UINT(idx);
@@ -108,19 +152,35 @@ static VALUE node_child(VALUE self, VALUE idx) {
108
152
  }
109
153
  }
110
154
 
111
- static VALUE node_field_name_for_child(VALUE self, VALUE idx) {
112
- TSNode node = SELF;
113
- uint32_t index = NUM2UINT(idx);
114
- uint32_t range = ts_node_child_count(node);
155
+ /**
156
+ * Get the node's child with the given numerical field id.
157
+ *
158
+ * You can convert a field name to an id using {Language#field_id_for_name}.
159
+ *
160
+ * @return [Node]
161
+ */
162
+ static VALUE node_child_by_field_id(VALUE self, VALUE field_id) {
163
+ return new_node_by_val(ts_node_child_by_field_id(SELF, NUM2UINT(field_id)));
164
+ }
115
165
 
116
- if (index < range) {
117
- return safe_str(ts_node_field_name_for_child(node, index));
118
- } else {
119
- rb_raise(rb_eIndexError, "Index %d is out of range (len = %d)", index,
120
- range);
121
- }
166
+ /**
167
+ * Get the node's child with the given field name.
168
+ *
169
+ * @param field_name [String]
170
+ *
171
+ * @return [Node]
172
+ */
173
+ static VALUE node_child_by_field_name(VALUE self, VALUE field_name) {
174
+ const char *name = StringValuePtr(field_name);
175
+ uint32_t length = (uint32_t)RSTRING_LEN(field_name);
176
+ return new_node_by_val(ts_node_child_by_field_name(SELF, name, length));
122
177
  }
123
178
 
179
+ /**
180
+ * Get the node's number of children.
181
+ *
182
+ * @return [Integer]
183
+ */
124
184
  static VALUE node_child_count(VALUE self) {
125
185
  TSNode node = SELF;
126
186
  const char *type = ts_node_type(node);
@@ -131,58 +191,26 @@ static VALUE node_child_count(VALUE self) {
131
191
  }
132
192
  }
133
193
 
134
- static VALUE node_named_child(VALUE self, VALUE idx) {
135
- TSNode node = SELF;
136
- uint32_t index = NUM2UINT(idx);
137
- uint32_t range = ts_node_named_child_count(node);
138
-
139
- if (index < range) {
140
- return new_node_by_val(ts_node_named_child(node, index));
141
- } else {
142
- rb_raise(rb_eIndexError, "Index %d is out of range (len = %d)", index,
143
- range);
144
- }
145
- }
146
-
147
- static VALUE node_named_child_count(VALUE self) {
148
- return UINT2NUM(ts_node_named_child_count(SELF));
149
- }
150
-
151
- static VALUE node_child_by_field_name(VALUE self, VALUE field_name) {
152
- const char *name = StringValuePtr(field_name);
153
- uint32_t length = (uint32_t)RSTRING_LEN(field_name);
154
- return new_node_by_val(ts_node_child_by_field_name(SELF, name, length));
155
- }
156
-
157
- static VALUE node_child_by_field_id(VALUE self, VALUE field_id) {
158
- return new_node_by_val(ts_node_child_by_field_id(SELF, NUM2UINT(field_id)));
159
- }
160
-
161
- static VALUE node_next_sibling(VALUE self) {
162
- return new_node_by_val(ts_node_next_sibling(SELF));
163
- }
164
-
165
- static VALUE node_prev_sibling(VALUE self) {
166
- return new_node_by_val(ts_node_prev_sibling(SELF));
167
- }
168
-
169
- static VALUE node_next_named_sibling(VALUE self) {
170
- return new_node_by_val(ts_node_next_named_sibling(SELF));
171
- }
172
-
173
- static VALUE node_prev_named_sibling(VALUE self) {
174
- return new_node_by_val(ts_node_prev_named_sibling(SELF));
175
- }
176
-
177
- static VALUE node_first_child_for_byte(VALUE self, VALUE byte) {
178
- return new_node_by_val(ts_node_first_child_for_byte(SELF, NUM2UINT(byte)));
179
- }
180
-
181
- static VALUE node_first_named_child_for_byte(VALUE self, VALUE byte) {
182
- return new_node_by_val(
183
- ts_node_first_named_child_for_byte(SELF, NUM2UINT(byte)));
184
- }
185
-
194
+ /**
195
+ * Get the node's number of descendants, including one for the node itself.
196
+ *
197
+ * @return [Integer]
198
+ */
199
+ VALUE node_descendant_count(VALUE self) {
200
+ return UINT2NUM(ts_node_descendant_count(SELF));
201
+ }
202
+
203
+ /**
204
+ * Get the smallest node within this node that spans the given range of byte
205
+ * positions.
206
+ *
207
+ * @raise [IndexError] if out of range.
208
+ *
209
+ * @param from [Integer]
210
+ * @param to [Integer]
211
+ *
212
+ * @return [Node]
213
+ */
186
214
  static VALUE node_descendant_for_byte_range(VALUE self, VALUE from, VALUE to) {
187
215
  uint32_t from_b = NUM2UINT(from);
188
216
  uint32_t to_b = NUM2UINT(to);
@@ -195,6 +223,17 @@ static VALUE node_descendant_for_byte_range(VALUE self, VALUE from, VALUE to) {
195
223
  }
196
224
  }
197
225
 
226
+ /**
227
+ * Get the smallest node within this node that spans the given range of
228
+ * (row, column) positions.
229
+ *
230
+ * @raise [IndexError] if out of range.
231
+ *
232
+ * @param from [Point]
233
+ * @param to [Point]
234
+ *
235
+ * @return [Node]
236
+ */
198
237
  static VALUE node_descendant_for_point_range(VALUE self, VALUE from, VALUE to) {
199
238
  TSNode node = SELF;
200
239
  TSPoint start = ts_node_start_point(node);
@@ -214,6 +253,133 @@ static VALUE node_descendant_for_point_range(VALUE self, VALUE from, VALUE to) {
214
253
  }
215
254
  }
216
255
 
256
+ /**
257
+ * Edit the node to keep it in-sync with source code that has been edited.
258
+ *
259
+ * This function is only rarely needed. When you edit a syntax tree with the
260
+ * {Tree#edit} function, all of the nodes that you retrieve from the tree
261
+ * afterward will already reflect the edit. You only need to use {Node#edit}
262
+ * when you have a {Node} instance that you want to keep and continue to use
263
+ * after an edit.
264
+ *
265
+ * @param input_edit [InputEdit]
266
+ *
267
+ * @return [nil]
268
+ */
269
+ static VALUE node_edit(VALUE self, VALUE input_edit) {
270
+ TSNode node = SELF;
271
+ TSInputEdit edit = value_to_input_edit(input_edit);
272
+ ts_node_edit(&node, &edit);
273
+
274
+ return Qnil;
275
+ }
276
+
277
+ /**
278
+ * Get the node's end byte.
279
+ *
280
+ * @return [Integer]
281
+ */
282
+ static VALUE node_end_byte(VALUE self) {
283
+ return UINT2NUM(ts_node_end_byte(SELF));
284
+ }
285
+
286
+ /**
287
+ * Get the node's end position in terms of rows and columns.
288
+ *
289
+ * @return [Point]
290
+ */
291
+ static VALUE node_end_point(VALUE self) {
292
+ return new_point_by_val(ts_node_end_point(SELF));
293
+ }
294
+
295
+ /**
296
+ * Get the field name for node's child at the given index, where zero represents
297
+ * the first child.
298
+ *
299
+ * @raise [IndexError] if out of range.
300
+ *
301
+ * @return [String]
302
+ */
303
+ static VALUE node_field_name_for_child(VALUE self, VALUE idx) {
304
+ // FIXME: the original API returns nil if no name was found, but I made it
305
+ // raise an exception like `node_child` for consistency. The latter was made
306
+ // this way to avoid segfault. Should we absolutely stick to the original API?
307
+ TSNode node = SELF;
308
+ uint32_t index = NUM2UINT(idx);
309
+ uint32_t range = ts_node_child_count(node);
310
+
311
+ if (index < range) {
312
+ return safe_str(ts_node_field_name_for_child(node, index));
313
+ } else {
314
+ rb_raise(rb_eIndexError, "Index %d is out of range (len = %d)", index,
315
+ range);
316
+ }
317
+ }
318
+
319
+ /**
320
+ * Get the node's first child that extends beyond the given byte offset.
321
+ *
322
+ * @param byte [Integer]
323
+ *
324
+ * @return [Node]
325
+ */
326
+ static VALUE node_first_child_for_byte(VALUE self, VALUE byte) {
327
+ return new_node_by_val(ts_node_first_child_for_byte(SELF, NUM2UINT(byte)));
328
+ }
329
+
330
+ /**
331
+ * Get the node's first named child that extends beyond the given byte offset.
332
+ *
333
+ * @param byte [Integer]
334
+ *
335
+ * @return [Node]
336
+ */
337
+ static VALUE node_first_named_child_for_byte(VALUE self, VALUE byte) {
338
+ return new_node_by_val(
339
+ ts_node_first_named_child_for_byte(SELF, NUM2UINT(byte)));
340
+ }
341
+
342
+ /**
343
+ * Get the node's type as a numerical id as it appears in the grammar ignoring
344
+ * aliases. This should be used in {Language#next_state} instead of
345
+ * {Node#symbol}.
346
+ *
347
+ * @return [Integer]
348
+ */
349
+ VALUE node_grammar_symbol(VALUE self) {
350
+ return UINT2NUM(ts_node_grammar_symbol(SELF));
351
+ }
352
+
353
+ /**
354
+ * Get the node's type as it appears in the grammar ignoring aliases as a
355
+ * null-terminated string.
356
+ *
357
+ * @return String
358
+ */
359
+ VALUE node_grammar_type(VALUE self) {
360
+ return safe_str(ts_node_grammar_type(SELF));
361
+ }
362
+
363
+ /**
364
+ * Get the node's language.
365
+ *
366
+ * @return [Language]
367
+ */
368
+ static VALUE node_language(VALUE self) {
369
+ return new_language(ts_node_language(SELF));
370
+ }
371
+
372
+ /**
373
+ * Get the smallest *named* node within this node that spans the given range of
374
+ * byte positions.
375
+ *
376
+ * @raise [IndexError] if out of range.
377
+ *
378
+ * @param from [Integer]
379
+ * @param to [Integer]
380
+ *
381
+ * @return [Node]
382
+ */
217
383
  static VALUE node_named_descendant_for_byte_range(VALUE self, VALUE from,
218
384
  VALUE to) {
219
385
  uint32_t from_b = NUM2UINT(from);
@@ -227,6 +393,17 @@ static VALUE node_named_descendant_for_byte_range(VALUE self, VALUE from,
227
393
  }
228
394
  }
229
395
 
396
+ /**
397
+ * Get the smallest *named* node within this node that spans the given range of
398
+ * (row, column) positions.
399
+ *
400
+ * @raise [IndexError] if out of range.
401
+ *
402
+ * @param from [Point]
403
+ * @param to [Point]
404
+ *
405
+ * @return [Node]
406
+ */
230
407
  static VALUE node_named_descendant_for_point_range(VALUE self, VALUE from,
231
408
  VALUE to) {
232
409
  TSNode node = SELF;
@@ -248,63 +425,194 @@ static VALUE node_named_descendant_for_point_range(VALUE self, VALUE from,
248
425
  }
249
426
  }
250
427
 
251
- static VALUE node_edit(VALUE self, VALUE input_edit) {
428
+ /**
429
+ * Get the node's *named* child at the given index.
430
+ *
431
+ * @see named?
432
+ *
433
+ * @param idx [Integer]
434
+ *
435
+ * @raise [IndexError] if out of range.
436
+ *
437
+ * @return [Node]
438
+ */
439
+ static VALUE node_named_child(VALUE self, VALUE idx) {
440
+ // FIXME: see notes in `node_field_name_for_child`
252
441
  TSNode node = SELF;
253
- TSInputEdit edit = value_to_input_edit(input_edit);
254
- ts_node_edit(&node, &edit);
442
+ uint32_t index = NUM2UINT(idx);
443
+ uint32_t range = ts_node_named_child_count(node);
255
444
 
256
- return Qnil;
445
+ if (index < range) {
446
+ return new_node_by_val(ts_node_named_child(node, index));
447
+ } else {
448
+ rb_raise(rb_eIndexError, "Index %d is out of range (len = %d)", index,
449
+ range);
450
+ }
257
451
  }
258
452
 
259
- static VALUE node_eq(VALUE self, VALUE other) {
260
- return ts_node_eq(SELF, unwrap(other)->data) ? Qtrue : Qfalse;
453
+ /**
454
+ * Get the node's number of *named* children.
455
+ *
456
+ * @see named?
457
+ *
458
+ * @return [Integer]
459
+ */
460
+ static VALUE node_named_child_count(VALUE self) {
461
+ return UINT2NUM(ts_node_named_child_count(SELF));
462
+ }
463
+
464
+ /**
465
+ * Get the node's next *named* sibling.
466
+ *
467
+ * @return [Node]
468
+ */
469
+ static VALUE node_next_named_sibling(VALUE self) {
470
+ return new_node_by_val(ts_node_next_named_sibling(SELF));
471
+ }
472
+
473
+ /**
474
+ * Get the node's next sibling.
475
+ *
476
+ * @return [Node]
477
+ */
478
+ static VALUE node_next_sibling(VALUE self) {
479
+ return new_node_by_val(ts_node_next_sibling(SELF));
480
+ }
481
+
482
+ /**
483
+ * Get the parse state after this node.
484
+ *
485
+ * @return [Integer]
486
+ */
487
+ VALUE node_next_parse_state(VALUE self) {
488
+ return UINT2NUM(ts_node_next_parse_state(SELF));
489
+ }
490
+
491
+ /**
492
+ * Get the node's immediate parent.
493
+ *
494
+ * @return [Node]
495
+ */
496
+ static VALUE node_parent(VALUE self) {
497
+ return new_node_by_val(ts_node_parent(SELF));
498
+ }
499
+
500
+ /**
501
+ * Get the node's previous *named* sibling.
502
+ *
503
+ * @return [Node]
504
+ */
505
+ static VALUE node_prev_named_sibling(VALUE self) {
506
+ return new_node_by_val(ts_node_prev_named_sibling(SELF));
507
+ }
508
+
509
+ /**
510
+ * Get the node's previous sibling.
511
+ *
512
+ * @return [Node]
513
+ */
514
+ static VALUE node_prev_sibling(VALUE self) {
515
+ return new_node_by_val(ts_node_prev_sibling(SELF));
516
+ }
517
+
518
+ /**
519
+ * Get the node's start byte.
520
+ *
521
+ * @return [Integer]
522
+ */
523
+ static VALUE node_start_byte(VALUE self) {
524
+ return UINT2NUM(ts_node_start_byte(SELF));
525
+ }
526
+
527
+ /**
528
+ * Get the node's start position in terms of rows and columns.
529
+ *
530
+ * @return [Point]
531
+ */
532
+ static VALUE node_start_point(VALUE self) {
533
+ return new_point_by_val(ts_node_start_point(SELF));
261
534
  }
262
535
 
536
+ /**
537
+ * Get this node's parse state.
538
+ *
539
+ * @return [Integer]
540
+ */
541
+ VALUE node_parse_state(VALUE self) {
542
+ return UINT2NUM(ts_node_parse_state(SELF));
543
+ }
544
+
545
+ /**
546
+ * Get the node's type as a numerical id.
547
+ *
548
+ * @return [Integer]
549
+ */
550
+ static VALUE node_symbol(VALUE self) { return UINT2NUM(ts_node_symbol(SELF)); }
551
+
552
+ /**
553
+ * Get the node's type as a null-terminated string.
554
+ *
555
+ * @return [Symbol]
556
+ */
557
+ static VALUE node_type(VALUE self) { return safe_symbol(ts_node_type(SELF)); }
558
+
263
559
  void init_node(void) {
264
560
  cNode = rb_define_class_under(mTreeSitter, "Node", rb_cObject);
265
561
 
266
562
  rb_undef_alloc_func(cNode);
267
563
 
564
+ /* Builtins */
565
+ rb_define_method(cNode, "eq?", node_eq, 1);
566
+ rb_define_method(cNode, "to_s", node_string, 0);
567
+ rb_define_method(cNode, "to_str", node_string, 0);
568
+ rb_define_method(cNode, "inspect", node_string, 0);
569
+ rb_define_method(cNode, "==", node_eq, 1);
570
+
268
571
  /* Class methods */
269
- rb_define_method(cNode, "type", node_type, 0);
270
- rb_define_method(cNode, "symbol", node_symbol, 0);
271
- rb_define_method(cNode, "start_byte", node_start_byte, 0);
272
- rb_define_method(cNode, "start_point", node_start_point, 0);
273
- rb_define_method(cNode, "end_byte", node_end_byte, 0);
274
- rb_define_method(cNode, "end_point", node_end_point, 0);
275
- rb_define_method(cNode, "null?", node_is_null, 0);
276
- rb_define_method(cNode, "named?", node_is_named, 0);
572
+ // Predicates
573
+ rb_define_method(cNode, "changed?", node_has_changes, 0);
574
+ rb_define_method(cNode, "error?", node_is_error, 0);
575
+ rb_define_method(cNode, "has_error?", node_has_error, 0);
277
576
  rb_define_method(cNode, "missing?", node_is_missing, 0);
577
+ rb_define_method(cNode, "named?", node_is_named, 0);
578
+ rb_define_method(cNode, "null?", node_is_null, 0);
278
579
  rb_define_method(cNode, "extra?", node_is_extra, 0);
279
- rb_define_method(cNode, "changed?", node_has_changes, 0);
280
- rb_define_method(cNode, "error?", node_has_error, 0);
281
- rb_define_method(cNode, "parent", node_parent, 0);
580
+
581
+ // Other
282
582
  rb_define_method(cNode, "child", node_child, 1);
283
- rb_define_method(cNode, "field_name_for_child", node_field_name_for_child, 1);
284
- rb_define_method(cNode, "child_count", node_child_count, 0);
285
- rb_define_method(cNode, "named_child", node_named_child, 1);
286
- rb_define_method(cNode, "named_child_count", node_named_child_count, 0);
287
- rb_define_method(cNode, "child_by_field_name", node_child_by_field_name, 1);
288
583
  rb_define_method(cNode, "child_by_field_id", node_child_by_field_id, 1);
289
- rb_define_method(cNode, "next_sibling", node_next_sibling, 0);
290
- rb_define_method(cNode, "prev_sibling", node_prev_sibling, 0);
291
- rb_define_method(cNode, "next_named_sibling", node_next_named_sibling, 0);
292
- rb_define_method(cNode, "prev_named_sibling", node_prev_named_sibling, 0);
293
- rb_define_method(cNode, "first_child_for_byte", node_first_child_for_byte, 1);
294
- rb_define_method(cNode, "first_named_child_for_byte",
295
- node_first_named_child_for_byte, 1);
584
+ rb_define_method(cNode, "child_by_field_name", node_child_by_field_name, 1);
585
+ rb_define_method(cNode, "child_count", node_child_count, 0);
586
+ rb_define_method(cNode, "descendant_count", node_descendant_count, 0);
296
587
  rb_define_method(cNode, "descendant_for_byte_range",
297
588
  node_descendant_for_byte_range, 2);
298
589
  rb_define_method(cNode, "descendant_for_point_range",
299
590
  node_descendant_for_point_range, 2);
591
+ rb_define_method(cNode, "edit", node_edit, 1);
592
+ rb_define_method(cNode, "end_byte", node_end_byte, 0);
593
+ rb_define_method(cNode, "end_point", node_end_point, 0);
594
+ rb_define_method(cNode, "field_name_for_child", node_field_name_for_child, 1);
595
+ rb_define_method(cNode, "first_child_for_byte", node_first_child_for_byte, 1);
596
+ rb_define_method(cNode, "first_named_child_for_byte",
597
+ node_first_named_child_for_byte, 1);
598
+ rb_define_method(cNode, "grammar_symbol", node_grammar_symbol, 0);
599
+ rb_define_method(cNode, "grammar_type", node_grammar_type, 0);
600
+ rb_define_method(cNode, "language", node_language, 0);
601
+ rb_define_method(cNode, "named_child", node_named_child, 1);
602
+ rb_define_method(cNode, "named_child_count", node_named_child_count, 0);
300
603
  rb_define_method(cNode, "named_descendant_for_byte_range",
301
604
  node_named_descendant_for_byte_range, 2);
302
605
  rb_define_method(cNode, "named_descendant_for_point_range",
303
606
  node_named_descendant_for_point_range, 2);
304
- rb_define_method(cNode, "eq?", node_eq, 1);
305
- rb_define_method(cNode, "edit", node_edit, 1);
306
- rb_define_method(cNode, "to_s", node_string, 0);
307
- rb_define_method(cNode, "to_str", node_string, 0);
308
- rb_define_method(cNode, "inspect", node_string, 0);
309
- rb_define_method(cNode, "==", node_eq, 1);
607
+ rb_define_method(cNode, "next_named_sibling", node_next_named_sibling, 0);
608
+ rb_define_method(cNode, "next_parse_state", node_next_parse_state, 0);
609
+ rb_define_method(cNode, "next_sibling", node_next_sibling, 0);
610
+ rb_define_method(cNode, "parent", node_parent, 0);
611
+ rb_define_method(cNode, "parse_state", node_parse_state, 0);
612
+ rb_define_method(cNode, "prev_named_sibling", node_prev_named_sibling, 0);
613
+ rb_define_method(cNode, "prev_sibling", node_prev_sibling, 0);
614
+ rb_define_method(cNode, "start_byte", node_start_byte, 0);
615
+ rb_define_method(cNode, "start_point", node_start_point, 0);
616
+ rb_define_method(cNode, "symbol", node_symbol, 0);
617
+ rb_define_method(cNode, "type", node_type, 0);
310
618
  }