Skip to content

Commit f44f834

Browse files
committed
Recognize individual value in user-defined named enum in inner class marked as deprecated
1 parent 00d6a22 commit f44f834

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

modules/gdscript/gdscript_analyzer.cpp

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

40434043
if (base.kind == GDScriptParser::DataType::ENUM) {
40444044
#if DEBUG_ENABLED
4045-
DocTools *dd = EditorHelp::get_doc_data();
4046-
StringName class_name = String(base.native_type).get_slicec('.', 0);
4047-
if (dd && dd->class_list.has(class_name)) {
4048-
for (const DocData::ConstantDoc &doc : dd->class_list[class_name].constants) {
4049-
if (doc.enumeration == base.enum_type && doc.name == name) {
4050-
if (doc.is_deprecated) {
4051-
parser->push_warning(p_identifier, GDScriptWarning::DEPRECATED_IDENTIFIER);
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;
4048+
4049+
// It's an inner class, so we need to get the outer class's name
4050+
// as well to construct its full name as found in the doc data.
4051+
if (base.class_type->outer != nullptr) {
4052+
class_name = String(base.class_type->outer->identifier->name) + "." + class_name;
4053+
}
4054+
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;
40524062
}
4053-
break;
40544063
}
40554064
}
40564065
}

0 commit comments

Comments
 (0)