removed src/point.h

This commit is contained in:
Maieul BOYER 2024-04-30 15:06:33 +02:00
parent dfdd8e4503
commit 5bec1546aa
No known key found for this signature in database
8 changed files with 153 additions and 66 deletions

View file

@ -1,62 +0,0 @@
#ifndef TREE_SITTER_POINT_H_
#define TREE_SITTER_POINT_H_
#include "parser/api.h"
#define POINT_ZERO ((t_point) {0, 0})
#define POINT_MAX ((t_point) {UINT32_MAX, UINT32_MAX})
static inline t_point point__new(unsigned row, unsigned column) {
t_point result = {row, column};
return result;
}
static inline t_point point_add(t_point a, t_point b) {
if (b.row > 0)
return point__new(a.row + b.row, b.column);
else
return point__new(a.row, a.column + b.column);
}
static inline t_point point_sub(t_point a, t_point b) {
if (a.row > b.row)
return point__new(a.row - b.row, a.column);
else
return point__new(0, a.column - b.column);
}
static inline bool point_lte(t_point a, t_point b) {
return (a.row < b.row) || (a.row == b.row && a.column <= b.column);
}
static inline bool point_lt(t_point a, t_point b) {
return (a.row < b.row) || (a.row == b.row && a.column < b.column);
}
static inline bool point_gt(t_point a, t_point b) {
return (a.row > b.row) || (a.row == b.row && a.column > b.column);
}
static inline bool point_gte(t_point a, t_point b) {
return (a.row > b.row) || (a.row == b.row && a.column >= b.column);
}
static inline bool point_eq(t_point a, t_point b) {
return a.row == b.row && a.column == b.column;
}
static inline t_point point_min(t_point a, t_point b) {
if (a.row < b.row || (a.row == b.row && a.column < b.column))
return a;
else
return b;
}
static inline t_point point_max(t_point a, t_point b) {
if (a.row > b.row || (a.row == b.row && a.column > b.column))
return a;
else
return b;
}
#endif

View file

@ -66,7 +66,7 @@ void ts_tree_edit(t_parse_tree *self, const t_input_edit *edit) {
);
if (range->end_byte < edit->new_end_byte) {
range->end_byte = UINT32_MAX;
range->end_point = POINT_MAX;
range->end_point = point_val_max();
}
}
} else if (range->end_byte > edit->start_byte) {
@ -81,7 +81,7 @@ void ts_tree_edit(t_parse_tree *self, const t_input_edit *edit) {
);
if (range->start_byte < edit->new_end_byte) {
range->start_byte = UINT32_MAX;
range->start_point = POINT_MAX;
range->start_point = point_val_max();
}
} else if (range->start_byte > edit->start_byte) {
range->start_byte = edit->start_byte;

View file

@ -299,7 +299,7 @@ static inline t_i64 ts_tree_cursor_goto_first_child_for_byte_and_point(
}
t_i64 ts_tree_cursor_goto_first_child_for_byte(t_parse_tree_cursor *self, t_u32 goal_byte) {
return ts_tree_cursor_goto_first_child_for_byte_and_point(self, goal_byte, POINT_ZERO);
return ts_tree_cursor_goto_first_child_for_byte_and_point(self, goal_byte, point_val_zero());
}
t_i64 ts_tree_cursor_goto_first_child_for_point(t_parse_tree_cursor *self, t_point goal_point) {