From 1f42455e0a6f4b708b06500f63e2413d2a218a7e Mon Sep 17 00:00:00 2001 From: HolonProduction Date: Fri, 26 Jan 2024 17:28:13 +0100 Subject: Debugging additions --- modules/gdscript/gdscript.cpp | 16 +++++++++- modules/gdscript/gdscript_cache.cpp | 1 + modules/gdscript/gdscript_compiler.cpp | 13 +++++++++ modules/gdscript/gdscript_editor.cpp | 34 ++++++++++++++++++---- modules/gdscript/register_types.cpp | 1 + .../scripts/completion/get_node/get_node.tscn | 2 +- .../class_member_typehint_scene.gd | 5 ++-- modules/gdscript/tests/test_completion.h | 28 ++++++++++++++++-- 8 files changed, 87 insertions(+), 13 deletions(-) (limited to 'modules') diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 94aa077014..adc8de833a 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -304,13 +304,22 @@ void GDScript::get_script_method_list(List *r_list) const { } void GDScript::_get_script_property_list(List *r_list, bool p_include_base) const { + print_line("GDSCript get_script_property list"); const GDScript *sptr = this; + print_line(this); List props; - while (sptr) { + print_line("while running"); + print_line(sptr->get_source_code()); + print_line(sptr->reloading); + print_line(sptr->member_indices.size()); + print_line(sptr->members.size()); + print_line(sptr->get_members().size()); Vector<_GDScriptMemberSort> msort; for (const KeyValue &E : sptr->member_indices) { + print_line(E.key); if (!sptr->members.has(E.key)) { + print_line("skipping"); continue; // Skip base class members. } _GDScriptMemberSort ms; @@ -330,6 +339,7 @@ void GDScript::_get_script_property_list(List *r_list, bool p_incl #endif // TOOLS_ENABLED for (const PropertyInfo &E : props) { + print_line("pushing_back", E.name); r_list->push_back(E); } @@ -687,6 +697,7 @@ void GDScript::_restore_old_static_data() { #endif Error GDScript::reload(bool p_keep_state) { + print_line("reload", this->get_script_path()); if (reloading) { return OK; } @@ -1016,6 +1027,7 @@ String GDScript::get_script_path() const { } Error GDScript::load_source_code(const String &p_path) { + print_line("load source code", p_path); if (p_path.is_empty() || p_path.begins_with("gdscript://") || ResourceLoader::get_resource_type(p_path.get_slice("::", 0)) == "PackedScene") { return OK; } @@ -2816,6 +2828,7 @@ Ref GDScriptLanguage::get_script_by_fully_qualified_name(const String /*************** RESOURCE ***************/ Ref ResourceFormatLoaderGDScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { + print_line("resource format loader load", p_path); Error err; bool ignoring = p_cache_mode == CACHE_MODE_IGNORE || p_cache_mode == CACHE_MODE_IGNORE_DEEP; Ref scr = GDScriptCache::get_full_script(p_original_path, err, "", ignoring); @@ -2839,6 +2852,7 @@ void ResourceFormatLoaderGDScript::get_recognized_extensions(List *p_ext } bool ResourceFormatLoaderGDScript::handles_type(const String &p_type) const { + print_line("GDScrip resource loader handles", p_type); return (p_type == "Script" || p_type == "GDScript"); } diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp index 7c27127dce..7576be781f 100644 --- a/modules/gdscript/gdscript_cache.cpp +++ b/modules/gdscript/gdscript_cache.cpp @@ -283,6 +283,7 @@ Ref GDScriptCache::get_shallow_script(const String &p_path, Error &r_e } Ref GDScriptCache::get_full_script(const String &p_path, Error &r_error, const String &p_owner, bool p_update_from_disk) { + print_line("get full script", p_path); MutexLock lock(singleton->mutex); if (!p_owner.is_empty()) { diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 13ed66710c..29d73b1977 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -30,6 +30,7 @@ #include "gdscript_compiler.h" +#include "core/string/print_string.h" #include "gdscript.h" #include "gdscript_byte_codegen.h" #include "gdscript_cache.h" @@ -2579,11 +2580,17 @@ Error GDScriptCompiler::_parse_setter_getter(GDScript *p_script, const GDScriptP // RPC info for its base classes first, then for itself, then for inner classes. // Warning: this function cannot initiate compilation of other classes, or it will result in cyclic dependency issues. Error GDScriptCompiler::_prepare_compilation(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state) { + print_line("prepare compilation", p_script->get_script_path()); + print_line(p_script->get_source_code()); + //print_line(p_class->extends[0]); + print_line(p_class->members.size()); if (parsed_classes.has(p_script)) { + print_line("already parsed"); return OK; } if (parsing_classes.has(p_script)) { + print_line("already parsing"); String class_name = p_class->identifier ? String(p_class->identifier->name) : p_class->fqcn; _set_error(vformat(R"(Cyclic class reference for "%s".)", class_name), p_class); return ERR_PARSE_ERROR; @@ -2712,8 +2719,11 @@ Error GDScriptCompiler::_prepare_compilation(GDScript *p_script, const GDScriptP for (int i = 0; i < p_class->members.size(); i++) { const GDScriptParser::ClassNode::Member &member = p_class->members[i]; + print_line(member.get_name()); + print_line(member.type); switch (member.type) { case GDScriptParser::ClassNode::Member::VARIABLE: { + print_line("variable"); const GDScriptParser::VariableNode *variable = member.variable; StringName name = variable->identifier->name; @@ -2756,9 +2766,11 @@ Error GDScriptCompiler::_prepare_compilation(GDScript *p_script, const GDScriptP minfo.property_info = prop_info; if (variable->is_static) { + print_line("static"); minfo.index = p_script->static_variables_indices.size(); p_script->static_variables_indices[name] = minfo; } else { + print_line("inserting"); minfo.index = p_script->member_indices.size(); p_script->member_indices[name] = minfo; p_script->members.insert(name); @@ -3174,6 +3186,7 @@ void GDScriptCompiler::_get_function_ptr_replacements(HashMapget_script_path()); err_line = -1; err_column = -1; error = ""; diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index bc3d82062d..b3b628af34 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ +#include "core/string/print_string.h" #include "gdscript.h" #include "gdscript_analyzer.h" @@ -1128,15 +1129,9 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base print_line("identifier script"); Ref