|
|
|
@ -651,6 +651,21 @@ static int _get_enum_constant_location(const StringName &p_class, const StringNa
|
|
|
|
|
return depth | ScriptLanguage::LOCATION_PARENT_MASK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int _get_enum_location(const StringName &p_class, const StringName &p_enum) {
|
|
|
|
|
if (!ClassDB::has_enum(p_class, p_enum)) {
|
|
|
|
|
return ScriptLanguage::LOCATION_OTHER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int depth = 0;
|
|
|
|
|
StringName class_test = p_class;
|
|
|
|
|
while (class_test && !ClassDB::has_enum(class_test, p_enum, true)) {
|
|
|
|
|
class_test = ClassDB::get_parent_class(class_test);
|
|
|
|
|
depth++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return depth | ScriptLanguage::LOCATION_PARENT_MASK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// END LOCATION METHODS
|
|
|
|
|
|
|
|
|
|
static String _trim_parent_class(const String &p_class, const String &p_base_class) {
|
|
|
|
@ -1202,13 +1217,15 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<StringName> enums;
|
|
|
|
|
ClassDB::get_enum_list(type, &enums);
|
|
|
|
|
for (const StringName &E : enums) {
|
|
|
|
|
int location = p_recursion_depth + _get_enum_location(type, E);
|
|
|
|
|
ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_ENUM, location);
|
|
|
|
|
r_result.insert(option.display, option);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (p_types_only) {
|
|
|
|
|
List<StringName> enums;
|
|
|
|
|
ClassDB::get_enum_list(type, &enums);
|
|
|
|
|
for (const StringName &E : enums) {
|
|
|
|
|
ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_ENUM);
|
|
|
|
|
r_result.insert(option.display, option);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1268,7 +1285,20 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
} break;
|
|
|
|
|
case GDScriptParser::DataType::ENUM:
|
|
|
|
|
case GDScriptParser::DataType::ENUM: {
|
|
|
|
|
String type_str = base_type.native_type;
|
|
|
|
|
StringName type = type_str.get_slicec('.', 0);
|
|
|
|
|
StringName type_enum = base_type.enum_type;
|
|
|
|
|
|
|
|
|
|
List<StringName> enum_values;
|
|
|
|
|
ClassDB::get_enum_constants(type, type_enum, &enum_values);
|
|
|
|
|
for (const StringName &E : enum_values) {
|
|
|
|
|
int location = p_recursion_depth + _get_enum_constant_location(type, E);
|
|
|
|
|
ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT, location);
|
|
|
|
|
r_result.insert(option.display, option);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[[fallthrough]];
|
|
|
|
|
case GDScriptParser::DataType::BUILTIN: {
|
|
|
|
|
if (p_types_only) {
|
|
|
|
|
return;
|
|
|
|
|