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

Improve autocompletion with get_node #79386

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions modules/gdscript/gdscript_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2667,6 +2667,11 @@ static bool _get_subscript_type(GDScriptParser::CompletionContext &p_context, co
if (p_context.base == nullptr) {
return false;
}
if (p_subscript->base->datatype.type_source == GDScriptParser::DataType::ANNOTATED_EXPLICIT) {
// Annotated type takes precedence.
return false;
}

const GDScriptParser::GetNodeNode *get_node = nullptr;

switch (p_subscript->base->type) {
Expand Down Expand Up @@ -2715,10 +2720,19 @@ static bool _get_subscript_type(GDScriptParser::CompletionContext &p_context, co
if (r_base != nullptr) {
*r_base = node;
}
r_base_type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
r_base_type.kind = GDScriptParser::DataType::NATIVE;

r_base_type.type_source = GDScriptParser::DataType::INFERRED;
r_base_type.builtin_type = Variant::OBJECT;
r_base_type.native_type = node->get_class_name();

Ref<Script> scr = node->get_script();
if (scr.is_null()) {
HolonProduction marked this conversation as resolved.
Show resolved Hide resolved
r_base_type.kind = GDScriptParser::DataType::NATIVE;
} else {
r_base_type.kind = GDScriptParser::DataType::SCRIPT;
r_base_type.script_type = scr;
}

return true;
}
}
Expand Down
Loading