There was an error in the way that we calculate the reference scope sequences that are used as the basis for assertions about changed ranges in randomized tests. The error caused some characters' scopes to not be checked. This corrects the reference implementation and fixes a previously uncaught bug in the implementation of `tree_path_get_changed_ranges`. Previously, when iterating over the old and new trees, we would only perform comparisons of visible nodes. This resulted in a failure to do any comparison for portions of the text in which there were trailing invisible child nodes (e.g. trailing `_line_break` nodes inside `statement` nodes in the JavaScript grammar). Now, we additionally perform comparisons at invisible leaf nodes, based on their lowest visible ancestor.
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
#include "./point_helpers.h"
|
|
#include <string>
|
|
#include <ostream>
|
|
#include "runtime/length.h"
|
|
#include "tree_sitter/runtime.h"
|
|
|
|
using namespace std;
|
|
|
|
bool operator==(const TSPoint &left, const TSPoint &right) {
|
|
return left.row == right.row && left.column == right.column;
|
|
}
|
|
|
|
bool operator==(const TSRange &left, const TSRange &right) {
|
|
return left.start == right.start && left.end == right.end;
|
|
}
|
|
|
|
bool operator==(const Length &left, const Length &right) {
|
|
return left.bytes == right.bytes &&
|
|
left.chars == right.chars &&
|
|
left.extent == right.extent;
|
|
}
|
|
|
|
bool operator<(const TSPoint &left, const TSPoint &right) {
|
|
if (left.row < right.row) return true;
|
|
if (left.row > right.row) return false;
|
|
|
|
return left.column < right.column;
|
|
}
|
|
|
|
bool operator>(const TSPoint &left, const TSPoint &right) {
|
|
return right < left;
|
|
}
|
|
|
|
std::ostream &operator<<(std::ostream &stream, const TSPoint &point) {
|
|
return stream << "{" << point.row << ", " << point.column << "}";
|
|
}
|
|
|
|
std::ostream &operator<<(std::ostream &stream, const TSRange &range) {
|
|
return stream << "{" << range.start << ", " << range.end << "}";
|
|
}
|
|
|
|
ostream &operator<<(ostream &stream, const Length &length) {
|
|
return stream << "{chars:" << length.chars << ", bytes:" <<
|
|
length.bytes << ", extent:" << length.extent << "}";
|
|
}
|