Skip to content

Commit 46d88c8

Browse files
committed
Add the concept of GDScriptParser::Node::owner
1 parent cef62c6 commit 46d88c8

File tree

3 files changed

+251
-93
lines changed

3 files changed

+251
-93
lines changed

modules/gdscript/gdscript_editor.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4231,10 +4231,10 @@ static void _refactor_rename_symbol_add_match(const String &p_path, const GDScri
42314231
r_result.add_match(p_path, match);
42324232
}
42334233

4234-
static Error _refactor_rename_symbol_match_from_class_loop_nodes(GDScriptParser::NodeList &p_node_list, const String &p_symbol, const String &p_path, ScriptLanguage::RefactorRenameSymbolResult &r_result, RefactorRenameSymbolDefinintionType p_expected_definition_type, GDScriptParser::Node *p_source_node, LocalVector<GDScriptParser::IdentifierNode::Source> p_target_sources = {}) {
4234+
static Error _refactor_rename_symbol_match_from_class_loop_nodes(LocalVector<GDScriptParser::Node *> &p_nodes, const String &p_symbol, const String &p_path, ScriptLanguage::RefactorRenameSymbolResult &r_result, RefactorRenameSymbolDefinintionType p_expected_definition_type, GDScriptParser::Node *p_source_node, LocalVector<GDScriptParser::IdentifierNode::Source> p_target_sources = {}) {
42354235
ERR_FAIL_NULL_V(p_source_node, FAILED);
42364236

4237-
for (GDScriptParser::Node *node : p_node_list) {
4237+
for (GDScriptParser::Node *node : p_nodes) {
42384238
switch (node->type) {
42394239
case GDScriptParser::Node::Type::IDENTIFIER: {
42404240
GDScriptParser::IdentifierNode *identifier_node = static_cast<GDScriptParser::IdentifierNode *>(node);
@@ -4253,7 +4253,7 @@ static Error _refactor_rename_symbol_match_from_class_loop_nodes(GDScriptParser:
42534253

42544254
// Maybe the identifier is in the definition itself of the source, so it doesn't have any source.
42554255
// Though, it's owner could be the same as the source node.
4256-
GDScriptParser::Node *identifier_node_owner = p_node_list.get_owner(identifier_node);
4256+
GDScriptParser::Node *identifier_node_owner = node->owner;
42574257
if (identifier_node_owner == p_source_node) {
42584258
if (identifier_node_owner->type != GDScriptParser::Node::ENUM) {
42594259
_refactor_rename_symbol_add_match(p_path, identifier_node, r_result);
@@ -4409,8 +4409,9 @@ static Error _refactor_rename_symbol_match_from_class_find_matching_nodes(GDScri
44094409
}
44104410

44114411
// As we found that the match comes from a class, let's find all the matches in that class.
4412-
GDScriptParser::NodeList list(p_class_node);
4413-
return _refactor_rename_symbol_match_from_class_loop_nodes(list, p_symbol, p_path, r_result, p_expected_definition_type, p_source_node, target_sources);
4412+
LocalVector<GDScriptParser::Node *> nodes;
4413+
p_class_node->get_nodes(nodes);
4414+
return _refactor_rename_symbol_match_from_class_loop_nodes(nodes, p_symbol, p_path, r_result, p_expected_definition_type, p_source_node, target_sources);
44144415
}
44154416

44164417
// This function finds and match all instances of the symbol outside the class.
@@ -4487,8 +4488,8 @@ static Error _refactor_rename_symbol_match_from_class_find_matching_nodes_from_s
44874488
continue;
44884489
}
44894490

4490-
GDScriptParser::NodeList node_list(const_cast<GDScriptParser::ClassNode *>(parser.get_head()));
4491-
_refactor_rename_symbol_match_from_class_loop_nodes(node_list, p_symbol, script_path, r_result, p_expected_definition_type, p_source_node);
4491+
LocalVector<GDScriptParser::Node *> nodes;
4492+
_refactor_rename_symbol_match_from_class_loop_nodes(nodes, p_symbol, script_path, r_result, p_expected_definition_type, p_source_node);
44924493
}
44934494

44944495
return OK;

0 commit comments

Comments
 (0)