Show built-in script names in the debugger

(cherry picked from commit 3b320cd9fe)
This commit is contained in:
kobewi 2021-11-11 19:50:27 +01:00 committed by Rémi Verschelde
parent f83b17e4eb
commit 175870ccc7
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 12 additions and 3 deletions

View File

@ -296,7 +296,7 @@ ScriptInstance *GDScript::instance_create(Object *p_this) {
if (top->native.is_valid()) { if (top->native.is_valid()) {
if (!ClassDB::is_parent_class(p_this->get_class_name(), top->native->get_name())) { if (!ClassDB::is_parent_class(p_this->get_class_name(), top->native->get_name())) {
if (ScriptDebugger::get_singleton()) { if (ScriptDebugger::get_singleton()) {
GDScriptLanguage::get_singleton()->debug_break_parse(get_path(), 1, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'"); GDScriptLanguage::get_singleton()->debug_break_parse(_get_debug_path(), 1, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'");
} }
ERR_FAIL_V_MSG(nullptr, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type '" + p_this->get_class() + "'" + "."); ERR_FAIL_V_MSG(nullptr, "Script inherits from native type '" + String(top->native->get_name()) + "', so it can't be instanced in object of type '" + p_this->get_class() + "'" + ".");
} }
@ -533,6 +533,14 @@ void GDScript::_set_subclass_path(Ref<GDScript> &p_sc, const String &p_path) {
} }
} }
String GDScript::_get_debug_path() const {
if ((get_path().empty() || get_path().find("::") != -1) && !get_name().empty()) {
return get_name() + " (" + get_path().get_slice("::", 0) + ")";
} else {
return get_path();
}
}
Error GDScript::reload(bool p_keep_state) { Error GDScript::reload(bool p_keep_state) {
GDScriptLanguage::singleton->lock.lock(); GDScriptLanguage::singleton->lock.lock();
bool has_instances = instances.size(); bool has_instances = instances.size();
@ -560,7 +568,7 @@ Error GDScript::reload(bool p_keep_state) {
Error err = parser.parse(source, basedir, false, path); Error err = parser.parse(source, basedir, false, path);
if (err) { if (err) {
if (ScriptDebugger::get_singleton()) { if (ScriptDebugger::get_singleton()) {
GDScriptLanguage::get_singleton()->debug_break_parse(get_path(), parser.get_error_line(), "Parser Error: " + parser.get_error()); GDScriptLanguage::get_singleton()->debug_break_parse(_get_debug_path(), parser.get_error_line(), "Parser Error: " + parser.get_error());
} }
_err_print_error("GDScript::reload", path.empty() ? "built-in" : (const char *)path.utf8().get_data(), parser.get_error_line(), ("Parse Error: " + parser.get_error()).utf8().get_data(), ERR_HANDLER_SCRIPT); _err_print_error("GDScript::reload", path.empty() ? "built-in" : (const char *)path.utf8().get_data(), parser.get_error_line(), ("Parse Error: " + parser.get_error()).utf8().get_data(), ERR_HANDLER_SCRIPT);
ERR_FAIL_V(ERR_PARSE_ERROR); ERR_FAIL_V(ERR_PARSE_ERROR);
@ -574,7 +582,7 @@ Error GDScript::reload(bool p_keep_state) {
if (err) { if (err) {
if (can_run) { if (can_run) {
if (ScriptDebugger::get_singleton()) { if (ScriptDebugger::get_singleton()) {
GDScriptLanguage::get_singleton()->debug_break_parse(get_path(), compiler.get_error_line(), "Parser Error: " + compiler.get_error()); GDScriptLanguage::get_singleton()->debug_break_parse(_get_debug_path(), compiler.get_error_line(), "Parser Error: " + compiler.get_error());
} }
_err_print_error("GDScript::reload", path.empty() ? "built-in" : (const char *)path.utf8().get_data(), compiler.get_error_line(), ("Compile Error: " + compiler.get_error()).utf8().get_data(), ERR_HANDLER_SCRIPT); _err_print_error("GDScript::reload", path.empty() ? "built-in" : (const char *)path.utf8().get_data(), compiler.get_error_line(), ("Compile Error: " + compiler.get_error()).utf8().get_data(), ERR_HANDLER_SCRIPT);
ERR_FAIL_V(ERR_COMPILATION_FAILED); ERR_FAIL_V(ERR_COMPILATION_FAILED);

View File

@ -116,6 +116,7 @@ class GDScript : public Script {
GDScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error); GDScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error);
void _set_subclass_path(Ref<GDScript> &p_sc, const String &p_path); void _set_subclass_path(Ref<GDScript> &p_sc, const String &p_path);
String _get_debug_path() const;
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
Set<PlaceHolderScriptInstance *> placeholders; Set<PlaceHolderScriptInstance *> placeholders;