Merge pull request #108577 from YYF233333/global_class_list
Simplify `ScriptServer::get_global_class_list`
This commit is contained in:
@ -717,11 +717,11 @@ void GDScriptSyntaxHighlighter::_update_cache() {
|
||||
|
||||
/* Engine types. */
|
||||
const Color types_color = EDITOR_GET("text_editor/theme/highlighting/engine_type_color");
|
||||
List<StringName> types;
|
||||
ClassDB::get_class_list(&types);
|
||||
for (const StringName &E : types) {
|
||||
if (ClassDB::is_class_exposed(E)) {
|
||||
class_names[E] = types_color;
|
||||
LocalVector<StringName> types;
|
||||
ClassDB::get_class_list(types);
|
||||
for (const StringName &type : types) {
|
||||
if (ClassDB::is_class_exposed(type)) {
|
||||
class_names[type] = types_color;
|
||||
}
|
||||
}
|
||||
|
||||
@ -734,10 +734,10 @@ void GDScriptSyntaxHighlighter::_update_cache() {
|
||||
|
||||
/* User types. */
|
||||
const Color usertype_color = EDITOR_GET("text_editor/theme/highlighting/user_type_color");
|
||||
List<StringName> global_classes;
|
||||
ScriptServer::get_global_class_list(&global_classes);
|
||||
for (const StringName &E : global_classes) {
|
||||
class_names[E] = usertype_color;
|
||||
LocalVector<StringName> global_classes;
|
||||
ScriptServer::get_global_class_list(global_classes);
|
||||
for (const StringName &class_name : global_classes) {
|
||||
class_names[class_name] = usertype_color;
|
||||
}
|
||||
|
||||
/* Autoloads. */
|
||||
|
||||
@ -2268,14 +2268,14 @@ void GDScriptLanguage::init() {
|
||||
|
||||
//populate native classes
|
||||
|
||||
List<StringName> class_list;
|
||||
ClassDB::get_class_list(&class_list);
|
||||
for (const StringName &n : class_list) {
|
||||
if (globals.has(n)) {
|
||||
LocalVector<StringName> class_list;
|
||||
ClassDB::get_class_list(class_list);
|
||||
for (const StringName &class_name : class_list) {
|
||||
if (globals.has(class_name)) {
|
||||
continue;
|
||||
}
|
||||
Ref<GDScriptNativeClass> nc = memnew(GDScriptNativeClass(n));
|
||||
_add_global(n, nc);
|
||||
Ref<GDScriptNativeClass> nc = memnew(GDScriptNativeClass(class_name));
|
||||
_add_global(class_name, nc);
|
||||
}
|
||||
|
||||
//populate singletons
|
||||
|
||||
@ -958,13 +958,13 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
|
||||
List<StringName> global_script_classes;
|
||||
ScriptServer::get_global_class_list(&global_script_classes);
|
||||
for (const StringName &E : global_script_classes) {
|
||||
if (!ClassDB::is_parent_class(ScriptServer::get_global_class_native_base(E), "Node")) {
|
||||
LocalVector<StringName> global_script_classes;
|
||||
ScriptServer::get_global_class_list(global_script_classes);
|
||||
for (const StringName &class_name : global_script_classes) {
|
||||
if (!ClassDB::is_parent_class(ScriptServer::get_global_class_native_base(class_name), "Node")) {
|
||||
continue;
|
||||
}
|
||||
ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
|
||||
ScriptLanguage::CodeCompletionOption option(class_name, ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
|
||||
option.insert_text = option.display.quote(p_quote_style);
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
@ -1052,11 +1052,11 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completio
|
||||
// Built-in Variant Types
|
||||
_find_built_in_variants(r_result, true);
|
||||
|
||||
List<StringName> native_types;
|
||||
ClassDB::get_class_list(&native_types);
|
||||
for (const StringName &E : native_types) {
|
||||
if (ClassDB::is_class_exposed(E) && !Engine::get_singleton()->has_singleton(E)) {
|
||||
ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
|
||||
LocalVector<StringName> native_types;
|
||||
ClassDB::get_class_list(native_types);
|
||||
for (const StringName &type : native_types) {
|
||||
if (ClassDB::is_class_exposed(type) && !Engine::get_singleton()->has_singleton(type)) {
|
||||
ScriptLanguage::CodeCompletionOption option(type, ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
}
|
||||
@ -1106,10 +1106,10 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completio
|
||||
}
|
||||
|
||||
// Global scripts
|
||||
List<StringName> global_classes;
|
||||
ScriptServer::get_global_class_list(&global_classes);
|
||||
for (const StringName &E : global_classes) {
|
||||
ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_CLASS, ScriptLanguage::LOCATION_OTHER_USER_CODE);
|
||||
LocalVector<StringName> global_classes;
|
||||
ScriptServer::get_global_class_list(global_classes);
|
||||
for (const StringName &class_name : global_classes) {
|
||||
ScriptLanguage::CodeCompletionOption option(class_name, ScriptLanguage::CODE_COMPLETION_KIND_CLASS, ScriptLanguage::LOCATION_OTHER_USER_CODE);
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
|
||||
@ -1629,10 +1629,10 @@ static void _find_identifiers(const GDScriptParser::CompletionContext &p_context
|
||||
_find_global_enums(r_result);
|
||||
|
||||
// Global classes
|
||||
List<StringName> global_classes;
|
||||
ScriptServer::get_global_class_list(&global_classes);
|
||||
for (const StringName &E : global_classes) {
|
||||
ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_CLASS, ScriptLanguage::LOCATION_OTHER_USER_CODE);
|
||||
LocalVector<StringName> global_classes;
|
||||
ScriptServer::get_global_class_list(global_classes);
|
||||
for (const StringName &class_name : global_classes) {
|
||||
ScriptLanguage::CodeCompletionOption option(class_name, ScriptLanguage::CODE_COMPLETION_KIND_CLASS, ScriptLanguage::LOCATION_OTHER_USER_CODE);
|
||||
r_result.insert(option.display, option);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,13 +40,11 @@
|
||||
void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
|
||||
Dictionary classes_dict;
|
||||
|
||||
List<StringName> class_list;
|
||||
ClassDB::get_class_list(&class_list);
|
||||
// Must be alphabetically sorted for hash to compute.
|
||||
class_list.sort_custom<StringName::AlphCompare>();
|
||||
LocalVector<StringName> class_list;
|
||||
ClassDB::get_class_list(class_list);
|
||||
|
||||
for (const StringName &E : class_list) {
|
||||
ClassDB::ClassInfo *t = ClassDB::classes.getptr(E);
|
||||
for (const StringName &class_name : class_list) {
|
||||
ClassDB::ClassInfo *t = ClassDB::classes.getptr(class_name);
|
||||
ERR_FAIL_NULL(t);
|
||||
if (t->api != p_api || !t->exposed) {
|
||||
continue;
|
||||
|
||||
@ -3858,35 +3858,28 @@ struct SortMethodWithHashes {
|
||||
bool BindingsGenerator::_populate_object_type_interfaces() {
|
||||
obj_types.clear();
|
||||
|
||||
List<StringName> class_list;
|
||||
ClassDB::get_class_list(&class_list);
|
||||
class_list.sort_custom<StringName::AlphCompare>();
|
||||
|
||||
while (class_list.size()) {
|
||||
StringName type_cname = class_list.front()->get();
|
||||
LocalVector<StringName> class_list;
|
||||
ClassDB::get_class_list(class_list);
|
||||
|
||||
for (const StringName &type_cname : class_list) {
|
||||
ClassDB::APIType api_type = ClassDB::get_api_type(type_cname);
|
||||
|
||||
if (api_type == ClassDB::API_NONE) {
|
||||
class_list.pop_front();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ignored_types.has(type_cname)) {
|
||||
_log("Ignoring type '%s' because it's in the list of ignored types\n", String(type_cname).utf8().get_data());
|
||||
class_list.pop_front();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!ClassDB::is_class_exposed(type_cname)) {
|
||||
_log("Ignoring type '%s' because it's not exposed\n", String(type_cname).utf8().get_data());
|
||||
class_list.pop_front();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!ClassDB::is_class_enabled(type_cname)) {
|
||||
_log("Ignoring type '%s' because it's not enabled\n", String(type_cname).utf8().get_data());
|
||||
class_list.pop_front();
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -4447,8 +4440,6 @@ bool BindingsGenerator::_populate_object_type_interfaces() {
|
||||
|
||||
obj_types.insert(itype.name + CS_SINGLETON_INSTANCE_SUFFIX, itype);
|
||||
}
|
||||
|
||||
class_list.pop_front();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user