mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Improve use of Ref.is_null/valid
Use `is_null` over `!is_valid` and vice versa.
This commit is contained in:
committed by
AThousandShips
parent
0f95e9f8e6
commit
a1846b27ea
@@ -792,7 +792,7 @@ GDScriptParser::DataType GDScriptAnalyzer::resolve_datatype(GDScriptParser::Type
|
||||
String ext = path.get_extension();
|
||||
if (ext == GDScriptLanguage::get_singleton()->get_extension()) {
|
||||
Ref<GDScriptParserRef> ref = parser->get_depended_parser_for(path);
|
||||
if (!ref.is_valid() || ref->raise_status(GDScriptParserRef::INHERITANCE_SOLVED) != OK) {
|
||||
if (ref.is_null() || ref->raise_status(GDScriptParserRef::INHERITANCE_SOLVED) != OK) {
|
||||
push_error(vformat(R"(Could not parse global class "%s" from "%s".)", first, ScriptServer::get_global_class_path(first)), p_type);
|
||||
return bad_type;
|
||||
}
|
||||
|
||||
@@ -284,10 +284,10 @@ struct GDScriptUtilityFunctionsDefinitions {
|
||||
VALIDATE_ARG_CUSTOM(0, Variant::DICTIONARY, !d.has("@path"), RTR("Invalid instance dictionary format (missing @path)."));
|
||||
|
||||
Ref<Script> scr = ResourceLoader::load(d["@path"]);
|
||||
VALIDATE_ARG_CUSTOM(0, Variant::DICTIONARY, !scr.is_valid(), RTR("Invalid instance dictionary format (can't load script at @path)."));
|
||||
VALIDATE_ARG_CUSTOM(0, Variant::DICTIONARY, scr.is_null(), RTR("Invalid instance dictionary format (can't load script at @path)."));
|
||||
|
||||
Ref<GDScript> gdscr = scr;
|
||||
VALIDATE_ARG_CUSTOM(0, Variant::DICTIONARY, !gdscr.is_valid(), RTR("Invalid instance dictionary format (invalid script at @path)."));
|
||||
VALIDATE_ARG_CUSTOM(0, Variant::DICTIONARY, gdscr.is_null(), RTR("Invalid instance dictionary format (invalid script at @path)."));
|
||||
|
||||
NodePath sub;
|
||||
if (d.has("@subpath")) {
|
||||
@@ -296,7 +296,7 @@ struct GDScriptUtilityFunctionsDefinitions {
|
||||
|
||||
for (int i = 0; i < sub.get_name_count(); i++) {
|
||||
gdscr = gdscr->subclasses[sub.get_name(i)];
|
||||
VALIDATE_ARG_CUSTOM(0, Variant::DICTIONARY, !gdscr.is_valid(), RTR("Invalid instance dictionary (invalid subclasses)."));
|
||||
VALIDATE_ARG_CUSTOM(0, Variant::DICTIONARY, gdscr.is_null(), RTR("Invalid instance dictionary (invalid subclasses)."));
|
||||
}
|
||||
|
||||
*r_ret = gdscr->_new(nullptr, -1 /* skip initializer */, r_error);
|
||||
|
||||
@@ -657,7 +657,7 @@ void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<S
|
||||
}
|
||||
|
||||
Ref<GDScript> scr = current->get_script();
|
||||
if (!scr.is_valid() || !GDScript::is_canonically_equal_paths(scr->get_path(), path)) {
|
||||
if (scr.is_null() || !GDScript::is_canonically_equal_paths(scr->get_path(), path)) {
|
||||
current = owner_scene_node;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ void init_autoloads() {
|
||||
scn.instantiate();
|
||||
scn->set_path(info.path);
|
||||
scn->reload_from_file();
|
||||
ERR_CONTINUE_MSG(!scn.is_valid(), vformat("Failed to instantiate an autoload, can't load from path: %s.", info.path));
|
||||
ERR_CONTINUE_MSG(scn.is_null(), vformat("Failed to instantiate an autoload, can't load from path: %s.", info.path));
|
||||
|
||||
if (scn.is_valid()) {
|
||||
n = scn->instantiate();
|
||||
|
||||
Reference in New Issue
Block a user