Skip to content

Commit bad29ef

Browse files
committed
Merge pull request #107636 from HolonProduction/completion-dont-use-next
Autocompletion: Don't use `next` for `GET_NODE` inference
2 parents e750950 + 49e8d3f commit bad29ef

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

modules/gdscript/gdscript_editor.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3147,8 +3147,21 @@ static bool _get_subscript_type(GDScriptParser::CompletionContext &p_context, co
31473147
}
31483148
} break;
31493149
case GDScriptParser::IdentifierNode::Source::LOCAL_VARIABLE: {
3150-
if (identifier_node->next != nullptr && identifier_node->next->type == GDScriptParser::ClassNode::Node::GET_NODE) {
3151-
get_node = static_cast<GDScriptParser::GetNodeNode *>(identifier_node->next);
3150+
// TODO: Do basic assignment flow analysis like in `_guess_expression_type`.
3151+
const GDScriptParser::SuiteNode::Local local = identifier_node->suite->get_local(identifier_node->name);
3152+
switch (local.type) {
3153+
case GDScriptParser::SuiteNode::Local::CONSTANT: {
3154+
if (local.constant->initializer && local.constant->initializer->type == GDScriptParser::Node::GET_NODE) {
3155+
get_node = static_cast<GDScriptParser::GetNodeNode *>(local.constant->initializer);
3156+
}
3157+
} break;
3158+
case GDScriptParser::SuiteNode::Local::VARIABLE: {
3159+
if (local.variable->initializer && local.variable->initializer->type == GDScriptParser::Node::GET_NODE) {
3160+
get_node = static_cast<GDScriptParser::GetNodeNode *>(local.variable->initializer);
3161+
}
3162+
} break;
3163+
default: {
3164+
} break;
31523165
}
31533166
} break;
31543167
default: {

modules/gdscript/tests/scripts/completion/get_node/local/local.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ extends Node
22

33
func a():
44
var test = $AnimationPlayer
5+
var foo = 10
56
test.➡
67
pass

0 commit comments

Comments
 (0)