MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _update_warnings

Method _update_warnings

editor/script/script_text_editor.cpp:887–950  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

885}
886
887void ScriptTextEditor::_update_warnings() {
888 int warning_nb = warnings.size();
889 warnings_panel->clear();
890
891 bool has_connections_table = false;
892 // Add missing connections.
893 if (GLOBAL_GET("debug/gdscript/warnings/enable")) {
894 Node *base = get_tree()->get_edited_scene_root();
895 if (base && missing_connections.size() > 0) {
896 has_connections_table = true;
897 warnings_panel->push_table(1);
898 for (const Connection &connection : missing_connections) {
899 String base_path = base->get_name();
900 String source_path = base == connection.signal.get_object() ? base_path : base_path + "/" + String(base->get_path_to(Object::cast_to<Node>(connection.signal.get_object())));
901 String target_path = base == connection.callable.get_object() ? base_path : base_path + "/" + String(base->get_path_to(Object::cast_to<Node>(connection.callable.get_object())));
902
903 warnings_panel->push_cell();
904 warnings_panel->push_color(warnings_panel->get_theme_color(SNAME("warning_color"), EditorStringName(Editor)));
905 warnings_panel->add_text(vformat(TTR("Missing connected method '%s' for signal '%s' from node '%s' to node '%s'."), connection.callable.get_method(), connection.signal.get_name(), source_path, target_path));
906 warnings_panel->pop(); // Color.
907 warnings_panel->pop(); // Cell.
908 }
909 warnings_panel->pop(); // Table.
910
911 warning_nb += missing_connections.size();
912 }
913 }
914
915 code_editor->set_warning_count(warning_nb);
916
917 if (has_connections_table) {
918 warnings_panel->add_newline();
919 }
920
921 // Add script warnings.
922 warnings_panel->push_table(3);
923 for (const ScriptLanguage::Warning &w : warnings) {
924 Dictionary ignore_meta;
925 ignore_meta["line"] = w.start_line;
926 ignore_meta["code"] = w.string_code.to_lower();
927 warnings_panel->push_cell();
928 warnings_panel->push_meta(ignore_meta);
929 warnings_panel->push_color(
930 warnings_panel->get_theme_color(SNAME("accent_color"), EditorStringName(Editor)).lerp(warnings_panel->get_theme_color(SNAME("mono_color"), EditorStringName(Editor)), 0.5f));
931 warnings_panel->add_text(TTR("[Ignore]"));
932 warnings_panel->pop(); // Color.
933 warnings_panel->pop(); // Meta ignore.
934 warnings_panel->pop(); // Cell.
935
936 warnings_panel->push_cell();
937 warnings_panel->push_meta(w.start_line - 1);
938 warnings_panel->push_color(warnings_panel->get_theme_color(SNAME("warning_color"), EditorStringName(Editor)));
939 warnings_panel->add_text(vformat(TTR("Line %d (%s):"), w.start_line, w.string_code));
940 warnings_panel->pop(); // Color.
941 warnings_panel->pop(); // Meta goto.
942 warnings_panel->pop(); // Cell.
943
944 warnings_panel->push_cell();

Callers

nothing calls this directly

Calls 15

vformatFunction · 0.85
TTRFunction · 0.85
push_tableMethod · 0.80
get_path_toMethod · 0.80
push_cellMethod · 0.80
push_colorMethod · 0.80
set_warning_countMethod · 0.80
add_newlineMethod · 0.80
to_lowerMethod · 0.80
push_metaMethod · 0.80
sizeMethod · 0.65
StringClass · 0.50

Tested by

no test coverage detected