MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / warning_ignore_annotation

Method warning_ignore_annotation

modules/gdscript/gdscript_parser.cpp:4996–5075  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4994}
4995
4996bool GDScriptParser::warning_ignore_annotation(AnnotationNode *p_annotation, Node *p_target, ClassNode *p_class) {
4997#ifdef DEBUG_ENABLED
4998 if (is_ignoring_warnings) {
4999 return true; // We already ignore all warnings, let's optimize it.
5000 }
5001
5002 bool has_error = false;
5003 for (const Variant &warning_name : p_annotation->resolved_arguments) {
5004 GDScriptWarning::Code warning_code = GDScriptWarning::get_code_from_name(String(warning_name).to_upper());
5005 if (warning_code == GDScriptWarning::WARNING_MAX) {
5006 push_error(vformat(R"(Invalid warning name: "%s".)", warning_name), p_annotation);
5007 has_error = true;
5008 } else {
5009 int start_line = p_annotation->start_line;
5010 int end_line = p_target->end_line;
5011
5012 switch (p_target->type) {
5013#define SIMPLE_CASE(m_type, m_class, m_property) \
5014 case m_type: { \
5015 m_class *node = static_cast<m_class *>(p_target); \
5016 if (node->m_property == nullptr) { \
5017 end_line = node->start_line; \
5018 } else { \
5019 end_line = node->m_property->end_line; \
5020 } \
5021 } break;
5022
5023 // Can contain properties (set/get).
5024 SIMPLE_CASE(Node::VARIABLE, VariableNode, initializer)
5025
5026 // Contain bodies.
5027 SIMPLE_CASE(Node::FOR, ForNode, list)
5028 SIMPLE_CASE(Node::IF, IfNode, condition)
5029 SIMPLE_CASE(Node::MATCH, MatchNode, test)
5030 SIMPLE_CASE(Node::WHILE, WhileNode, condition)
5031#undef SIMPLE_CASE
5032
5033 case Node::CLASS: {
5034 end_line = p_target->start_line;
5035 for (const AnnotationNode *annotation : p_target->annotations) {
5036 start_line = MIN(start_line, annotation->start_line);
5037 end_line = MAX(end_line, annotation->end_line);
5038 }
5039 } break;
5040
5041 case Node::FUNCTION: {
5042 FunctionNode *function = static_cast<FunctionNode *>(p_target);
5043 end_line = function->start_line;
5044 for (int i = 0; i < function->parameters.size(); i++) {
5045 end_line = MAX(end_line, function->parameters[i]->end_line);
5046 if (function->parameters[i]->initializer != nullptr) {
5047 end_line = MAX(end_line, function->parameters[i]->initializer->end_line);
5048 }
5049 }
5050 } break;
5051
5052 case Node::MATCH_BRANCH: {
5053 MatchBranchNode *branch = static_cast<MatchBranchNode *>(p_target);

Callers

nothing calls this directly

Calls 7

vformatFunction · 0.85
MINFunction · 0.85
MAXFunction · 0.85
to_upperMethod · 0.80
sizeMethod · 0.65
StringClass · 0.50
insertMethod · 0.45

Tested by

no test coverage detected