Skip to content

Commit a3186c4

Browse files
committed
Fix recognition of individual value from native enum with enum name marked as deprecated
Remove some duplicate code
1 parent f44f834 commit a3186c4

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

modules/gdscript/gdscript_analyzer.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4042,24 +4042,33 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
40424042

40434043
if (base.kind == GDScriptParser::DataType::ENUM) {
40444044
#if DEBUG_ENABLED
4045-
if (base.class_type && base.class_type->identifier && base.class_type->identifier->name) {
4046-
DocTools *dd = EditorHelp::get_doc_data();
4047-
StringName class_name = base.class_type->identifier->name;
4045+
StringName class_name;
4046+
DocTools *dd = EditorHelp::get_doc_data();
4047+
// TODO: Is this a proper way of detecting it's from a native class?
4048+
// e.g., "AnimationPlayer.AnimationProcessCallback"
4049+
// User-defined enums also seem to have a "native_type" so we can't
4050+
// detect actual native classes solely based on whether or not that
4051+
// string is defined.
4052+
if (base.native_type && !base.class_type) {
4053+
class_name = String(base.native_type).get_slicec('.', 0);
4054+
}
40484055

4056+
else if (base.class_type && base.class_type->identifier && base.class_type->identifier->name) {
4057+
class_name = base.class_type->identifier->name;
40494058
// It's an inner class, so we need to get the outer class's name
40504059
// as well to construct its full name as found in the doc data.
40514060
if (base.class_type->outer != nullptr) {
40524061
class_name = String(base.class_type->outer->identifier->name) + "." + class_name;
40534062
}
4063+
}
40544064

4055-
if (dd && dd->class_list.has(class_name)) {
4056-
for (const DocData::ConstantDoc &doc : dd->class_list[class_name].constants) {
4057-
if (doc.enumeration == base.enum_type && doc.name == name) {
4058-
if (doc.is_deprecated) {
4059-
parser->push_warning(p_identifier, GDScriptWarning::DEPRECATED_IDENTIFIER);
4060-
}
4061-
break;
4065+
if (dd && dd->class_list.has(class_name)) {
4066+
for (const DocData::ConstantDoc &doc : dd->class_list[class_name].constants) {
4067+
if (doc.enumeration == base.enum_type && doc.name == name) {
4068+
if (doc.is_deprecated) {
4069+
parser->push_warning(p_identifier, GDScriptWarning::DEPRECATED_IDENTIFIER);
40624070
}
4071+
break;
40634072
}
40644073
}
40654074
}

0 commit comments

Comments
 (0)