| 831 | } |
| 832 | |
| 833 | void ScriptTextEditor::_validate_script() { |
| 834 | CodeEdit *te = code_editor->get_text_editor(); |
| 835 | |
| 836 | String text = te->get_text(); |
| 837 | List<String> fnc; |
| 838 | |
| 839 | warnings.clear(); |
| 840 | errors.clear(); |
| 841 | depended_errors.clear(); |
| 842 | safe_lines.clear(); |
| 843 | |
| 844 | if (!script->get_language()->validate(text, script->get_path(), &fnc, &errors, &warnings, &safe_lines)) { |
| 845 | List<ScriptLanguage::ScriptError>::Element *E = errors.front(); |
| 846 | while (E) { |
| 847 | List<ScriptLanguage::ScriptError>::Element *next_E = E->next(); |
| 848 | if ((E->get().path.is_empty() && !script->get_path().is_empty()) || E->get().path != script->get_path()) { |
| 849 | depended_errors[E->get().path].push_back(E->get()); |
| 850 | E->erase(); |
| 851 | } |
| 852 | E = next_E; |
| 853 | } |
| 854 | |
| 855 | if (errors.size() > 0) { |
| 856 | const int line = errors.front()->get().line; |
| 857 | const int column = errors.front()->get().column; |
| 858 | const String message = errors.front()->get().message.replace("[", "[lb]"); |
| 859 | const String error_text = vformat(TTR("Error at ([hint=Line %d, column %d]%d, %d[/hint]):"), line, column, line, column) + " " + message; |
| 860 | code_editor->set_error(error_text); |
| 861 | code_editor->set_error_pos(line - 1, column - 1); |
| 862 | } |
| 863 | script_is_valid = false; |
| 864 | } else { |
| 865 | code_editor->set_error(""); |
| 866 | if (!script->is_tool()) { |
| 867 | script->set_source_code(text); |
| 868 | script->update_exports(); |
| 869 | te->get_syntax_highlighter()->update_cache(); |
| 870 | } |
| 871 | |
| 872 | functions.clear(); |
| 873 | for (const String &E : fnc) { |
| 874 | functions.push_back(E); |
| 875 | } |
| 876 | script_is_valid = true; |
| 877 | } |
| 878 | _update_connected_methods(); |
| 879 | _update_warnings(); |
| 880 | _update_errors(); |
| 881 | _update_background_color(); |
| 882 | |
| 883 | emit_signal(SNAME("name_changed")); |
| 884 | emit_signal(SNAME("edited_script_changed")); |
| 885 | } |
| 886 | |
| 887 | void ScriptTextEditor::_update_warnings() { |
| 888 | int warning_nb = warnings.size(); |
nothing calls this directly
no test coverage detected