1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-08 12:40:44 +00:00

Improve autocompletion with get_node

(cherry picked from commit c8889a7fe7)
This commit is contained in:
HolonProduction
2023-07-12 19:27:21 +02:00
committed by Rémi Verschelde
parent 0ba32ac384
commit 6f8cc1b8de

View File

@@ -2676,6 +2676,11 @@ static bool _get_subscript_type(GDScriptParser::CompletionContext &p_context, co
if (p_context.base == nullptr) { if (p_context.base == nullptr) {
return false; 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; const GDScriptParser::GetNodeNode *get_node = nullptr;
switch (p_subscript->base->type) { switch (p_subscript->base->type) {
@@ -2724,10 +2729,19 @@ static bool _get_subscript_type(GDScriptParser::CompletionContext &p_context, co
if (r_base != nullptr) { if (r_base != nullptr) {
*r_base = node; *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.builtin_type = Variant::OBJECT;
r_base_type.native_type = node->get_class_name(); r_base_type.native_type = node->get_class_name();
Ref<Script> 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; return true;
} }
} }