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

Method get_message

modules/gdscript/gdscript_warning.cpp:45–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43#ifdef DEBUG_ENABLED
44
45String GDScriptWarning::get_message() const {
46#define CHECK_SYMBOLS(m_amount) ERR_FAIL_COND_V(symbols.size() < m_amount, String());
47
48 switch (code) {
49 case UNASSIGNED_VARIABLE:
50 CHECK_SYMBOLS(1);
51 return vformat(R"(The variable "%s" is used before being assigned a value.)", symbols[0]);
52 case UNASSIGNED_VARIABLE_OP_ASSIGN:
53 CHECK_SYMBOLS(2);
54 return vformat(R"(The variable "%s" is modified with the compound-assignment operator "%s=" but was not previously initialized.)", symbols[0], symbols[1]);
55 case UNUSED_VARIABLE:
56 CHECK_SYMBOLS(1);
57 return vformat(R"(The local variable "%s" is declared but never used in the block. If this is intended, prefix it with an underscore: "_%s".)", symbols[0], symbols[0]);
58 case UNUSED_LOCAL_CONSTANT:
59 CHECK_SYMBOLS(1);
60 return vformat(R"(The local constant "%s" is declared but never used in the block. If this is intended, prefix it with an underscore: "_%s".)", symbols[0], symbols[0]);
61 case UNUSED_PRIVATE_CLASS_VARIABLE:
62 CHECK_SYMBOLS(1);
63 return vformat(R"(The class variable "%s" is declared but never used in the class.)", symbols[0]);
64 case UNUSED_PARAMETER:
65 CHECK_SYMBOLS(2);
66 return vformat(R"*(The parameter "%s" is never used in the function "%s()". If this is intended, prefix it with an underscore: "_%s".)*", symbols[1], symbols[0], symbols[1]);
67 case UNUSED_SIGNAL:
68 CHECK_SYMBOLS(1);
69 return vformat(R"(The signal "%s" is declared but never explicitly used in the class.)", symbols[0]);
70 case SHADOWED_VARIABLE:
71 CHECK_SYMBOLS(4);
72 return vformat(R"(The local %s "%s" is shadowing an already-declared %s at line %s in the current class.)", symbols[0], symbols[1], symbols[2], symbols[3]);
73 case SHADOWED_VARIABLE_BASE_CLASS:
74 CHECK_SYMBOLS(4);
75 if (symbols.size() > 4) {
76 return vformat(R"(The local %s "%s" is shadowing an already-declared %s at line %s in the base class "%s".)", symbols[0], symbols[1], symbols[2], symbols[3], symbols[4]);
77 }
78 return vformat(R"(The local %s "%s" is shadowing an already-declared %s in the base class "%s".)", symbols[0], symbols[1], symbols[2], symbols[3]);
79 case SHADOWED_GLOBAL_IDENTIFIER:
80 CHECK_SYMBOLS(3);
81 return vformat(R"(The %s "%s" has the same name as a %s.)", symbols[0], symbols[1], symbols[2]);
82 case UNREACHABLE_CODE:
83 CHECK_SYMBOLS(1);
84 return vformat(R"*(Unreachable code (statement after return) in function "%s()".)*", symbols[0]);
85 case UNREACHABLE_PATTERN:
86 return "Unreachable pattern (pattern after wildcard or bind).";
87 case STANDALONE_EXPRESSION:
88 return "Standalone expression (the line may have no effect).";
89 case STANDALONE_TERNARY:
90 return "Standalone ternary operator (the return value is being discarded).";
91 case INCOMPATIBLE_TERNARY:
92 return "Values of the ternary operator are not mutually compatible.";
93 case UNTYPED_DECLARATION:
94 CHECK_SYMBOLS(2);
95 if (symbols[0] == "Function") {
96 return vformat(R"*(%s "%s()" has no static return type.)*", symbols[0], symbols[1]);
97 }
98 return vformat(R"(%s "%s" has no static type.)", symbols[0], symbols[1]);
99 case INFERRED_DECLARATION:
100 CHECK_SYMBOLS(2);
101 return vformat(R"(%s "%s" has an implicitly inferred static type.)", symbols[0], symbols[1]);
102 case UNSAFE_PROPERTY_ACCESS:

Callers 5

reloadMethod · 0.45
validateMethod · 0.45
update_diagnosticsMethod · 0.45
execute_test_codeMethod · 0.45

Calls 3

vformatFunction · 0.85
sizeMethod · 0.65
StringClass · 0.50

Tested by 1

execute_test_codeMethod · 0.36