Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocompletion: Keep get_node values which are compatible with type hint #92263

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions modules/gdscript/gdscript_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2928,11 +2928,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 @@ -2970,6 +2965,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