Skip to content

Commit

Permalink
Autocompletion: Keep get_node values which are compatible with type hint
Browse files Browse the repository at this point in the history
  • Loading branch information
HolonProduction committed Jul 12, 2024
1 parent 26d1577 commit 9a84387
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions modules/gdscript/gdscript_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2971,11 +2971,6 @@ static bool _get_subscript_type(GDScriptParser::CompletionContext &p_context, co
} break;

case GDScriptParser::Node::IDENTIFIER: {
if (p_subscript->base->datatype.type_source == GDScriptParser::DataType::ANNOTATED_EXPLICIT) {
// Annotated type takes precedence.
return false;
}

const GDScriptParser::IdentifierNode *identifier_node = static_cast<GDScriptParser::IdentifierNode *>(p_subscript->base);

switch (identifier_node->source) {
Expand Down Expand Up @@ -3013,6 +3008,14 @@ static bool _get_subscript_type(GDScriptParser::CompletionContext &p_context, co
if (get_node != nullptr) {
const Object *node = p_context.base->call("get_node_or_null", NodePath(get_node->full_path));
if (node != nullptr) {
GDScriptParser::DataType assigned_type = _type_from_variant(node, p_context).type;
GDScriptParser::DataType base_type = p_subscript->base->datatype;

if (p_subscript->base->type == GDScriptParser::Node::IDENTIFIER && base_type.type_source == GDScriptParser::DataType::ANNOTATED_EXPLICIT && (assigned_type.kind != base_type.kind || assigned_type.script_path != base_type.script_path || assigned_type.native_type != base_type.native_type)) {
// Annotated type takes precedence.
return false;
}

if (r_base != nullptr) {
*r_base = node;
}
Expand Down

0 comments on commit 9a84387

Please sign in to comment.