Skip to content

Commit

Permalink
Improve autocompletion with get_node
Browse files Browse the repository at this point in the history
  • Loading branch information
HolonProduction committed Jul 12, 2023
1 parent ef155c1 commit 3e63545
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions modules/gdscript/gdscript_editor.cpp
Expand Up @@ -2597,6 +2597,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 @@ -2645,10 +2650,16 @@ 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.native_type = node->get_class_name();
r_base_type.builtin_type = Variant::OBJECT;
Ref<GDScript> scr = node->get_script();
if (scr.is_null()) {
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

0 comments on commit 3e63545

Please sign in to comment.