GDScript: Remove unused values from Token

This commit is contained in:
HolonProduction 2024-07-28 01:49:06 +02:00
parent 607b230ffe
commit 356de8fec3
2 changed files with 3 additions and 9 deletions

View File

@ -357,7 +357,6 @@ GDScriptTokenizer::Token GDScriptTokenizerText::make_token(Token::Type p_type) {
token.end_column = column; token.end_column = column;
token.leftmost_column = leftmost_column; token.leftmost_column = leftmost_column;
token.rightmost_column = rightmost_column; token.rightmost_column = rightmost_column;
token.source = String(_start, _current - _start);
if (p_type != Token::ERROR && cursor_line > -1) { if (p_type != Token::ERROR && cursor_line > -1) {
// Also count whitespace after token. // Also count whitespace after token.
@ -370,7 +369,6 @@ GDScriptTokenizer::Token GDScriptTokenizerText::make_token(Token::Type p_type) {
if (start_line == line) { if (start_line == line) {
// Single line token. // Single line token.
if (cursor_line == start_line && cursor_column >= start_column && cursor_column <= last_column) { if (cursor_line == start_line && cursor_column >= start_column && cursor_column <= last_column) {
token.cursor_position = cursor_column - start_column;
if (cursor_column == start_column) { if (cursor_column == start_column) {
token.cursor_place = CURSOR_BEGINNING; token.cursor_place = CURSOR_BEGINNING;
} else if (cursor_column < column) { } else if (cursor_column < column) {
@ -383,7 +381,6 @@ GDScriptTokenizer::Token GDScriptTokenizerText::make_token(Token::Type p_type) {
// Multi line token. // Multi line token.
if (cursor_line == start_line && cursor_column >= start_column) { if (cursor_line == start_line && cursor_column >= start_column) {
// Is in first line. // Is in first line.
token.cursor_position = cursor_column - start_column;
if (cursor_column == start_column) { if (cursor_column == start_column) {
token.cursor_place = CURSOR_BEGINNING; token.cursor_place = CURSOR_BEGINNING;
} else { } else {
@ -391,7 +388,6 @@ GDScriptTokenizer::Token GDScriptTokenizerText::make_token(Token::Type p_type) {
} }
} else if (cursor_line == line && cursor_column <= last_column) { } else if (cursor_line == line && cursor_column <= last_column) {
// Is in last line. // Is in last line.
token.cursor_position = cursor_column - start_column;
if (cursor_column < column) { if (cursor_column < column) {
token.cursor_place = CURSOR_MIDDLE; token.cursor_place = CURSOR_MIDDLE;
} else { } else {
@ -399,7 +395,7 @@ GDScriptTokenizer::Token GDScriptTokenizerText::make_token(Token::Type p_type) {
} }
} else if (cursor_line > start_line && cursor_line < line) { } else if (cursor_line > start_line && cursor_line < line) {
// Is in middle line. // Is in middle line.
token.cursor_position = CURSOR_MIDDLE; token.cursor_place = CURSOR_MIDDLE;
} }
} }
} }
@ -480,7 +476,7 @@ GDScriptTokenizer::Token GDScriptTokenizerText::annotation() {
_advance(); _advance();
} }
Token annotation = make_token(Token::ANNOTATION); Token annotation = make_token(Token::ANNOTATION);
annotation.literal = StringName(annotation.source); annotation.literal = StringName(String(_start, _current - _start));
return annotation; return annotation;
} }

View File

@ -170,12 +170,10 @@ public:
}; };
Type type = EMPTY; Type type = EMPTY;
Variant literal;
int start_line = 0, end_line = 0, start_column = 0, end_column = 0; int start_line = 0, end_line = 0, start_column = 0, end_column = 0;
int leftmost_column = 0, rightmost_column = 0; // Column span for multiline tokens. int leftmost_column = 0, rightmost_column = 0; // Column span for multiline tokens.
int cursor_position = -1;
CursorPlace cursor_place = CURSOR_NONE; CursorPlace cursor_place = CURSOR_NONE;
String source; Variant literal;
const char *get_name() const; const char *get_name() const;
bool can_precede_bin_op() const; bool can_precede_bin_op() const;