From 76b2d85c9fb10426fad78a8d2dbafd8ca08a4b89 Mon Sep 17 00:00:00 2001 From: Danil Alexeev Date: Mon, 15 Apr 2024 22:10:47 +0300 Subject: [PATCH] GDScript: Fix some export annotation issues --- editor/editor_help.cpp | 2 +- modules/gdscript/doc_classes/@GDScript.xml | 3 +- modules/gdscript/gdscript_editor.cpp | 23 +++ modules/gdscript/gdscript_parser.cpp | 43 ++++-- modules/gdscript/gdscript_parser.h | 1 + .../features/export_enum_as_dictionary.out | 10 +- .../scripts/parser/features/annotations.out | 24 +-- .../scripts/parser/features/export_arrays.out | 138 +++++++++--------- .../scripts/parser/features/export_enum.out | 40 ++--- .../parser/features/export_variable.gd | 34 ++++- .../parser/features/export_variable.out | 60 +++++--- ...group_no_name_conflict_with_properties.out | 6 +- .../gdscript/tests/scripts/utils.notest.gd | 15 +- 13 files changed, 249 insertions(+), 150 deletions(-) diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index d0ad0e8b1150..b497f23d216b 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -1967,7 +1967,7 @@ void EditorHelp::_update_doc() { class_desc->add_text(argument.name); class_desc->add_text(": "); - _add_type(argument.type); + _add_type(argument.type, argument.enumeration, argument.is_bitfield); if (!argument.default_value.is_empty()) { class_desc->push_color(theme_cache.symbol_color); diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 07d917ea0479..1909ca5ab520 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -349,10 +349,11 @@ - Allows you to set a custom hint, hint string, and usage flags for the exported property. Note that there's no validation done in GDScript, it will just pass the hint along to the editor. + Allows you to set a custom hint, hint string, and usage flags for the exported property. Note that there's no validation done in GDScript, it will just pass the parameters to the editor. [codeblock] @export_custom(PROPERTY_HINT_NONE, "suffix:m") var suffix: Vector3 [/codeblock] + [b]Note:[/b] Regardless of the [param usage] value, the [constant PROPERTY_USAGE_SCRIPT_VARIABLE] flag is always added, as with any explicitly declared script variable. diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index cae85d7c701c..cacdb1df7f39 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -911,6 +911,29 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a option.insert_text = option.display.quote(p_quote_style); r_result.insert(option.display, option); } + } else if (p_annotation->name == SNAME("@export_custom")) { + switch (p_argument) { + case 0: { + static HashMap items; + if (unlikely(items.is_empty())) { + CoreConstants::get_enum_values(SNAME("PropertyHint"), &items); + } + for (const KeyValue &item : items) { + ScriptLanguage::CodeCompletionOption option(item.key, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT); + r_result.insert(option.display, option); + } + } break; + case 2: { + static HashMap items; + if (unlikely(items.is_empty())) { + CoreConstants::get_enum_values(SNAME("PropertyUsageFlags"), &items); + } + for (const KeyValue &item : items) { + ScriptLanguage::CodeCompletionOption option(item.key, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT); + r_result.insert(option.display, option); + } + } break; + } } else if (p_annotation->name == SNAME("@warning_ignore")) { for (int warning_code = 0; warning_code < GDScriptWarning::WARNING_MAX; warning_code++) { ScriptLanguage::CodeCompletionOption warning(GDScriptWarning::get_name_from_code((GDScriptWarning::Code)warning_code).to_lower(), ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 9be9307b8a41..e4640d24a329 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -101,7 +101,6 @@ GDScriptParser::GDScriptParser() { register_annotation(MethodInfo("@onready"), AnnotationInfo::VARIABLE, &GDScriptParser::onready_annotation); // Export annotations. register_annotation(MethodInfo("@export"), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations); - register_annotation(MethodInfo("@export_storage"), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations); register_annotation(MethodInfo("@export_enum", PropertyInfo(Variant::STRING, "names")), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations, varray(), true); register_annotation(MethodInfo("@export_file", PropertyInfo(Variant::STRING, "filter")), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations, varray(""), true); register_annotation(MethodInfo("@export_dir"), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations); @@ -121,6 +120,7 @@ GDScriptParser::GDScriptParser() { register_annotation(MethodInfo("@export_flags_3d_physics"), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations); register_annotation(MethodInfo("@export_flags_3d_navigation"), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations); register_annotation(MethodInfo("@export_flags_avoidance"), AnnotationInfo::VARIABLE, &GDScriptParser::export_annotations); + register_annotation(MethodInfo("@export_storage"), AnnotationInfo::VARIABLE, &GDScriptParser::export_storage_annotation); register_annotation(MethodInfo("@export_custom", PropertyInfo(Variant::INT, "hint", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_CLASS_IS_ENUM, "PropertyHint"), PropertyInfo(Variant::STRING, "hint_string"), PropertyInfo(Variant::INT, "usage", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_CLASS_IS_BITFIELD, "PropertyUsageFlags")), AnnotationInfo::VARIABLE, &GDScriptParser::export_custom_annotation, varray(PROPERTY_USAGE_DEFAULT)); // Export grouping annotations. register_annotation(MethodInfo("@export_category", PropertyInfo(Variant::STRING, "name")), AnnotationInfo::STANDALONE, &GDScriptParser::export_group_annotations); @@ -4295,7 +4295,7 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node case GDScriptParser::DataType::BUILTIN: variable->export_info.type = export_type.builtin_type; variable->export_info.hint = PROPERTY_HINT_NONE; - variable->export_info.hint_string = Variant::get_type_name(export_type.builtin_type); + variable->export_info.hint_string = String(); break; case GDScriptParser::DataType::NATIVE: if (ClassDB::is_parent_class(export_type.native_type, SNAME("Resource"))) { @@ -4396,12 +4396,6 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node push_error(_get_annotation_error_string(p_annotation->name, expected_types, variable->get_datatype()), p_annotation); return false; } - } else if (p_annotation->name == SNAME("@export_storage")) { - use_default_variable_type_check = false; // Can be applied to a variable of any type. - - // Save the info because the compiler uses export info for overwriting member info. - variable->export_info = export_type.to_property_info(variable->identifier->name); - variable->export_info.usage |= PROPERTY_USAGE_STORAGE; } if (use_default_variable_type_check) { @@ -4421,11 +4415,38 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node if (variable->export_info.hint) { hint_prefix += "/" + itos(variable->export_info.hint); } + variable->export_info.type = original_export_type_builtin; variable->export_info.hint = PROPERTY_HINT_TYPE_STRING; variable->export_info.hint_string = hint_prefix + ":" + variable->export_info.hint_string; - variable->export_info.type = original_export_type_builtin; + variable->export_info.usage = PROPERTY_USAGE_DEFAULT; + variable->export_info.class_name = StringName(); + } + + return true; +} + +// For `@export_storage` and `@export_custom`, there is no need to check the variable type, argument values, +// or handle array exports in a special way, so they are implemented as separate methods. + +bool GDScriptParser::export_storage_annotation(const AnnotationNode *p_annotation, Node *p_node, ClassNode *p_class) { + ERR_FAIL_COND_V_MSG(p_node->type != Node::VARIABLE, false, vformat(R"("%s" annotation can only be applied to variables.)", p_annotation->name)); + + VariableNode *variable = static_cast(p_node); + if (variable->is_static) { + push_error(vformat(R"(Annotation "%s" cannot be applied to a static variable.)", p_annotation->name), p_annotation); + return false; + } + if (variable->exported) { + push_error(vformat(R"(Annotation "%s" cannot be used with another "@export" annotation.)", p_annotation->name), p_annotation); + return false; } + variable->exported = true; + + // Save the info because the compiler uses export info for overwriting member info. + variable->export_info = variable->get_datatype().to_property_info(variable->identifier->name); + variable->export_info.usage |= PROPERTY_USAGE_STORAGE; + return true; } @@ -4434,6 +4455,10 @@ bool GDScriptParser::export_custom_annotation(const AnnotationNode *p_annotation ERR_FAIL_COND_V_MSG(p_annotation->resolved_arguments.size() < 2, false, R"(Annotation "@export_custom" requires 2 arguments.)"); VariableNode *variable = static_cast(p_node); + if (variable->is_static) { + push_error(vformat(R"(Annotation "%s" cannot be applied to a static variable.)", p_annotation->name), p_annotation); + return false; + } if (variable->exported) { push_error(vformat(R"(Annotation "%s" cannot be used with another "@export" annotation.)", p_annotation->name), p_annotation); return false; diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index 1e67e2d496a5..f2e5007755db 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -1499,6 +1499,7 @@ class GDScriptParser { bool onready_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class); template bool export_annotations(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class); + bool export_storage_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class); bool export_custom_annotation(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class); template bool export_group_annotations(const AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class); diff --git a/modules/gdscript/tests/scripts/analyzer/features/export_enum_as_dictionary.out b/modules/gdscript/tests/scripts/analyzer/features/export_enum_as_dictionary.out index 505af5f1f397..0d96f8c02153 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/export_enum_as_dictionary.out +++ b/modules/gdscript/tests/scripts/analyzer/features/export_enum_as_dictionary.out @@ -1,11 +1,11 @@ GDTEST_OK var test_1: Dictionary - hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_2: TestExportEnumAsDictionary.MyEnum - hint=ENUM hint_string="A:0,B:1,C:2" usage=DEFAULT|SCRIPT_VARIABLE|CLASS_IS_ENUM + hint=ENUM hint_string="A:0,B:1,C:2" usage=DEFAULT|SCRIPT_VARIABLE|CLASS_IS_ENUM class_name=&"TestExportEnumAsDictionary.MyEnum" var test_3: Dictionary - hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_4: TestExportEnumAsDictionary.MyEnum - hint=ENUM hint_string="A:0,B:1,C:2" usage=DEFAULT|SCRIPT_VARIABLE|CLASS_IS_ENUM + hint=ENUM hint_string="A:0,B:1,C:2" usage=DEFAULT|SCRIPT_VARIABLE|CLASS_IS_ENUM class_name=&"TestExportEnumAsDictionary.MyEnum" var test_5: TestExportEnumAsDictionary.MyEnum - hint=ENUM hint_string="A:0,B:1,C:2" usage=DEFAULT|SCRIPT_VARIABLE|CLASS_IS_ENUM + hint=ENUM hint_string="A:0,B:1,C:2" usage=DEFAULT|SCRIPT_VARIABLE|CLASS_IS_ENUM class_name=&"TestExportEnumAsDictionary.MyEnum" diff --git a/modules/gdscript/tests/scripts/parser/features/annotations.out b/modules/gdscript/tests/scripts/parser/features/annotations.out index 2ba9dd7496e0..6516672820e6 100644 --- a/modules/gdscript/tests/scripts/parser/features/annotations.out +++ b/modules/gdscript/tests/scripts/parser/features/annotations.out @@ -1,25 +1,25 @@ GDTEST_OK var test_1: int = null - hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE + hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_2: int = null - hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE + hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_3: int = null - hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE + hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_4: int = null - hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE + hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_5: int = 0 - hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_6: int = 0 - hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_7: int = 42 - hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_8: int = 0 - hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_9: int = 0 - hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_10: int = 0 - hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_11: int = 0 - hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_12: int = 0 - hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" diff --git a/modules/gdscript/tests/scripts/parser/features/export_arrays.out b/modules/gdscript/tests/scripts/parser/features/export_arrays.out index acbf389645e8..f1522d096fa9 100644 --- a/modules/gdscript/tests/scripts/parser/features/export_arrays.out +++ b/modules/gdscript/tests/scripts/parser/features/export_arrays.out @@ -1,139 +1,139 @@ GDTEST_OK var test_dir: Array - hint=TYPE_STRING hint_string="String/DIR:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_dir_packed: PackedStringArray - hint=TYPE_STRING hint_string="String/DIR:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_file: Array - hint=TYPE_STRING hint_string="String/FILE:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_file_packed: PackedStringArray - hint=TYPE_STRING hint_string="String/FILE:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_global_dir: Array - hint=TYPE_STRING hint_string="String/GLOBAL_DIR:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_global_dir_packed: PackedStringArray - hint=TYPE_STRING hint_string="String/GLOBAL_DIR:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_global_file: Array - hint=TYPE_STRING hint_string="String/GLOBAL_FILE:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_global_file_packed: PackedStringArray - hint=TYPE_STRING hint_string="String/GLOBAL_FILE:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag: Array - hint=TYPE_STRING hint_string="int/FLAGS:A,B,C" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_packed_byte: PackedByteArray - hint=TYPE_STRING hint_string="int/FLAGS:A,B,C" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_packed32: PackedInt32Array - hint=TYPE_STRING hint_string="int/FLAGS:A,B,C" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_packed64: PackedInt64Array - hint=TYPE_STRING hint_string="int/FLAGS:A,B,C" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_2d_nav: Array - hint=TYPE_STRING hint_string="int/LAYERS_2D_NAVIGATION:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_2d_nav_packed_byte: PackedByteArray - hint=TYPE_STRING hint_string="int/LAYERS_2D_NAVIGATION:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_2d_nav_packed32: PackedInt32Array - hint=TYPE_STRING hint_string="int/LAYERS_2D_NAVIGATION:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_2d_nav_packed64: PackedInt64Array - hint=TYPE_STRING hint_string="int/LAYERS_2D_NAVIGATION:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_2d_phys: Array - hint=TYPE_STRING hint_string="int/LAYERS_2D_PHYSICS:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_2d_phys_packed_byte: PackedByteArray - hint=TYPE_STRING hint_string="int/LAYERS_2D_PHYSICS:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_2d_phys_packed32: PackedInt32Array - hint=TYPE_STRING hint_string="int/LAYERS_2D_PHYSICS:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_2d_phys_packed64: PackedInt64Array - hint=TYPE_STRING hint_string="int/LAYERS_2D_PHYSICS:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_2d_render: Array - hint=TYPE_STRING hint_string="int/LAYERS_2D_RENDER:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_2d_render_packed_byte: PackedByteArray - hint=TYPE_STRING hint_string="int/LAYERS_2D_RENDER:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_2d_render_packed32: PackedInt32Array - hint=TYPE_STRING hint_string="int/LAYERS_2D_RENDER:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_2d_render_packed64: PackedInt64Array - hint=TYPE_STRING hint_string="int/LAYERS_2D_RENDER:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_3d_nav: Array - hint=TYPE_STRING hint_string="int/LAYERS_3D_NAVIGATION:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_3d_nav_packed_byte: PackedByteArray - hint=TYPE_STRING hint_string="int/LAYERS_3D_NAVIGATION:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_3d_nav_packed32: PackedInt32Array - hint=TYPE_STRING hint_string="int/LAYERS_3D_NAVIGATION:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_3d_nav_packed64: PackedInt64Array - hint=TYPE_STRING hint_string="int/LAYERS_3D_NAVIGATION:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_3d_phys: Array - hint=TYPE_STRING hint_string="int/LAYERS_3D_PHYSICS:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_3d_phys_packed_byte: PackedByteArray - hint=TYPE_STRING hint_string="int/LAYERS_3D_PHYSICS:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_3d_phys_packed32: PackedInt32Array - hint=TYPE_STRING hint_string="int/LAYERS_3D_PHYSICS:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_3d_phys_packed64: PackedInt64Array - hint=TYPE_STRING hint_string="int/LAYERS_3D_PHYSICS:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_3d_render: Array - hint=TYPE_STRING hint_string="int/LAYERS_3D_RENDER:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_3d_render_packed_byte: PackedByteArray - hint=TYPE_STRING hint_string="int/LAYERS_3D_RENDER:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_3d_render_packed32: PackedInt32Array - hint=TYPE_STRING hint_string="int/LAYERS_3D_RENDER:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_bit_flag_3d_render_packed64: PackedInt64Array - hint=TYPE_STRING hint_string="int/LAYERS_3D_RENDER:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_multiline: Array - hint=TYPE_STRING hint_string="String/MULTILINE_TEXT:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_multiline_packed: PackedStringArray - hint=TYPE_STRING hint_string="String/MULTILINE_TEXT:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_placeholder: Array - hint=TYPE_STRING hint_string="String/PLACEHOLDER_TEXT:Placeholder" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:Placeholder" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_placeholder_packed: PackedStringArray - hint=TYPE_STRING hint_string="String/PLACEHOLDER_TEXT:Placeholder" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:Placeholder" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_range_int: Array - hint=TYPE_STRING hint_string="int/RANGE:1,10" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:1,10" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_range_int_packed_byte: PackedByteArray - hint=TYPE_STRING hint_string="int/RANGE:1,10" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:1,10" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_range_int_packed32: PackedInt32Array - hint=TYPE_STRING hint_string="int/RANGE:1,10" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:1,10" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_range_int_packed64: PackedInt64Array - hint=TYPE_STRING hint_string="int/RANGE:1,10" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:1,10" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_range_int_float_step: Array - hint=TYPE_STRING hint_string="int/RANGE:1,10,0.01" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:1,10,0.01" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_range_float: Array - hint=TYPE_STRING hint_string="float/RANGE:1,10" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:1,10" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_range_float_packed32: PackedFloat32Array - hint=TYPE_STRING hint_string="float/RANGE:1,10" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:1,10" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_range_float_packed64: PackedFloat64Array - hint=TYPE_STRING hint_string="float/RANGE:1,10" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:1,10" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_exp_easing: Array - hint=TYPE_STRING hint_string="float/EXP_EASING:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_exp_easing_packed32: PackedFloat32Array - hint=TYPE_STRING hint_string="float/EXP_EASING:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_exp_easing_packed64: PackedFloat64Array - hint=TYPE_STRING hint_string="float/EXP_EASING:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_node_path: Array - hint=TYPE_STRING hint_string="NodePath/NODE_PATH_VALID_TYPES:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_color: Array - hint=TYPE_STRING hint_string="Color/COLOR_NO_ALPHA:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_color_packed: PackedColorArray - hint=TYPE_STRING hint_string="Color/COLOR_NO_ALPHA:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_packed_byte_array: PackedByteArray - hint=TYPE_STRING hint_string="int:int" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string=":" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_packed_int32_array: PackedInt32Array - hint=TYPE_STRING hint_string="int:int" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string=":" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_packed_int64_array: PackedInt64Array - hint=TYPE_STRING hint_string="int:int" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string=":" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_packed_float32_array: PackedFloat32Array - hint=TYPE_STRING hint_string="float:float" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string=":" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_packed_float64_array: PackedFloat64Array - hint=TYPE_STRING hint_string="float:float" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string=":" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_packed_color_array: PackedColorArray - hint=TYPE_STRING hint_string="Color:Color" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string=":" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_packed_vector2_array: PackedVector2Array - hint=TYPE_STRING hint_string="Vector2:Vector2" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string=":" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_packed_vector3_array: PackedVector3Array - hint=TYPE_STRING hint_string="Vector3:Vector3" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string=":" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_packed_vector4_array: PackedVector4Array - hint=TYPE_STRING hint_string="Vector4:Vector4" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string=":" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_range_weak_packed_byte_array: PackedByteArray - hint=TYPE_STRING hint_string="int/RANGE:1,10" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:1,10" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_range_weak_packed_int32_array: PackedInt32Array - hint=TYPE_STRING hint_string="int/RANGE:1,10" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:1,10" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_range_weak_packed_int64_array: PackedInt64Array - hint=TYPE_STRING hint_string="int/RANGE:1,10" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:1,10" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_range_weak_packed_float32_array: PackedFloat32Array - hint=TYPE_STRING hint_string="float/RANGE:1,10" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:1,10" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_range_weak_packed_float64_array: PackedFloat64Array - hint=TYPE_STRING hint_string="float/RANGE:1,10" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:1,10" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_noalpha_weak_packed_color_array: PackedColorArray - hint=TYPE_STRING hint_string="Color/COLOR_NO_ALPHA:" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" diff --git a/modules/gdscript/tests/scripts/parser/features/export_enum.out b/modules/gdscript/tests/scripts/parser/features/export_enum.out index c87f9b17f062..31d3fa890290 100644 --- a/modules/gdscript/tests/scripts/parser/features/export_enum.out +++ b/modules/gdscript/tests/scripts/parser/features/export_enum.out @@ -1,41 +1,41 @@ GDTEST_OK var test_untyped: int = null - hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_with_values: int = null - hint=ENUM hint_string="Red:10,Green:20,Blue:30" usage=DEFAULT|SCRIPT_VARIABLE + hint=ENUM hint_string="Red:10,Green:20,Blue:30" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_variant: int = null - hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_int: int = 0 - hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_string: String = "" - hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_array_int: Array = Array[int]([]) - hint=TYPE_STRING hint_string="int/ENUM:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_array_string: Array = Array[String]([]) - hint=TYPE_STRING hint_string="String/ENUM:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_packed_byte_array: PackedByteArray = PackedByteArray() - hint=TYPE_STRING hint_string="int/ENUM:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_packed_int32_array: PackedInt32Array = PackedInt32Array() - hint=TYPE_STRING hint_string="int/ENUM:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_packed_int64_array: PackedInt64Array = PackedInt64Array() - hint=TYPE_STRING hint_string="int/ENUM:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_weak_packed_string_array: PackedStringArray = PackedStringArray() - hint=TYPE_STRING hint_string="String/ENUM:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_hard_variant: int = null - hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_hard_int: int = 0 - hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_hard_string: String = "" - hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=ENUM hint_string="Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_hard_array_int: Array = Array[int]([]) - hint=TYPE_STRING hint_string="int/ENUM:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_hard_array_string: Array = Array[String]([]) - hint=TYPE_STRING hint_string="String/ENUM:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_variant_array_int: Array = Array[int]([]) - hint=TYPE_STRING hint_string="int/ENUM:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_variant_packed_int32_array: PackedInt32Array = PackedInt32Array() - hint=TYPE_STRING hint_string="int/ENUM:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_variant_array_string: Array = Array[String]([]) - hint=TYPE_STRING hint_string="String/ENUM:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_variant_packed_string_array: PackedStringArray = PackedStringArray() - hint=TYPE_STRING hint_string="String/ENUM:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE + hint=TYPE_STRING hint_string="/:Red,Green,Blue" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" diff --git a/modules/gdscript/tests/scripts/parser/features/export_variable.gd b/modules/gdscript/tests/scripts/parser/features/export_variable.gd index 2a218774de8d..8b343de5ef0d 100644 --- a/modules/gdscript/tests/scripts/parser/features/export_variable.gd +++ b/modules/gdscript/tests/scripts/parser/features/export_variable.gd @@ -2,19 +2,43 @@ extends Node const Utils = preload("../../utils.notest.gd") +# Built-in types. @export var test_weak_int = 1 @export var test_hard_int: int = 2 -@export_storage var test_storage_untyped -@export_storage var test_storage_weak_int = 3 # Property info still `Variant`, unlike `@export`. -@export_storage var test_storage_hard_int: int = 4 @export_range(0, 100) var test_range = 100 @export_range(0, 100, 1) var test_range_step = 101 @export_range(0, 100, 1, "or_greater") var test_range_step_or_greater = 102 @export var test_color: Color @export_color_no_alpha var test_color_no_alpha: Color @export_node_path("Sprite2D", "Sprite3D", "Control", "Node") var test_node_path := ^"hello" -@export var test_node: Node -@export var test_node_array: Array[Node] + +# Enums. +@export var test_side: Side +@export var test_atm: AutoTranslateMode + +# Resources and nodes. +@export var test_image: Image +@export var test_timer: Timer + +# Arrays. +@export var test_array: Array +@export var test_array_bool: Array[bool] +@export var test_array_array: Array[Array] +@export var test_array_side: Array[Side] +@export var test_array_atm: Array[AutoTranslateMode] +@export var test_array_image: Array[Image] +@export var test_array_timer: Array[Timer] + +# `@export_storage`. +@export_storage var test_storage_untyped +@export_storage var test_storage_weak_int = 3 # Property info still `Variant`, unlike `@export`. +@export_storage var test_storage_hard_int: int = 4 + +# `@export_custom`. +# NOTE: `PROPERTY_USAGE_NIL_IS_VARIANT` flag will be removed. +@export_custom(PROPERTY_HINT_ENUM, "A,B,C") var test_export_custom_untyped +@export_custom(PROPERTY_HINT_ENUM, "A,B,C") var test_export_custom_weak_int = 5 +@export_custom(PROPERTY_HINT_ENUM, "A,B,C") var test_export_custom_hard_int: int = 6 func test(): for property in get_property_list(): diff --git a/modules/gdscript/tests/scripts/parser/features/export_variable.out b/modules/gdscript/tests/scripts/parser/features/export_variable.out index b3f9d0ca9ce5..99d7b27130f7 100644 --- a/modules/gdscript/tests/scripts/parser/features/export_variable.out +++ b/modules/gdscript/tests/scripts/parser/features/export_variable.out @@ -1,27 +1,51 @@ GDTEST_OK var test_weak_int: int = 1 - hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_hard_int: int = 2 - hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE -var test_storage_untyped: Variant = null - hint=NONE hint_string="" usage=STORAGE|SCRIPT_VARIABLE|NIL_IS_VARIANT -var test_storage_weak_int: Variant = 3 - hint=NONE hint_string="" usage=STORAGE|SCRIPT_VARIABLE|NIL_IS_VARIANT -var test_storage_hard_int: int = 4 - hint=NONE hint_string="" usage=STORAGE|SCRIPT_VARIABLE + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_range: int = 100 - hint=RANGE hint_string="0,100" usage=DEFAULT|SCRIPT_VARIABLE + hint=RANGE hint_string="0,100" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_range_step: int = 101 - hint=RANGE hint_string="0,100,1" usage=DEFAULT|SCRIPT_VARIABLE + hint=RANGE hint_string="0,100,1" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_range_step_or_greater: int = 102 - hint=RANGE hint_string="0,100,1,or_greater" usage=DEFAULT|SCRIPT_VARIABLE + hint=RANGE hint_string="0,100,1,or_greater" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_color: Color = Color(0, 0, 0, 1) - hint=NONE hint_string="Color" usage=DEFAULT|SCRIPT_VARIABLE + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_color_no_alpha: Color = Color(0, 0, 0, 1) - hint=COLOR_NO_ALPHA hint_string="" usage=DEFAULT|SCRIPT_VARIABLE + hint=COLOR_NO_ALPHA hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" var test_node_path: NodePath = NodePath("hello") - hint=NODE_PATH_VALID_TYPES hint_string="Sprite2D,Sprite3D,Control,Node" usage=DEFAULT|SCRIPT_VARIABLE -var test_node: Node = null - hint=NODE_TYPE hint_string="Node" usage=DEFAULT|SCRIPT_VARIABLE -var test_node_array: Array = Array[Node]([]) - hint=TYPE_STRING hint_string="Object/NODE_TYPE:Node" usage=DEFAULT|SCRIPT_VARIABLE + hint=NODE_PATH_VALID_TYPES hint_string="Sprite2D,Sprite3D,Control,Node" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" +var test_side: Side = 0 + hint=ENUM hint_string="Side Left:0,Side Top:1,Side Right:2,Side Bottom:3" usage=DEFAULT|SCRIPT_VARIABLE|CLASS_IS_ENUM class_name=&"Side" +var test_atm: Node.AutoTranslateMode = 0 + hint=ENUM hint_string="Auto Translate Mode Inherit:0,Auto Translate Mode Always:1,Auto Translate Mode Disabled:2" usage=DEFAULT|SCRIPT_VARIABLE|CLASS_IS_ENUM class_name=&"Node.AutoTranslateMode" +var test_image: Image = null + hint=RESOURCE_TYPE hint_string="Image" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"Image" +var test_timer: Timer = null + hint=NODE_TYPE hint_string="Timer" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"Timer" +var test_array: Array = [] + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" +var test_array_bool: Array = Array[bool]([]) + hint=TYPE_STRING hint_string=":" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" +var test_array_array: Array = Array[Array]([]) + hint=TYPE_STRING hint_string=":" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" +var test_array_side: Array = Array[int]([]) + hint=TYPE_STRING hint_string="/:Side Left:0,Side Top:1,Side Right:2,Side Bottom:3" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" +var test_array_atm: Array = Array[int]([]) + hint=TYPE_STRING hint_string="/:Auto Translate Mode Inherit:0,Auto Translate Mode Always:1,Auto Translate Mode Disabled:2" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" +var test_array_image: Array = Array[Image]([]) + hint=TYPE_STRING hint_string="/:Image" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" +var test_array_timer: Array = Array[Timer]([]) + hint=TYPE_STRING hint_string="/:Timer" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" +var test_storage_untyped: Variant = null + hint=NONE hint_string="" usage=STORAGE|SCRIPT_VARIABLE|NIL_IS_VARIANT class_name=&"" +var test_storage_weak_int: Variant = 3 + hint=NONE hint_string="" usage=STORAGE|SCRIPT_VARIABLE|NIL_IS_VARIANT class_name=&"" +var test_storage_hard_int: int = 4 + hint=NONE hint_string="" usage=STORAGE|SCRIPT_VARIABLE class_name=&"" +var test_export_custom_untyped: null = null + hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" +var test_export_custom_weak_int: int = 5 + hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" +var test_export_custom_hard_int: int = 6 + hint=ENUM hint_string="A,B,C" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" diff --git a/modules/gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.out b/modules/gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.out index 9387ec50d7c4..a1e7233078ab 100644 --- a/modules/gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.out +++ b/modules/gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.out @@ -1,8 +1,8 @@ GDTEST_OK Not shadowed: Resource var test_1: int = 0 - hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" @export_category("test_1") - hint=NONE hint_string="" usage=CATEGORY + hint=NONE hint_string="" usage=CATEGORY class_name=&"" var test_2: int = 0 - hint=NONE hint_string="int" usage=DEFAULT|SCRIPT_VARIABLE + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" diff --git a/modules/gdscript/tests/scripts/utils.notest.gd b/modules/gdscript/tests/scripts/utils.notest.gd index 1cf46c179ed7..7fdd6556ece0 100644 --- a/modules/gdscript/tests/scripts/utils.notest.gd +++ b/modules/gdscript/tests/scripts/utils.notest.gd @@ -55,18 +55,18 @@ static func get_human_readable_hint_string(property: Dictionary) -> String: if elem_type_hint.is_valid_int(): elem_type = elem_type_hint.to_int() - type_hint_prefixes += type_string(elem_type) + ":" + type_hint_prefixes += "<%s>:" % type_string(elem_type) else: if elem_type_hint.count("/") != 1: push_error("Invalid PROPERTY_HINT_TYPE_STRING format.") elem_type = elem_type_hint.get_slice("/", 0).to_int() elem_hint = elem_type_hint.get_slice("/", 1).to_int() - type_hint_prefixes += "%s/%s:" % [ - type_string(elem_type), - get_property_hint_name(elem_hint).trim_prefix("PROPERTY_HINT_"), + type_hint_prefixes += "<%s>/<%s>:" % [ + type_string(elem_type), + get_property_hint_name(elem_hint).trim_prefix("PROPERTY_HINT_"), ] - if elem_type < TYPE_ARRAY: + if elem_type < TYPE_ARRAY or hint_string.is_empty(): break return type_hint_prefixes + hint_string @@ -76,10 +76,11 @@ static func get_human_readable_hint_string(property: Dictionary) -> String: static func print_property_extended_info(property: Dictionary, base: Object = null, is_static: bool = false) -> void: print(get_property_signature(property, base, is_static)) - print(' hint=%s hint_string="%s" usage=%s' % [ + print(' hint=%s hint_string="%s" usage=%s class_name=&"%s"' % [ get_property_hint_name(property.hint).trim_prefix("PROPERTY_HINT_"), - get_human_readable_hint_string(property), + get_human_readable_hint_string(property).c_escape(), get_property_usage_string(property.usage).replace("PROPERTY_USAGE_", ""), + property.class_name.c_escape(), ])