@prosdevlab/dev-agent 0.8.5

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 (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +138 -0
  3. package/dist/cli.js +74721 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/mcp.js +61445 -0
  6. package/dist/mcp.js.map +1 -0
  7. package/dist/vendor/web-tree-sitter/lib/alloc.c +48 -0
  8. package/dist/vendor/web-tree-sitter/lib/alloc.h +41 -0
  9. package/dist/vendor/web-tree-sitter/lib/array.h +291 -0
  10. package/dist/vendor/web-tree-sitter/lib/atomic.h +68 -0
  11. package/dist/vendor/web-tree-sitter/lib/clock.h +146 -0
  12. package/dist/vendor/web-tree-sitter/lib/error_costs.h +11 -0
  13. package/dist/vendor/web-tree-sitter/lib/get_changed_ranges.c +523 -0
  14. package/dist/vendor/web-tree-sitter/lib/get_changed_ranges.h +36 -0
  15. package/dist/vendor/web-tree-sitter/lib/host.h +21 -0
  16. package/dist/vendor/web-tree-sitter/lib/language.c +293 -0
  17. package/dist/vendor/web-tree-sitter/lib/language.h +293 -0
  18. package/dist/vendor/web-tree-sitter/lib/length.h +52 -0
  19. package/dist/vendor/web-tree-sitter/lib/lexer.c +483 -0
  20. package/dist/vendor/web-tree-sitter/lib/lexer.h +54 -0
  21. package/dist/vendor/web-tree-sitter/lib/lib.c +12 -0
  22. package/dist/vendor/web-tree-sitter/lib/node.c +875 -0
  23. package/dist/vendor/web-tree-sitter/lib/parser.c +2297 -0
  24. package/dist/vendor/web-tree-sitter/lib/parser.h +286 -0
  25. package/dist/vendor/web-tree-sitter/lib/point.h +48 -0
  26. package/dist/vendor/web-tree-sitter/lib/query.c +4347 -0
  27. package/dist/vendor/web-tree-sitter/lib/reduce_action.h +34 -0
  28. package/dist/vendor/web-tree-sitter/lib/reusable_node.h +95 -0
  29. package/dist/vendor/web-tree-sitter/lib/stack.c +912 -0
  30. package/dist/vendor/web-tree-sitter/lib/stack.h +133 -0
  31. package/dist/vendor/web-tree-sitter/lib/subtree.c +1034 -0
  32. package/dist/vendor/web-tree-sitter/lib/subtree.h +399 -0
  33. package/dist/vendor/web-tree-sitter/lib/tree-sitter.c +987 -0
  34. package/dist/vendor/web-tree-sitter/lib/tree-sitter.cjs +2988 -0
  35. package/dist/vendor/web-tree-sitter/lib/tree-sitter.wasm +0 -0
  36. package/dist/vendor/web-tree-sitter/lib/tree-sitter.wasm.map +1 -0
  37. package/dist/vendor/web-tree-sitter/lib/tree.c +170 -0
  38. package/dist/vendor/web-tree-sitter/lib/tree.h +31 -0
  39. package/dist/vendor/web-tree-sitter/lib/tree_cursor.c +716 -0
  40. package/dist/vendor/web-tree-sitter/lib/tree_cursor.h +48 -0
  41. package/dist/vendor/web-tree-sitter/lib/ts_assert.h +11 -0
  42. package/dist/vendor/web-tree-sitter/lib/unicode.h +75 -0
  43. package/dist/vendor/web-tree-sitter/lib/wasm_store.c +1937 -0
  44. package/dist/vendor/web-tree-sitter/lib/wasm_store.h +31 -0
  45. package/dist/vendor/web-tree-sitter/package.json +98 -0
  46. package/dist/vendor/web-tree-sitter/tree-sitter.cjs +4031 -0
  47. package/dist/vendor/web-tree-sitter/tree-sitter.wasm +0 -0
  48. package/dist/wasm/tree-sitter-go.wasm +0 -0
  49. package/dist/wasm/tree-sitter.wasm +0 -0
  50. package/package.json +65 -0
@@ -0,0 +1,523 @@
1
+ #include "./get_changed_ranges.h"
2
+ #include "./subtree.h"
3
+ #include "./language.h"
4
+ #include "./error_costs.h"
5
+ #include "./tree_cursor.h"
6
+ #include "./ts_assert.h"
7
+
8
+ // #define DEBUG_GET_CHANGED_RANGES
9
+
10
+ static void ts_range_array_add(
11
+ TSRangeArray *self,
12
+ Length start,
13
+ Length end
14
+ ) {
15
+ if (self->size > 0) {
16
+ TSRange *last_range = array_back(self);
17
+ if (start.bytes <= last_range->end_byte) {
18
+ last_range->end_byte = end.bytes;
19
+ last_range->end_point = end.extent;
20
+ return;
21
+ }
22
+ }
23
+
24
+ if (start.bytes < end.bytes) {
25
+ TSRange range = { start.extent, end.extent, start.bytes, end.bytes };
26
+ array_push(self, range);
27
+ }
28
+ }
29
+
30
+ bool ts_range_array_intersects(
31
+ const TSRangeArray *self,
32
+ unsigned start_index,
33
+ uint32_t start_byte,
34
+ uint32_t end_byte
35
+ ) {
36
+ for (unsigned i = start_index; i < self->size; i++) {
37
+ TSRange *range = array_get(self, i);
38
+ if (range->end_byte > start_byte) {
39
+ if (range->start_byte >= end_byte) break;
40
+ return true;
41
+ }
42
+ }
43
+ return false;
44
+ }
45
+
46
+ void ts_range_array_get_changed_ranges(
47
+ const TSRange *old_ranges, unsigned old_range_count,
48
+ const TSRange *new_ranges, unsigned new_range_count,
49
+ TSRangeArray *differences
50
+ ) {
51
+ unsigned new_index = 0;
52
+ unsigned old_index = 0;
53
+ Length current_position = length_zero();
54
+ bool in_old_range = false;
55
+ bool in_new_range = false;
56
+
57
+ while (old_index < old_range_count || new_index < new_range_count) {
58
+ const TSRange *old_range = &old_ranges[old_index];
59
+ const TSRange *new_range = &new_ranges[new_index];
60
+
61
+ Length next_old_position;
62
+ if (in_old_range) {
63
+ next_old_position = (Length) {old_range->end_byte, old_range->end_point};
64
+ } else if (old_index < old_range_count) {
65
+ next_old_position = (Length) {old_range->start_byte, old_range->start_point};
66
+ } else {
67
+ next_old_position = LENGTH_MAX;
68
+ }
69
+
70
+ Length next_new_position;
71
+ if (in_new_range) {
72
+ next_new_position = (Length) {new_range->end_byte, new_range->end_point};
73
+ } else if (new_index < new_range_count) {
74
+ next_new_position = (Length) {new_range->start_byte, new_range->start_point};
75
+ } else {
76
+ next_new_position = LENGTH_MAX;
77
+ }
78
+
79
+ if (next_old_position.bytes < next_new_position.bytes) {
80
+ if (in_old_range != in_new_range) {
81
+ ts_range_array_add(differences, current_position, next_old_position);
82
+ }
83
+ if (in_old_range) old_index++;
84
+ current_position = next_old_position;
85
+ in_old_range = !in_old_range;
86
+ } else if (next_new_position.bytes < next_old_position.bytes) {
87
+ if (in_old_range != in_new_range) {
88
+ ts_range_array_add(differences, current_position, next_new_position);
89
+ }
90
+ if (in_new_range) new_index++;
91
+ current_position = next_new_position;
92
+ in_new_range = !in_new_range;
93
+ } else {
94
+ if (in_old_range != in_new_range) {
95
+ ts_range_array_add(differences, current_position, next_new_position);
96
+ }
97
+ if (in_old_range) old_index++;
98
+ if (in_new_range) new_index++;
99
+ in_old_range = !in_old_range;
100
+ in_new_range = !in_new_range;
101
+ current_position = next_new_position;
102
+ }
103
+ }
104
+ }
105
+
106
+ typedef struct {
107
+ TreeCursor cursor;
108
+ const TSLanguage *language;
109
+ unsigned visible_depth;
110
+ bool in_padding;
111
+ Subtree prev_external_token;
112
+ } Iterator;
113
+
114
+ static Iterator iterator_new(
115
+ TreeCursor *cursor,
116
+ const Subtree *tree,
117
+ const TSLanguage *language
118
+ ) {
119
+ array_clear(&cursor->stack);
120
+ array_push(&cursor->stack, ((TreeCursorEntry) {
121
+ .subtree = tree,
122
+ .position = length_zero(),
123
+ .child_index = 0,
124
+ .structural_child_index = 0,
125
+ }));
126
+ return (Iterator) {
127
+ .cursor = *cursor,
128
+ .language = language,
129
+ .visible_depth = 1,
130
+ .in_padding = false,
131
+ .prev_external_token = NULL_SUBTREE,
132
+ };
133
+ }
134
+
135
+ static bool iterator_done(Iterator *self) {
136
+ return self->cursor.stack.size == 0;
137
+ }
138
+
139
+ static Length iterator_start_position(Iterator *self) {
140
+ TreeCursorEntry entry = *array_back(&self->cursor.stack);
141
+ if (self->in_padding) {
142
+ return entry.position;
143
+ } else {
144
+ return length_add(entry.position, ts_subtree_padding(*entry.subtree));
145
+ }
146
+ }
147
+
148
+ static Length iterator_end_position(Iterator *self) {
149
+ TreeCursorEntry entry = *array_back(&self->cursor.stack);
150
+ Length result = length_add(entry.position, ts_subtree_padding(*entry.subtree));
151
+ if (self->in_padding) {
152
+ return result;
153
+ } else {
154
+ return length_add(result, ts_subtree_size(*entry.subtree));
155
+ }
156
+ }
157
+
158
+ static bool iterator_tree_is_visible(const Iterator *self) {
159
+ TreeCursorEntry entry = *array_back(&self->cursor.stack);
160
+ if (ts_subtree_visible(*entry.subtree)) return true;
161
+ if (self->cursor.stack.size > 1) {
162
+ Subtree parent = *array_get(&self->cursor.stack, self->cursor.stack.size - 2)->subtree;
163
+ return ts_language_alias_at(
164
+ self->language,
165
+ parent.ptr->production_id,
166
+ entry.structural_child_index
167
+ ) != 0;
168
+ }
169
+ return false;
170
+ }
171
+
172
+ static void iterator_get_visible_state(
173
+ const Iterator *self,
174
+ Subtree *tree,
175
+ TSSymbol *alias_symbol,
176
+ uint32_t *start_byte
177
+ ) {
178
+ uint32_t i = self->cursor.stack.size - 1;
179
+
180
+ if (self->in_padding) {
181
+ if (i == 0) return;
182
+ i--;
183
+ }
184
+
185
+ for (; i + 1 > 0; i--) {
186
+ TreeCursorEntry entry = *array_get(&self->cursor.stack, i);
187
+
188
+ if (i > 0) {
189
+ const Subtree *parent = array_get(&self->cursor.stack, i - 1)->subtree;
190
+ *alias_symbol = ts_language_alias_at(
191
+ self->language,
192
+ parent->ptr->production_id,
193
+ entry.structural_child_index
194
+ );
195
+ }
196
+
197
+ if (ts_subtree_visible(*entry.subtree) || *alias_symbol) {
198
+ *tree = *entry.subtree;
199
+ *start_byte = entry.position.bytes;
200
+ break;
201
+ }
202
+ }
203
+ }
204
+
205
+ static void iterator_ascend(Iterator *self) {
206
+ if (iterator_done(self)) return;
207
+ if (iterator_tree_is_visible(self) && !self->in_padding) self->visible_depth--;
208
+ if (array_back(&self->cursor.stack)->child_index > 0) self->in_padding = false;
209
+ self->cursor.stack.size--;
210
+ }
211
+
212
+ static bool iterator_descend(Iterator *self, uint32_t goal_position) {
213
+ if (self->in_padding) return false;
214
+
215
+ bool did_descend = false;
216
+ do {
217
+ did_descend = false;
218
+ TreeCursorEntry entry = *array_back(&self->cursor.stack);
219
+ Length position = entry.position;
220
+ uint32_t structural_child_index = 0;
221
+ for (uint32_t i = 0, n = ts_subtree_child_count(*entry.subtree); i < n; i++) {
222
+ const Subtree *child = &ts_subtree_children(*entry.subtree)[i];
223
+ Length child_left = length_add(position, ts_subtree_padding(*child));
224
+ Length child_right = length_add(child_left, ts_subtree_size(*child));
225
+
226
+ if (child_right.bytes > goal_position) {
227
+ array_push(&self->cursor.stack, ((TreeCursorEntry) {
228
+ .subtree = child,
229
+ .position = position,
230
+ .child_index = i,
231
+ .structural_child_index = structural_child_index,
232
+ }));
233
+
234
+ if (iterator_tree_is_visible(self)) {
235
+ if (child_left.bytes > goal_position) {
236
+ self->in_padding = true;
237
+ } else {
238
+ self->visible_depth++;
239
+ }
240
+ return true;
241
+ }
242
+
243
+ did_descend = true;
244
+ break;
245
+ }
246
+
247
+ position = child_right;
248
+ if (!ts_subtree_extra(*child)) structural_child_index++;
249
+ Subtree last_external_token = ts_subtree_last_external_token(*child);
250
+ if (last_external_token.ptr) {
251
+ self->prev_external_token = last_external_token;
252
+ }
253
+ }
254
+ } while (did_descend);
255
+
256
+ return false;
257
+ }
258
+
259
+ static void iterator_advance(Iterator *self) {
260
+ if (self->in_padding) {
261
+ self->in_padding = false;
262
+ if (iterator_tree_is_visible(self)) {
263
+ self->visible_depth++;
264
+ } else {
265
+ iterator_descend(self, 0);
266
+ }
267
+ return;
268
+ }
269
+
270
+ for (;;) {
271
+ if (iterator_tree_is_visible(self)) self->visible_depth--;
272
+ TreeCursorEntry entry = array_pop(&self->cursor.stack);
273
+ if (iterator_done(self)) return;
274
+
275
+ const Subtree *parent = array_back(&self->cursor.stack)->subtree;
276
+ uint32_t child_index = entry.child_index + 1;
277
+ Subtree last_external_token = ts_subtree_last_external_token(*entry.subtree);
278
+ if (last_external_token.ptr) {
279
+ self->prev_external_token = last_external_token;
280
+ }
281
+ if (ts_subtree_child_count(*parent) > child_index) {
282
+ Length position = length_add(entry.position, ts_subtree_total_size(*entry.subtree));
283
+ uint32_t structural_child_index = entry.structural_child_index;
284
+ if (!ts_subtree_extra(*entry.subtree)) structural_child_index++;
285
+ const Subtree *next_child = &ts_subtree_children(*parent)[child_index];
286
+
287
+ array_push(&self->cursor.stack, ((TreeCursorEntry) {
288
+ .subtree = next_child,
289
+ .position = position,
290
+ .child_index = child_index,
291
+ .structural_child_index = structural_child_index,
292
+ }));
293
+
294
+ if (iterator_tree_is_visible(self)) {
295
+ if (ts_subtree_padding(*next_child).bytes > 0) {
296
+ self->in_padding = true;
297
+ } else {
298
+ self->visible_depth++;
299
+ }
300
+ } else {
301
+ iterator_descend(self, 0);
302
+ }
303
+ break;
304
+ }
305
+ }
306
+ }
307
+
308
+ typedef enum {
309
+ IteratorDiffers,
310
+ IteratorMayDiffer,
311
+ IteratorMatches,
312
+ } IteratorComparison;
313
+
314
+ static IteratorComparison iterator_compare(
315
+ const Iterator *old_iter,
316
+ const Iterator *new_iter
317
+ ) {
318
+ Subtree old_tree = NULL_SUBTREE;
319
+ Subtree new_tree = NULL_SUBTREE;
320
+ uint32_t old_start = 0;
321
+ uint32_t new_start = 0;
322
+ TSSymbol old_alias_symbol = 0;
323
+ TSSymbol new_alias_symbol = 0;
324
+ iterator_get_visible_state(old_iter, &old_tree, &old_alias_symbol, &old_start);
325
+ iterator_get_visible_state(new_iter, &new_tree, &new_alias_symbol, &new_start);
326
+ TSSymbol old_symbol = ts_subtree_symbol(old_tree);
327
+ TSSymbol new_symbol = ts_subtree_symbol(new_tree);
328
+
329
+ if (!old_tree.ptr && !new_tree.ptr) return IteratorMatches;
330
+ if (!old_tree.ptr || !new_tree.ptr) return IteratorDiffers;
331
+ if (old_alias_symbol != new_alias_symbol || old_symbol != new_symbol) return IteratorDiffers;
332
+
333
+ uint32_t old_size = ts_subtree_size(old_tree).bytes;
334
+ uint32_t new_size = ts_subtree_size(new_tree).bytes;
335
+ TSStateId old_state = ts_subtree_parse_state(old_tree);
336
+ TSStateId new_state = ts_subtree_parse_state(new_tree);
337
+ bool old_has_external_tokens = ts_subtree_has_external_tokens(old_tree);
338
+ bool new_has_external_tokens = ts_subtree_has_external_tokens(new_tree);
339
+ uint32_t old_error_cost = ts_subtree_error_cost(old_tree);
340
+ uint32_t new_error_cost = ts_subtree_error_cost(new_tree);
341
+
342
+ if (
343
+ old_start != new_start ||
344
+ old_symbol == ts_builtin_sym_error ||
345
+ old_size != new_size ||
346
+ old_state == TS_TREE_STATE_NONE ||
347
+ new_state == TS_TREE_STATE_NONE ||
348
+ ((old_state == ERROR_STATE) != (new_state == ERROR_STATE)) ||
349
+ old_error_cost != new_error_cost ||
350
+ old_has_external_tokens != new_has_external_tokens ||
351
+ ts_subtree_has_changes(old_tree) ||
352
+ (
353
+ old_has_external_tokens &&
354
+ !ts_subtree_external_scanner_state_eq(old_iter->prev_external_token, new_iter->prev_external_token)
355
+ )
356
+ ) {
357
+ return IteratorMayDiffer;
358
+ }
359
+
360
+ return IteratorMatches;
361
+ }
362
+
363
+ #ifdef DEBUG_GET_CHANGED_RANGES
364
+ static inline void iterator_print_state(Iterator *self) {
365
+ TreeCursorEntry entry = *array_back(&self->cursor.stack);
366
+ TSPoint start = iterator_start_position(self).extent;
367
+ TSPoint end = iterator_end_position(self).extent;
368
+ const char *name = ts_language_symbol_name(self->language, ts_subtree_symbol(*entry.subtree));
369
+ printf(
370
+ "(%-25s %s\t depth:%u [%u, %u] - [%u, %u])",
371
+ name, self->in_padding ? "(p)" : " ",
372
+ self->visible_depth,
373
+ start.row, start.column,
374
+ end.row, end.column
375
+ );
376
+ }
377
+ #endif
378
+
379
+ unsigned ts_subtree_get_changed_ranges(
380
+ const Subtree *old_tree, const Subtree *new_tree,
381
+ TreeCursor *cursor1, TreeCursor *cursor2,
382
+ const TSLanguage *language,
383
+ const TSRangeArray *included_range_differences,
384
+ TSRange **ranges
385
+ ) {
386
+ TSRangeArray results = array_new();
387
+
388
+ Iterator old_iter = iterator_new(cursor1, old_tree, language);
389
+ Iterator new_iter = iterator_new(cursor2, new_tree, language);
390
+
391
+ unsigned included_range_difference_index = 0;
392
+
393
+ Length position = iterator_start_position(&old_iter);
394
+ Length next_position = iterator_start_position(&new_iter);
395
+ if (position.bytes < next_position.bytes) {
396
+ ts_range_array_add(&results, position, next_position);
397
+ position = next_position;
398
+ } else if (position.bytes > next_position.bytes) {
399
+ ts_range_array_add(&results, next_position, position);
400
+ next_position = position;
401
+ }
402
+
403
+ do {
404
+ #ifdef DEBUG_GET_CHANGED_RANGES
405
+ printf("At [%-2u, %-2u] Compare ", position.extent.row, position.extent.column);
406
+ iterator_print_state(&old_iter);
407
+ printf("\tvs\t");
408
+ iterator_print_state(&new_iter);
409
+ puts("");
410
+ #endif
411
+
412
+ // Compare the old and new subtrees.
413
+ IteratorComparison comparison = iterator_compare(&old_iter, &new_iter);
414
+
415
+ // Even if the two subtrees appear to be identical, they could differ
416
+ // internally if they contain a range of text that was previously
417
+ // excluded from the parse, and is now included, or vice-versa.
418
+ if (comparison == IteratorMatches && ts_range_array_intersects(
419
+ included_range_differences,
420
+ included_range_difference_index,
421
+ position.bytes,
422
+ iterator_end_position(&old_iter).bytes
423
+ )) {
424
+ comparison = IteratorMayDiffer;
425
+ }
426
+
427
+ bool is_changed = false;
428
+ switch (comparison) {
429
+ // If the subtrees are definitely identical, move to the end
430
+ // of both subtrees.
431
+ case IteratorMatches:
432
+ next_position = iterator_end_position(&old_iter);
433
+ break;
434
+
435
+ // If the subtrees might differ internally, descend into both
436
+ // subtrees, finding the first child that spans the current position.
437
+ case IteratorMayDiffer:
438
+ if (iterator_descend(&old_iter, position.bytes)) {
439
+ if (!iterator_descend(&new_iter, position.bytes)) {
440
+ is_changed = true;
441
+ next_position = iterator_end_position(&old_iter);
442
+ }
443
+ } else if (iterator_descend(&new_iter, position.bytes)) {
444
+ is_changed = true;
445
+ next_position = iterator_end_position(&new_iter);
446
+ } else {
447
+ next_position = length_min(
448
+ iterator_end_position(&old_iter),
449
+ iterator_end_position(&new_iter)
450
+ );
451
+ }
452
+ break;
453
+
454
+ // If the subtrees are different, record a change and then move
455
+ // to the end of both subtrees.
456
+ case IteratorDiffers:
457
+ is_changed = true;
458
+ next_position = length_min(
459
+ iterator_end_position(&old_iter),
460
+ iterator_end_position(&new_iter)
461
+ );
462
+ break;
463
+ }
464
+
465
+ // Ensure that both iterators are caught up to the current position.
466
+ while (
467
+ !iterator_done(&old_iter) &&
468
+ iterator_end_position(&old_iter).bytes <= next_position.bytes
469
+ ) iterator_advance(&old_iter);
470
+ while (
471
+ !iterator_done(&new_iter) &&
472
+ iterator_end_position(&new_iter).bytes <= next_position.bytes
473
+ ) iterator_advance(&new_iter);
474
+
475
+ // Ensure that both iterators are at the same depth in the tree.
476
+ while (old_iter.visible_depth > new_iter.visible_depth) {
477
+ iterator_ascend(&old_iter);
478
+ }
479
+ while (new_iter.visible_depth > old_iter.visible_depth) {
480
+ iterator_ascend(&new_iter);
481
+ }
482
+
483
+ if (is_changed) {
484
+ #ifdef DEBUG_GET_CHANGED_RANGES
485
+ printf(
486
+ " change: [[%u, %u] - [%u, %u]]\n",
487
+ position.extent.row + 1, position.extent.column,
488
+ next_position.extent.row + 1, next_position.extent.column
489
+ );
490
+ #endif
491
+
492
+ ts_range_array_add(&results, position, next_position);
493
+ }
494
+
495
+ position = next_position;
496
+
497
+ // Keep track of the current position in the included range differences
498
+ // array in order to avoid scanning the entire array on each iteration.
499
+ while (included_range_difference_index < included_range_differences->size) {
500
+ const TSRange *range = array_get(included_range_differences,
501
+ included_range_difference_index
502
+ );
503
+ if (range->end_byte <= position.bytes) {
504
+ included_range_difference_index++;
505
+ } else {
506
+ break;
507
+ }
508
+ }
509
+ } while (!iterator_done(&old_iter) && !iterator_done(&new_iter));
510
+
511
+ Length old_size = ts_subtree_total_size(*old_tree);
512
+ Length new_size = ts_subtree_total_size(*new_tree);
513
+ if (old_size.bytes < new_size.bytes) {
514
+ ts_range_array_add(&results, old_size, new_size);
515
+ } else if (new_size.bytes < old_size.bytes) {
516
+ ts_range_array_add(&results, new_size, old_size);
517
+ }
518
+
519
+ *cursor1 = old_iter.cursor;
520
+ *cursor2 = new_iter.cursor;
521
+ *ranges = results.contents;
522
+ return results.size;
523
+ }
@@ -0,0 +1,36 @@
1
+ #ifndef TREE_SITTER_GET_CHANGED_RANGES_H_
2
+ #define TREE_SITTER_GET_CHANGED_RANGES_H_
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ #include "./tree_cursor.h"
9
+ #include "./subtree.h"
10
+
11
+ typedef Array(TSRange) TSRangeArray;
12
+
13
+ void ts_range_array_get_changed_ranges(
14
+ const TSRange *old_ranges, unsigned old_range_count,
15
+ const TSRange *new_ranges, unsigned new_range_count,
16
+ TSRangeArray *differences
17
+ );
18
+
19
+ bool ts_range_array_intersects(
20
+ const TSRangeArray *self, unsigned start_index,
21
+ uint32_t start_byte, uint32_t end_byte
22
+ );
23
+
24
+ unsigned ts_subtree_get_changed_ranges(
25
+ const Subtree *old_tree, const Subtree *new_tree,
26
+ TreeCursor *cursor1, TreeCursor *cursor2,
27
+ const TSLanguage *language,
28
+ const TSRangeArray *included_range_differences,
29
+ TSRange **ranges
30
+ );
31
+
32
+ #ifdef __cplusplus
33
+ }
34
+ #endif
35
+
36
+ #endif // TREE_SITTER_GET_CHANGED_RANGES_H_
@@ -0,0 +1,21 @@
1
+
2
+ // Determine endian and pointer size based on known defines.
3
+ // TS_BIG_ENDIAN and TS_PTR_SIZE can be set as -D compiler arguments
4
+ // to override this.
5
+
6
+ #if !defined(TS_BIG_ENDIAN)
7
+ #if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) \
8
+ || (defined( __APPLE_CC__) && (defined(__ppc__) || defined(__ppc64__)))
9
+ #define TS_BIG_ENDIAN 1
10
+ #else
11
+ #define TS_BIG_ENDIAN 0
12
+ #endif
13
+ #endif
14
+
15
+ #if !defined(TS_PTR_SIZE)
16
+ #if UINTPTR_MAX == 0xFFFFFFFF
17
+ #define TS_PTR_SIZE 32
18
+ #else
19
+ #define TS_PTR_SIZE 64
20
+ #endif
21
+ #endif