Display correct symbol in warning when unique name is used without @onready annotation

Add tests for `GET_NODE_DEFAULT_WITHOUT_ONREADY` warning with unique nodes

Small modifications to tests
This commit is contained in:
Malcolm Anderson 2025-02-03 17:35:19 -08:00
parent f0f5319b0b
commit 8e8f93cf0c
3 changed files with 24 additions and 3 deletions

View file

@ -1093,7 +1093,12 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
}
}
if (is_get_node) {
parser->push_warning(member.variable, GDScriptWarning::GET_NODE_DEFAULT_WITHOUT_ONREADY, is_using_shorthand ? "$" : "get_node()");
String offending_syntax = "get_node()";
if (is_using_shorthand) {
GDScriptParser::GetNodeNode *get_node_node = static_cast<GDScriptParser::GetNodeNode *>(expr);
offending_syntax = get_node_node->use_dollar ? "$" : "%";
}
parser->push_warning(member.variable, GDScriptWarning::GET_NODE_DEFAULT_WITHOUT_ONREADY, offending_syntax);
}
}
}