mirror of
https://github.com/godotengine/godot.git
synced 2025-01-30 21:33:18 +08:00
Merge pull request #70002 from poohcom1/fix/static-subscript-autocomplete
Fix code-completion suggesting non-static members for custom classes
This commit is contained in:
commit
9d16250353
@ -977,7 +977,7 @@ static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class,
|
||||
}
|
||||
break;
|
||||
case GDScriptParser::ClassNode::Member::SIGNAL:
|
||||
if (p_only_functions || outer) {
|
||||
if (p_only_functions || outer || p_static) {
|
||||
continue;
|
||||
}
|
||||
option = ScriptLanguage::CodeCompletionOption(member.signal->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location);
|
||||
@ -1033,6 +1033,14 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
|
||||
ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER, location);
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
|
||||
List<MethodInfo> signals;
|
||||
scr->get_script_signal_list(&signals);
|
||||
for (const MethodInfo &E : signals) {
|
||||
int location = p_recursion_depth + _get_signal_location(scr->get_class_name(), E.name);
|
||||
ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location);
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
}
|
||||
HashMap<StringName, Variant> constants;
|
||||
scr->get_constants(&constants);
|
||||
@ -1041,14 +1049,6 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
|
||||
ScriptLanguage::CodeCompletionOption option(E.key.operator String(), ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT, location);
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
|
||||
List<MethodInfo> signals;
|
||||
scr->get_script_signal_list(&signals);
|
||||
for (const MethodInfo &E : signals) {
|
||||
int location = p_recursion_depth + _get_signal_location(scr->get_class_name(), E.name);
|
||||
ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location);
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
}
|
||||
|
||||
List<MethodInfo> methods;
|
||||
@ -1093,14 +1093,6 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
|
||||
List<MethodInfo> signals;
|
||||
ClassDB::get_signal_list(type, &signals);
|
||||
for (const MethodInfo &E : signals) {
|
||||
int location = p_recursion_depth + _get_signal_location(type, StringName(E.name));
|
||||
ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location);
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
|
||||
if (!base_type.is_meta_type || Engine::get_singleton()->has_singleton(type)) {
|
||||
List<PropertyInfo> pinfo;
|
||||
ClassDB::get_property_list(type, &pinfo);
|
||||
@ -1115,6 +1107,14 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
|
||||
ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER, location);
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
|
||||
List<MethodInfo> signals;
|
||||
ClassDB::get_signal_list(type, &signals);
|
||||
for (const MethodInfo &E : signals) {
|
||||
int location = p_recursion_depth + _get_signal_location(type, StringName(E.name));
|
||||
ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location);
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2031,6 +2031,7 @@ static bool _guess_identifier_type(GDScriptParser::CompletionContext &p_context,
|
||||
r_type.type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
|
||||
r_type.type.script_path = script;
|
||||
r_type.type.class_type = parser->get_parser()->get_tree();
|
||||
r_type.type.is_meta_type = true;
|
||||
r_type.type.is_constant = false;
|
||||
r_type.type.kind = GDScriptParser::DataType::CLASS;
|
||||
r_type.value = Variant();
|
||||
@ -2142,6 +2143,7 @@ static bool _guess_identifier_type_from_base(GDScriptParser::CompletionContext &
|
||||
r_type.type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
|
||||
r_type.type.kind = GDScriptParser::DataType::CLASS;
|
||||
r_type.type.class_type = member.m_class;
|
||||
r_type.type.is_meta_type = true;
|
||||
return true;
|
||||
case GDScriptParser::ClassNode::Member::GROUP:
|
||||
return false; // No-op, but silences warnings.
|
||||
|
Loading…
Reference in New Issue
Block a user