mirror of
https://github.com/godotengine/godot.git
synced 2026-01-01 05:49:28 +03:00
Merge pull request #109433 from KoBeWi/hastension
Add `has_extension()` method to String
This commit is contained in:
@@ -492,7 +492,7 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c
|
||||
}
|
||||
} else if (ProjectSettings::get_singleton()->has_autoload(name) && ProjectSettings::get_singleton()->get_autoload(name).is_singleton) {
|
||||
const ProjectSettings::AutoloadInfo &info = ProjectSettings::get_singleton()->get_autoload(name);
|
||||
if (info.path.get_extension().to_lower() != GDScriptLanguage::get_singleton()->get_extension()) {
|
||||
if (!info.path.has_extension(GDScriptLanguage::get_singleton()->get_extension())) {
|
||||
push_error(vformat(R"(Singleton %s is not a GDScript.)", info.name), id);
|
||||
return ERR_PARSE_ERROR;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ Error GDScriptParserRef::raise_status(Status p_new_status) {
|
||||
get_parser()->clear();
|
||||
status = PARSED;
|
||||
String remapped_path = ResourceLoader::path_remap(path);
|
||||
if (remapped_path.get_extension().to_lower() == "gdc") {
|
||||
if (remapped_path.has_extension("gdc")) {
|
||||
Vector<uint8_t> tokens = GDScriptCache::get_binary_tokens(remapped_path);
|
||||
source_hash = hash_djb2_buffer(tokens.ptr(), tokens.size());
|
||||
result = get_parser()->parse_binary(tokens, path);
|
||||
@@ -313,7 +313,7 @@ Ref<GDScript> GDScriptCache::get_shallow_script(const String &p_path, Error &r_e
|
||||
Ref<GDScript> script;
|
||||
script.instantiate();
|
||||
script->set_path(p_path, true);
|
||||
if (remapped_path.get_extension().to_lower() == "gdc") {
|
||||
if (remapped_path.has_extension("gdc")) {
|
||||
Vector<uint8_t> buffer = get_binary_tokens(remapped_path);
|
||||
if (buffer.is_empty()) {
|
||||
r_error = ERR_FILE_CANT_READ;
|
||||
@@ -364,7 +364,7 @@ Ref<GDScript> GDScriptCache::get_full_script(const String &p_path, Error &r_erro
|
||||
const String remapped_path = ResourceLoader::path_remap(p_path);
|
||||
|
||||
if (p_update_from_disk) {
|
||||
if (remapped_path.get_extension().to_lower() == "gdc") {
|
||||
if (remapped_path.has_extension("gdc")) {
|
||||
Vector<uint8_t> buffer = get_binary_tokens(remapped_path);
|
||||
if (buffer.is_empty()) {
|
||||
r_error = ERR_FILE_CANT_READ;
|
||||
|
||||
@@ -1123,7 +1123,7 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completio
|
||||
|
||||
for (const KeyValue<StringName, ProjectSettings::AutoloadInfo> &E : autoloads) {
|
||||
const ProjectSettings::AutoloadInfo &info = E.value;
|
||||
if (!info.is_singleton || info.path.get_extension().to_lower() != "gd") {
|
||||
if (!info.is_singleton || !info.path.has_extension("gd")) {
|
||||
continue;
|
||||
}
|
||||
ScriptLanguage::CodeCompletionOption option(info.name, ScriptLanguage::CODE_COMPLETION_KIND_CLASS, ScriptLanguage::LOCATION_OTHER_USER_CODE);
|
||||
|
||||
@@ -282,7 +282,7 @@ bool GDScriptTestRunner::make_tests_for_dir(const String &p_dir) {
|
||||
} else if (binary_tokens && next.ends_with(".textonly.gd")) {
|
||||
next = dir->get_next();
|
||||
continue;
|
||||
} else if (next.get_extension().to_lower() == "gd") {
|
||||
} else if (next.has_extension("gd")) {
|
||||
#ifndef DEBUG_ENABLED
|
||||
// On release builds, skip tests marked as debug only.
|
||||
Error open_err = OK;
|
||||
|
||||
Reference in New Issue
Block a user