From 810fcc74318a4fcb12997d20d3738cd5e349430c Mon Sep 17 00:00:00 2001 From: baptr <1522777+baptr@users.noreply.github.com> Date: Sun, 26 Feb 2023 19:42:55 -0800 Subject: [PATCH] Fix gdscript analyzer error when instantiating EditorPlugins. Editor code is not instantiable outside of the editor (https://github.com/godotengine/godot/blob/1d14c054a12dacdc193b589e4afb0ef319ee2aae/core/object/class_db.cpp#L369). This is fine for editor plugins and the like, but the GDScript analyzer balks at it, causing F5 runs to fail: #73525. Instead, we really just want to know if the type is abstract - so add a new ClassDB method to check that and nothing else. Update core/object/class_db.cpp Apply code review comments Co-Authored-By: Bryce <1522777+baptr@users.noreply.github.com> --- core/object/class_db.cpp | 15 +++++++++++++++ core/object/class_db.h | 1 + modules/gdscript/gdscript_analyzer.cpp | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index fe4345aa0d94..cca83b514d61 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -671,6 +671,21 @@ bool ClassDB::can_instantiate(const StringName &p_class) { return (!ti->disabled && ti->creation_func != nullptr && !(ti->gdextension && !ti->gdextension->create_instance)); } +bool ClassDB::is_abstract(const StringName &p_class) { + OBJTYPE_RLOCK; + + ClassInfo *ti = classes.getptr(p_class); + if (!ti) { + if (!ScriptServer::is_global_class(p_class)) { + ERR_FAIL_V_MSG(false, "Cannot get class '" + String(p_class) + "'."); + } + String path = ScriptServer::get_global_class_path(p_class); + Ref