Skip to content

Commit 496a990

Browse files
committed
Merge pull request #92526 from dalexeev/gds-remove-renamed-hint-from-warning-enum
GDScript: Remove `RENAMED_IN_GODOT_4_HINT` from `GDScriptWarning::Code` enum
2 parents 0257995 + cd918ff commit 496a990

File tree

8 files changed

+16
-18
lines changed

8 files changed

+16
-18
lines changed

doc/classes/ProjectSettings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@
551551
<member name="debug/gdscript/warnings/redundant_static_unload" type="int" setter="" getter="" default="1">
552552
When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when the [code]@static_unload[/code] annotation is used in a script without any static variables.
553553
</member>
554-
<member name="debug/gdscript/warnings/renamed_in_godot_4_hint" type="bool" setter="" getter="" default="1">
554+
<member name="debug/gdscript/warnings/renamed_in_godot_4_hint" type="bool" setter="" getter="" default="true">
555555
When enabled, using a property, enum, or function that was renamed since Godot 3 will produce a hint if an error occurs.
556556
</member>
557557
<member name="debug/gdscript/warnings/return_value_discarded" type="int" setter="" getter="" default="0">

editor/plugins/script_text_editor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ void ScriptTextEditor::_update_warnings() {
579579

580580
bool has_connections_table = false;
581581
// Add missing connections.
582-
if (GLOBAL_GET("debug/gdscript/warnings/enable").booleanize()) {
582+
if (GLOBAL_GET("debug/gdscript/warnings/enable")) {
583583
Node *base = get_tree()->get_edited_scene_root();
584584
if (base && missing_connections.size() > 0) {
585585
has_connections_table = true;

modules/gdscript/gdscript.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2972,6 +2972,7 @@ GDScriptLanguage::GDScriptLanguage() {
29722972
#ifdef DEBUG_ENABLED
29732973
GLOBAL_DEF("debug/gdscript/warnings/enable", true);
29742974
GLOBAL_DEF("debug/gdscript/warnings/exclude_addons", true);
2975+
GLOBAL_DEF("debug/gdscript/warnings/renamed_in_godot_4_hint", true);
29752976
for (int i = 0; i < (int)GDScriptWarning::WARNING_MAX; i++) {
29762977
GDScriptWarning::Code code = (GDScriptWarning::Code)i;
29772978
Variant default_enabled = GDScriptWarning::get_default_value(code);

modules/gdscript/gdscript_analyzer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3690,7 +3690,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
36903690
String base_name = is_self && !p_call->is_super ? "self" : base_type.to_string();
36913691
#ifdef SUGGEST_GODOT4_RENAMES
36923692
String rename_hint;
3693-
if (GLOBAL_GET(GDScriptWarning::get_settings_path_from_code(GDScriptWarning::RENAMED_IN_GODOT_4_HINT)).booleanize()) {
3693+
if (GLOBAL_GET("debug/gdscript/warnings/renamed_in_godot_4_hint")) {
36943694
const char *renamed_function_name = check_for_renamed_identifier(p_call->function_name, p_call->type);
36953695
if (renamed_function_name) {
36963696
rename_hint = " " + vformat(R"(Did you mean to use "%s"?)", String(renamed_function_name) + "()");
@@ -4036,7 +4036,7 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
40364036
if (!valid && base.is_hard_type()) {
40374037
#ifdef SUGGEST_GODOT4_RENAMES
40384038
String rename_hint;
4039-
if (GLOBAL_GET(GDScriptWarning::get_settings_path_from_code(GDScriptWarning::RENAMED_IN_GODOT_4_HINT)).booleanize()) {
4039+
if (GLOBAL_GET("debug/gdscript/warnings/renamed_in_godot_4_hint")) {
40404040
const char *renamed_identifier_name = check_for_renamed_identifier(name, p_identifier->type);
40414041
if (renamed_identifier_name) {
40424042
rename_hint = " " + vformat(R"(Did you mean to use "%s"?)", renamed_identifier_name);
@@ -4080,7 +4080,7 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
40804080
if (base.is_hard_type()) {
40814081
#ifdef SUGGEST_GODOT4_RENAMES
40824082
String rename_hint;
4083-
if (GLOBAL_GET(GDScriptWarning::get_settings_path_from_code(GDScriptWarning::RENAMED_IN_GODOT_4_HINT)).booleanize()) {
4083+
if (GLOBAL_GET("debug/gdscript/warnings/renamed_in_godot_4_hint")) {
40844084
const char *renamed_identifier_name = check_for_renamed_identifier(name, p_identifier->type);
40854085
if (renamed_identifier_name) {
40864086
rename_hint = " " + vformat(R"(Did you mean to use "%s"?)", renamed_identifier_name);
@@ -4596,7 +4596,7 @@ void GDScriptAnalyzer::reduce_identifier(GDScriptParser::IdentifierNode *p_ident
45964596
// Not found.
45974597
#ifdef SUGGEST_GODOT4_RENAMES
45984598
String rename_hint;
4599-
if (GLOBAL_GET(GDScriptWarning::get_settings_path_from_code(GDScriptWarning::RENAMED_IN_GODOT_4_HINT)).booleanize()) {
4599+
if (GLOBAL_GET("debug/gdscript/warnings/renamed_in_godot_4_hint")) {
46004600
const char *renamed_identifier_name = check_for_renamed_identifier(name, p_identifier->type);
46014601
if (renamed_identifier_name) {
46024602
rename_hint = " " + vformat(R"(Did you mean to use "%s"?)", renamed_identifier_name);

modules/gdscript/gdscript_editor.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -964,9 +964,11 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a
964964
}
965965
} else if (p_annotation->name == SNAME("@warning_ignore") || p_annotation->name == SNAME("@warning_ignore_start") || p_annotation->name == SNAME("@warning_ignore_restore")) {
966966
for (int warning_code = 0; warning_code < GDScriptWarning::WARNING_MAX; warning_code++) {
967-
if (warning_code == GDScriptWarning::RENAMED_IN_GODOT_4_HINT) {
968-
continue;
967+
#ifndef DISABLE_DEPRECATED
968+
if (warning_code >= GDScriptWarning::FIRST_DEPRECATED_WARNING) {
969+
break; // Don't suggest deprecated warnings as they are never produced.
969970
}
971+
#endif
970972
ScriptLanguage::CodeCompletionOption warning(GDScriptWarning::get_name_from_code((GDScriptWarning::Code)warning_code).to_lower(), ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
971973
warning.insert_text = warning.display.quote(p_quote_style);
972974
r_result.insert(warning.display, warning);

modules/gdscript/gdscript_parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ void GDScriptParser::push_warning(const Node *p_source, GDScriptWarning::Code p_
196196
if (is_ignoring_warnings) {
197197
return;
198198
}
199-
if (GLOBAL_GET("debug/gdscript/warnings/exclude_addons").booleanize() && script_path.begins_with("res://addons/")) {
199+
if (GLOBAL_GET("debug/gdscript/warnings/exclude_addons") && script_path.begins_with("res://addons/")) {
200200
return;
201201
}
202202
GDScriptWarning::WarnLevel warn_level = (GDScriptWarning::WarnLevel)(int)GLOBAL_GET(GDScriptWarning::get_settings_path_from_code(p_code));

modules/gdscript/gdscript_warning.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@ String GDScriptWarning::get_message() const {
139139
case DEPRECATED_KEYWORD:
140140
CHECK_SYMBOLS(2);
141141
return vformat(R"(The "%s" keyword is deprecated and will be removed in a future release, please replace its uses by "%s".)", symbols[0], symbols[1]);
142-
case RENAMED_IN_GODOT_4_HINT:
143-
break; // Renamed identifier hint is taken care of by the GDScriptAnalyzer. No message needed here.
144142
case CONFUSABLE_IDENTIFIER:
145143
CHECK_SYMBOLS(1);
146144
return vformat(R"(The identifier "%s" has misleading characters and might be confused with something else.)", symbols[0]);
@@ -185,10 +183,6 @@ int GDScriptWarning::get_default_value(Code p_code) {
185183
}
186184

187185
PropertyInfo GDScriptWarning::get_property_info(Code p_code) {
188-
// Making this a separate function in case a warning needs different PropertyInfo in the future.
189-
if (p_code == Code::RENAMED_IN_GODOT_4_HINT) {
190-
return PropertyInfo(Variant::BOOL, get_settings_path_from_code(p_code));
191-
}
192186
return PropertyInfo(Variant::INT, get_settings_path_from_code(p_code), PROPERTY_HINT_ENUM, "Ignore,Warn,Error");
193187
}
194188

@@ -236,7 +230,6 @@ String GDScriptWarning::get_name_from_code(Code p_code) {
236230
"ENUM_VARIABLE_WITHOUT_DEFAULT",
237231
"EMPTY_FILE",
238232
"DEPRECATED_KEYWORD",
239-
"RENAMED_IN_GODOT_4_HINT",
240233
"CONFUSABLE_IDENTIFIER",
241234
"CONFUSABLE_LOCAL_DECLARATION",
242235
"CONFUSABLE_LOCAL_USAGE",

modules/gdscript/gdscript_warning.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ class GDScriptWarning {
8282
ENUM_VARIABLE_WITHOUT_DEFAULT, // A variable with an enum type does not have a default value. The default will be set to `0` instead of the first enum value.
8383
EMPTY_FILE, // A script file is empty.
8484
DEPRECATED_KEYWORD, // The keyword is deprecated and should be replaced.
85-
RENAMED_IN_GODOT_4_HINT, // A variable or function that could not be found has been renamed in Godot 4.
8685
CONFUSABLE_IDENTIFIER, // The identifier contains misleading characters that can be confused. E.g. "usеr" (has Cyrillic "е" instead of Latin "e").
8786
CONFUSABLE_LOCAL_DECLARATION, // The parent block declares an identifier with the same name below.
8887
CONFUSABLE_LOCAL_USAGE, // The identifier will be shadowed below in the block.
@@ -99,6 +98,10 @@ class GDScriptWarning {
9998
WARNING_MAX,
10099
};
101100

101+
#ifndef DISABLE_DEPRECATED
102+
static constexpr int FIRST_DEPRECATED_WARNING = PROPERTY_USED_AS_FUNCTION;
103+
#endif
104+
102105
constexpr static WarnLevel default_warning_levels[] = {
103106
WARN, // UNASSIGNED_VARIABLE
104107
WARN, // UNASSIGNED_VARIABLE_OP_ASSIGN
@@ -136,7 +139,6 @@ class GDScriptWarning {
136139
WARN, // ENUM_VARIABLE_WITHOUT_DEFAULT
137140
WARN, // EMPTY_FILE
138141
WARN, // DEPRECATED_KEYWORD
139-
WARN, // RENAMED_IN_GODOT_4_HINT
140142
WARN, // CONFUSABLE_IDENTIFIER
141143
WARN, // CONFUSABLE_LOCAL_DECLARATION
142144
WARN, // CONFUSABLE_LOCAL_USAGE

0 commit comments

Comments
 (0)