Godot Engine – Multi-platform 2D and 3D game engine
Script Editor: Make override indicators for inner class methods be relative to their parent class
Malcolm Anderson94dc8be1acbd
diff --git a/editor/script/script_text_editor.cpp b/editor/script/script_text_editor.cppindex e435924b611..44bead2eb85 100644--- a/editor/script/script_text_editor.cpp+++ b/editor/script/script_text_editor.cpp@@ -1616,16 +1616,36 @@ void ScriptTextEditor::_update_connected_methods() {continue;}+ StringName base_class = script->get_instance_base_type();+ Ref<Script> inherited_script = script->get_base_script();+// Account for inner classes by stripping the class names from the method,// starting from the right since our inner class might be inside of another inner class.+ // We then iterate down the inner class "path" to ensure we're checking the correct+ // base class for methods to mark as overridden.+ String found_base_class;int pos = raw_name.rfind_char('.');if (pos != -1) {name = raw_name.substr(pos + 1);++ // We start with the main script class, and work through inner classes+ // until we get to the inner class that is extending a type including+ // overriding methods.+ Ref<Script> current_inner_class_script = script;+ for (const String ¤t_inner_class_name : raw_name.substr(0, pos).split(".")) {+ HashMap<StringName, Variant> consts;+ current_inner_class_script->get_constants(&consts);++ if (consts.has(current_inner_class_name)) {+ current_inner_class_script = consts.get(current_inner_class_name);+ } else {+ break;+ }+ }+ base_class = current_inner_class_script->get_instance_base_type();+ inherited_script = current_inner_class_script->get_base_script();}- String found_base_class;- StringName base_class = script->get_instance_base_type();- Ref<Script> inherited_script = script->get_base_script();while (inherited_script.is_valid()) {if (inherited_script->has_method(name)) {found_base_class = "script:" + inherited_script->get_path();