summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_editor.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-06-26 15:19:31 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-06-26 15:19:31 +0200
commit93fc9b885798a850e82976c24919cc39d9d4e34b (patch)
tree176cac6ce94ddcf0d8495f1b158873230bc3d303 /modules/gdscript/gdscript_editor.cpp
parentdf78d0dd418464c8ea11932607716e97d6d169fe (diff)
parent322c64c6ea179c29f3e3f553a4a0c615230594e6 (diff)
downloadredot-engine-93fc9b885798a850e82976c24919cc39d9d4e34b.tar.gz
Merge pull request #93566 from Chaosus/gds_fix_enum_lookup
Fix symbol lookup for native enums
Diffstat (limited to 'modules/gdscript/gdscript_editor.cpp')
-rw-r--r--modules/gdscript/gdscript_editor.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 8da829907e..f557727718 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -3657,11 +3657,21 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
return OK;
}
- StringName enum_name = ClassDB::get_integer_constant_enum(class_name, p_symbol, true);
- if (enum_name != StringName()) {
- r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_ENUM;
+ List<StringName> enums;
+ ClassDB::get_enum_list(class_name, &enums);
+ for (const StringName &E : enums) {
+ if (E == p_symbol) {
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_ENUM;
+ r_result.class_name = base_type.native_type;
+ r_result.class_member = p_symbol;
+ return OK;
+ }
+ }
+
+ if (!String(ClassDB::get_integer_constant_enum(class_name, p_symbol, true)).is_empty()) {
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT;
r_result.class_name = base_type.native_type;
- r_result.class_member = enum_name;
+ r_result.class_member = p_symbol;
return OK;
}
@@ -3735,6 +3745,15 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
return OK;
}
} break;
+ case GDScriptParser::DataType::ENUM: {
+ if (base_type.enum_values.has(p_symbol)) {
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT;
+ r_result.class_name = String(base_type.native_type).get_slicec('.', 0);
+ r_result.class_member = p_symbol;
+ return OK;
+ }
+ base_type.kind = GDScriptParser::DataType::UNRESOLVED;
+ } break;
default: {
base_type.kind = GDScriptParser::DataType::UNRESOLVED;
} break;