1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-08 12:40:44 +00:00

GDScript: Remove leftmost_column and rightmost_column fields

This commit is contained in:
Danil Alexeev
2025-05-21 18:16:20 +03:00
parent 428a762e98
commit 7aafa6ef18
11 changed files with 37 additions and 104 deletions

View File

@@ -64,25 +64,41 @@ static void test_tokenizer(const String &p_code, const Vector<String> &p_lines)
StringBuilder token;
token += " --> "; // Padding for line number.
if (current.start_line != current.end_line) {
// Print "vvvvvv" to point at the token.
StringBuilder pointer;
pointer += " "; // Padding for line number.
int line_width = 0;
if (current.start_line - 1 >= 0 && current.start_line - 1 < p_lines.size()) {
line_width = p_lines[current.start_line - 1].replace("\t", tab).length();
}
const int offset = MAX(0, current.start_column - 1);
const int width = MAX(0, line_width - current.start_column + 1);
pointer += String::chr(' ').repeat(offset) + String::chr('v').repeat(width);
print_line(pointer.as_string());
}
for (int l = current.start_line; l <= current.end_line && l <= p_lines.size(); l++) {
print_line(vformat("%04d %s", l, p_lines[l - 1]).replace("\t", tab));
}
{
// Print carets to point at the token.
// Print "^^^^^^" to point at the token.
StringBuilder pointer;
pointer += " "; // Padding for line number.
int rightmost_column = current.rightmost_column;
if (current.end_line > current.start_line) {
rightmost_column--; // Don't point to the newline as a column.
}
for (int col = 1; col < rightmost_column; col++) {
if (col < current.leftmost_column) {
pointer += " ";
} else {
pointer += "^";
}
if (current.start_line == current.end_line) {
const int offset = MAX(0, current.start_column - 1);
const int width = MAX(0, current.end_column - current.start_column);
pointer += String::chr(' ').repeat(offset) + String::chr('^').repeat(width);
} else {
const int width = MAX(0, current.end_column - 1);
pointer += String::chr('^').repeat(width);
}
print_line(pointer.as_string());
}