diff --git a/doc/classes/ScriptEditorBase.xml b/doc/classes/ScriptEditorBase.xml
index 68834839f3e..a3fcf532284 100644
--- a/doc/classes/ScriptEditorBase.xml
+++ b/doc/classes/ScriptEditorBase.xml
@@ -35,6 +35,13 @@
Emitted when the user requests a specific documentation page.
+
+
+
+
+ Emitted when the user requests to view a specific method of a script, similar to [signal request_open_script_at_line].
+
+
Emitted after script validation or when the edited resource has changed.
@@ -56,7 +63,7 @@
- Emitted when the user requests a script.
+ Emitted when the user requests to view a specific line of a script, similar to [signal go_to_method].
diff --git a/editor/icons/MethodOverride.svg b/editor/icons/MethodOverride.svg
new file mode 100644
index 00000000000..004b9bf2838
--- /dev/null
+++ b/editor/icons/MethodOverride.svg
@@ -0,0 +1 @@
+
diff --git a/editor/icons/MethodOverrideAndSlot.svg b/editor/icons/MethodOverrideAndSlot.svg
new file mode 100644
index 00000000000..d3bd9f0253b
--- /dev/null
+++ b/editor/icons/MethodOverrideAndSlot.svg
@@ -0,0 +1 @@
+
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 0a111aeb498..9386c17dd51 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -227,6 +227,7 @@ void ScriptEditorBase::_bind_methods() {
// TODO: This signal is no use for VisualScript.
ADD_SIGNAL(MethodInfo("search_in_files_requested", PropertyInfo(Variant::STRING, "text")));
ADD_SIGNAL(MethodInfo("replace_in_files_requested", PropertyInfo(Variant::STRING, "text")));
+ ADD_SIGNAL(MethodInfo("go_to_method", PropertyInfo(Variant::OBJECT, "script"), PropertyInfo(Variant::STRING, "method")));
}
class EditorScriptCodeCompletionCache : public ScriptCodeCompletionCache {
@@ -2380,6 +2381,7 @@ bool ScriptEditor::edit(const Ref &p_resource, int p_line, int p_col,
se->connect("request_save_history", callable_mp(this, &ScriptEditor::_save_history));
se->connect("search_in_files_requested", callable_mp(this, &ScriptEditor::_on_find_in_files_requested));
se->connect("replace_in_files_requested", callable_mp(this, &ScriptEditor::_on_replace_in_files_requested));
+ se->connect("go_to_method", callable_mp(this, &ScriptEditor::script_goto_method));
//test for modification, maybe the script was not edited but was loaded
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 42dcfb8b1f6..a7a5e512f5e 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -956,10 +956,7 @@ void ScriptTextEditor::_update_connected_methods() {
CodeEdit *text_edit = code_editor->get_text_editor();
text_edit->set_gutter_width(connection_gutter, text_edit->get_line_height());
for (int i = 0; i < text_edit->get_line_count(); i++) {
- if (text_edit->get_line_gutter_metadata(i, connection_gutter) == "") {
- continue;
- }
- text_edit->set_line_gutter_metadata(i, connection_gutter, "");
+ text_edit->set_line_gutter_metadata(i, connection_gutter, Dictionary());
text_edit->set_line_gutter_icon(i, connection_gutter, nullptr);
text_edit->set_line_gutter_clickable(i, connection_gutter, false);
}
@@ -974,6 +971,7 @@ void ScriptTextEditor::_update_connected_methods() {
return;
}
+ // Add connection icons to methods.
Vector nodes = _find_all_node_for_script(base, base, script);
HashSet methods_found;
for (int i = 0; i < nodes.size(); i++) {
@@ -1002,8 +1000,11 @@ void ScriptTextEditor::_update_connected_methods() {
for (int j = 0; j < functions.size(); j++) {
String name = functions[j].get_slice(":", 0);
if (name == method) {
+ Dictionary line_meta;
+ line_meta["type"] = "connection";
+ line_meta["method"] = method;
line = functions[j].get_slice(":", 1).to_int() - 1;
- text_edit->set_line_gutter_metadata(line, connection_gutter, method);
+ text_edit->set_line_gutter_metadata(line, connection_gutter, line_meta);
text_edit->set_line_gutter_icon(line, connection_gutter, get_parent_control()->get_theme_icon(SNAME("Slot"), SNAME("EditorIcons")));
text_edit->set_line_gutter_clickable(line, connection_gutter, true);
methods_found.insert(method);
@@ -1033,6 +1034,58 @@ void ScriptTextEditor::_update_connected_methods() {
}
}
}
+
+ // Add override icons to methods.
+ methods_found.clear();
+ for (int i = 0; i < functions.size(); i++) {
+ StringName name = StringName(functions[i].get_slice(":", 0));
+ if (methods_found.has(name)) {
+ continue;
+ }
+
+ String found_base_class;
+ StringName base_class = script->get_instance_base_type();
+ Ref