1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Unify ClassDB lookups for code completion

This commit is contained in:
Pedro J. Estébanez
2018-10-28 01:53:48 +02:00
parent aeddb30fa3
commit f39ea99c08

View File

@@ -1308,37 +1308,33 @@ static bool _guess_identifier_type(const GDScriptCompletionContext &p_context, c
return false; return false;
} }
// Check ClassDB for (int i = 0; i < 2; i++) {
if (ClassDB::class_exists(p_identifier)) { StringName target_id;
r_type.type.has_type = true; switch (i) {
r_type.type.kind = GDScriptParser::DataType::NATIVE; case 0:
r_type.type.native_type = p_identifier; // Check ClassDB
if (Engine::get_singleton()->has_singleton(p_identifier)) { target_id = p_identifier;
r_type.type.is_meta_type = false; break;
r_type.value = Engine::get_singleton()->get_singleton_object(p_identifier); case 1:
} else { // ClassDB again for underscore-prefixed classes
r_type.type.is_meta_type = true; target_id = String("_") + p_identifier;
int idx = GDScriptLanguage::get_singleton()->get_global_map()[p_identifier]; break;
r_type.value = GDScriptLanguage::get_singleton()->get_global_array()[idx];
} }
return true;
}
// ClassDB again for underscore-prefixed classes if (ClassDB::class_exists(target_id)) {
StringName under_id = String("_") + p_identifier; r_type.type.has_type = true;
if (ClassDB::class_exists(under_id)) { r_type.type.kind = GDScriptParser::DataType::NATIVE;
r_type.type.has_type = true; r_type.type.native_type = target_id;
r_type.type.kind = GDScriptParser::DataType::NATIVE; if (Engine::get_singleton()->has_singleton(target_id)) {
r_type.type.native_type = p_identifier; r_type.type.is_meta_type = false;
if (Engine::get_singleton()->has_singleton(p_identifier)) { r_type.value = Engine::get_singleton()->get_singleton_object(target_id);
r_type.type.is_meta_type = false; } else {
r_type.value = Engine::get_singleton()->get_singleton_object(p_identifier); r_type.type.is_meta_type = true;
} else { int idx = GDScriptLanguage::get_singleton()->get_global_map()[target_id];
r_type.type.is_meta_type = true; r_type.value = GDScriptLanguage::get_singleton()->get_global_array()[idx];
int idx = GDScriptLanguage::get_singleton()->get_global_map()[p_identifier]; }
r_type.value = GDScriptLanguage::get_singleton()->get_global_array()[idx]; return true;
} }
return true;
} }
// Check autoload singletons // Check autoload singletons