| 151 | } |
| 152 | |
| 153 | bool GDScriptLanguage::validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors, List<ScriptLanguage::Warning> *r_warnings, HashSet<int> *r_safe_lines) const { |
| 154 | GDScriptParser parser; |
| 155 | GDScriptAnalyzer analyzer(&parser); |
| 156 | |
| 157 | Error err = parser.parse(p_script, p_path, false); |
| 158 | if (err == OK) { |
| 159 | err = analyzer.analyze(); |
| 160 | } |
| 161 | #ifdef DEBUG_ENABLED |
| 162 | if (r_warnings) { |
| 163 | for (const GDScriptWarning &E : parser.get_warnings()) { |
| 164 | const GDScriptWarning &warn = E; |
| 165 | ScriptLanguage::Warning w; |
| 166 | w.start_line = warn.start_line; |
| 167 | w.end_line = warn.end_line; |
| 168 | w.code = (int)warn.code; |
| 169 | w.string_code = GDScriptWarning::get_name_from_code(warn.code); |
| 170 | w.message = warn.get_message(); |
| 171 | r_warnings->push_back(w); |
| 172 | } |
| 173 | } |
| 174 | #endif |
| 175 | if (err) { |
| 176 | if (r_errors) { |
| 177 | for (const GDScriptParser::ParserError &pe : parser.get_errors()) { |
| 178 | ScriptLanguage::ScriptError e; |
| 179 | e.path = p_path; |
| 180 | e.line = pe.line; |
| 181 | e.column = pe.column; |
| 182 | e.message = pe.message; |
| 183 | r_errors->push_back(e); |
| 184 | } |
| 185 | |
| 186 | for (KeyValue<String, Ref<GDScriptParserRef>> E : parser.get_depended_parsers()) { |
| 187 | GDScriptParser *depended_parser = E.value->get_parser(); |
| 188 | for (const GDScriptParser::ParserError &pe : depended_parser->get_errors()) { |
| 189 | ScriptLanguage::ScriptError e; |
| 190 | e.path = E.key; |
| 191 | e.line = pe.line; |
| 192 | e.column = pe.column; |
| 193 | e.message = pe.message; |
| 194 | r_errors->push_back(e); |
| 195 | } |
| 196 | } |
| 197 | } |
| 198 | return false; |
| 199 | } else if (r_functions) { |
| 200 | const GDScriptParser::ClassNode *cl = parser.get_tree(); |
| 201 | HashMap<int, String> funcs; |
| 202 | |
| 203 | get_function_names_recursively(cl, "", funcs); |
| 204 | |
| 205 | for (const KeyValue<int, String> &E : funcs) { |
| 206 | r_functions->push_back(E.value + ":" + itos(E.key)); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | #ifdef DEBUG_ENABLED |
no test coverage detected