From 462d8f47521d3406a7ee8b5b024699112c4337aa Mon Sep 17 00:00:00 2001 From: Danil Alexeev Date: Mon, 28 Aug 2023 19:20:10 +0300 Subject: [PATCH] GDScript: Fix `get_*_list()` methods return incorrect info --- modules/gdscript/editor/gdscript_docgen.cpp | 9 +- modules/gdscript/gdscript.cpp | 127 ++++-------- modules/gdscript/gdscript.h | 14 +- modules/gdscript/gdscript_analyzer.cpp | 10 +- modules/gdscript/gdscript_byte_codegen.cpp | 3 - modules/gdscript/gdscript_compiler.cpp | 49 ++--- modules/gdscript/gdscript_function.cpp | 36 ---- modules/gdscript/gdscript_function.h | 188 ++++++------------ modules/gdscript/gdscript_parser.cpp | 100 ++++++++++ modules/gdscript/gdscript_parser.h | 9 +- .../gdscript/gdscript_utility_functions.cpp | 2 +- modules/gdscript/gdscript_vm.cpp | 8 +- .../scripts/runtime/features/member_info.gd | 125 ++++++++++++ .../scripts/runtime/features/member_info.out | 45 +++++ modules/gdscript/tests/test_gdscript.cpp | 9 +- 15 files changed, 429 insertions(+), 305 deletions(-) create mode 100644 modules/gdscript/tests/scripts/runtime/features/member_info.gd create mode 100644 modules/gdscript/tests/scripts/runtime/features/member_info.out diff --git a/modules/gdscript/editor/gdscript_docgen.cpp b/modules/gdscript/editor/gdscript_docgen.cpp index 1aecfc6de1b..0b440274c05 100644 --- a/modules/gdscript/editor/gdscript_docgen.cpp +++ b/modules/gdscript/editor/gdscript_docgen.cpp @@ -87,7 +87,7 @@ static void _doctype_from_gdtype(const GDType &p_gdtype, String &r_type, String case GDType::SCRIPT: if (p_gdtype.script_type.is_valid()) { if (p_gdtype.script_type->get_global_name() != StringName()) { - r_type = _get_script_path(p_gdtype.script_type->get_global_name()); + r_type = p_gdtype.script_type->get_global_name(); return; } if (!p_gdtype.script_type->get_path().is_empty()) { @@ -129,10 +129,10 @@ void GDScriptDocGen::generate_docs(GDScript *p_script, const GDP::ClassNode *p_c DocData::ClassDoc &doc = p_script->doc; doc.script_path = _get_script_path(p_script->get_script_path()); - if (p_script->name.is_empty()) { + if (p_script->local_name == StringName()) { doc.name = doc.script_path; } else { - doc.name = p_script->name; + doc.name = p_script->local_name; } if (p_script->_owner) { @@ -204,6 +204,9 @@ void GDScriptDocGen::generate_docs(GDScript *p_script, const GDP::ClassNode *p_c if (m_func->return_type) { _doctype_from_gdtype(m_func->return_type->get_datatype(), method_doc.return_type, method_doc.return_enum, true); + } else if (!m_func->body->has_return) { + // If no `return` statement, then return type is `void`, not `Variant`. + method_doc.return_type = "void"; } else { method_doc.return_type = "Variant"; } diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index ccbcb3ee96e..114c04a38fb 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -254,7 +254,7 @@ Ref