Skip to content

Commit 4213a9d

Browse files
committed
Remove literal as refactor context
1 parent 34718ef commit 4213a9d

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

modules/gdscript/gdscript_editor.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4795,10 +4795,6 @@ ::Error GDScriptLanguage::refactor_rename_symbol_code(const String &p_code, cons
47954795
bool is_function = false;
47964796

47974797
switch (context.type) {
4798-
case GDScriptParser::REFACTOR_RENAME_TYPE_LITERAL: {
4799-
REFACTOR_RENAME_OUTSIDE_GDSCRIPT(REFACTOR_RENAME_SYMBOL_RESULT_LITERAL);
4800-
REFACTOR_RENAME_RETURN(OK);
4801-
} break;
48024798
case GDScriptParser::REFACTOR_RENAME_TYPE_BUILT_IN_TYPE_CONSTANT_OR_STATIC_METHOD: {
48034799
REFACTOR_RENAME_OUTSIDE_GDSCRIPT(REFACTOR_RENAME_SYMBOL_RESULT_CLASS_CONSTANT);
48044800
REFACTOR_RENAME_RETURN(OK);

modules/gdscript/gdscript_parser.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -443,23 +443,26 @@ bool GDScriptParser::refactor_rename_register(GDScriptParser::RefactorRenameType
443443
context.current_line = tokenizer->get_cursor_line();
444444
context.parser = this;
445445
context.node = p_node;
446-
context.identifier = nullptr;
446+
context.value = nullptr;
447447
if (previous.has_cursor()) {
448448
context.token = previous;
449449
}
450450
refactor_rename_context = context;
451451
return true;
452452
}
453453

454-
bool GDScriptParser::refactor_rename_register_identifier(GDScriptParser::IdentifierNode *p_identifier) {
454+
bool GDScriptParser::refactor_rename_register_value(GDScriptParser::Node *p_value_node) {
455455
if (!is_for_refactor_rename()) {
456456
return false;
457457
}
458458
if (!previous.has_cursor()) {
459459
return false;
460460
}
461461
ERR_FAIL_NULL_V(refactor_rename_context.node, false);
462-
refactor_rename_context.identifier = p_identifier;
462+
refactor_rename_context.value = p_value_node;
463+
if (previous.has_cursor()) {
464+
refactor_rename_context.token = previous;
465+
}
463466
return true;
464467
}
465468

@@ -2855,7 +2858,7 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_identifier(ExpressionNode
28552858
ERR_FAIL_V_MSG(nullptr, "Parser bug: parsing identifier node without identifier token.");
28562859
}
28572860
IdentifierNode *identifier = alloc_node<IdentifierNode>();
2858-
refactor_rename_register_identifier(identifier);
2861+
refactor_rename_register_value(identifier);
28592862
complete_extents(identifier);
28602863

28612864
identifier->name = previous.get_identifier();
@@ -2913,7 +2916,7 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_literal(ExpressionNode *p_
29132916
}
29142917

29152918
LiteralNode *literal = alloc_node<LiteralNode>();
2916-
refactor_rename_register(REFACTOR_RENAME_TYPE_LITERAL, literal);
2919+
refactor_rename_register_value(literal);
29172920
literal->value = previous.literal;
29182921
reset_extents(literal, p_previous_operand);
29192922
update_extents(literal);
@@ -3268,13 +3271,14 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_assignment(ExpressionNode
32683271

32693272
GDScriptParser::ExpressionNode *GDScriptParser::parse_await(ExpressionNode *p_previous_operand, bool p_can_assign) {
32703273
AwaitNode *await = alloc_node<AwaitNode>();
3271-
// TODO: refactor take token into account.
3274+
refactor_rename_register(REFACTOR_RENAME_TYPE_KEYWORD, await);
32723275
ExpressionNode *element = parse_precedence(PREC_AWAIT, false);
32733276
if (element == nullptr) {
32743277
push_error(R"(Expected signal or coroutine after "await".)");
32753278
}
32763279
await->to_await = element;
32773280
complete_extents(await);
3281+
refactor_rename_register(REFACTOR_RENAME_TYPE_KEYWORD, await);
32783282

32793283
if (current_function) { // Might be null in a getter or setter.
32803284
current_function->is_coroutine = true;

modules/gdscript/gdscript_parser.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,12 +1795,11 @@ class GDScriptParser {
17951795
REFACTOR_RENAME_TYPE_TYPE_ATTRIBUTE, // Attribute in type name (Type.|).
17961796
REFACTOR_RENAME_TYPE_TYPE_NAME, // Name of type (after :).
17971797
REFACTOR_RENAME_TYPE_TYPE_NAME_OR_VOID, // Same as TYPE_NAME, but allows void (in function return type).
1798-
REFACTOR_RENAME_TYPE_LITERAL, // Declared literal (e.g. variable name).
17991798
};
18001799

18011800
struct RefactorRenameContext : ParsingContext {
18021801
RefactorRenameType type = REFACTOR_RENAME_TYPE_NONE;
1803-
GDScriptParser::IdentifierNode *identifier = nullptr;
1802+
GDScriptParser::Node *value = nullptr;
18041803
GDScriptTokenizer::Token token;
18051804
};
18061805

@@ -1986,7 +1985,7 @@ class GDScriptParser {
19861985
bool refactor_rename_was_cursor_just_parsed() const;
19871986
bool refactor_rename_is_node_more_specific(const GDScriptParser::Node *p_node) const;
19881987
bool refactor_rename_register(GDScriptParser::RefactorRenameType p_type, GDScriptParser::Node *p_node);
1989-
bool refactor_rename_register_identifier(GDScriptParser::IdentifierNode *p_node);
1988+
bool refactor_rename_register_value(GDScriptParser::Node *p_node);
19901989

19911990
GDScriptTokenizer::Token advance();
19921991
bool match(GDScriptTokenizer::Token::Type p_token_type);

0 commit comments

Comments
 (0)