GDScript: Add warning if non-@tool class extends @tool class

This commit is contained in:
Danil Alexeev 2024-07-04 10:23:44 +03:00
parent 6a13fdcae3
commit 3f52871f70
No known key found for this signature in database
GPG key ID: 124453E157DA8DC7
9 changed files with 55 additions and 0 deletions

View file

@ -411,6 +411,12 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c
return err;
}
#ifdef DEBUG_ENABLED
if (!parser->_is_tool && ext_parser->get_parser()->_is_tool) {
parser->push_warning(p_class, GDScriptWarning::MISSING_TOOL);
}
#endif
base = ext_parser->get_parser()->head->get_datatype();
} else {
if (p_class->extends.is_empty()) {
@ -438,6 +444,13 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c
push_error(vformat(R"(Could not resolve super class inheritance from "%s".)", name), id);
return err;
}
#ifdef DEBUG_ENABLED
if (!parser->_is_tool && base_parser->get_parser()->_is_tool) {
parser->push_warning(p_class, GDScriptWarning::MISSING_TOOL);
}
#endif
base = base_parser->get_parser()->head->get_datatype();
}
} else if (ProjectSettings::get_singleton()->has_autoload(name) && ProjectSettings::get_singleton()->get_autoload(name).is_singleton) {
@ -458,6 +471,13 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c
push_error(vformat(R"(Could not resolve super class inheritance from "%s".)", name), id);
return err;
}
#ifdef DEBUG_ENABLED
if (!parser->_is_tool && info_parser->get_parser()->_is_tool) {
parser->push_warning(p_class, GDScriptWarning::MISSING_TOOL);
}
#endif
base = info_parser->get_parser()->head->get_datatype();
} else if (class_exists(name)) {
if (Engine::get_singleton()->has_singleton(name)) {