1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Use get_slicec instead of get_slice for single character splitters

This commit is contained in:
A Thousand Ships
2024-11-16 17:16:07 +01:00
parent b5bdb88062
commit 466590d0ec
58 changed files with 210 additions and 210 deletions

View File

@@ -783,8 +783,8 @@ void GDScriptSyntaxHighlighter::_update_cache() {
List<String> comments;
gdscript->get_comment_delimiters(&comments);
for (const String &comment : comments) {
String beg = comment.get_slice(" ", 0);
String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String();
String beg = comment.get_slicec(' ', 0);
String end = comment.get_slice_count(" ") > 1 ? comment.get_slicec(' ', 1) : String();
add_color_region(ColorRegion::TYPE_COMMENT, beg, end, comment_color, end.is_empty());
}
@@ -793,8 +793,8 @@ void GDScriptSyntaxHighlighter::_update_cache() {
List<String> doc_comments;
gdscript->get_doc_comment_delimiters(&doc_comments);
for (const String &doc_comment : doc_comments) {
String beg = doc_comment.get_slice(" ", 0);
String end = doc_comment.get_slice_count(" ") > 1 ? doc_comment.get_slice(" ", 1) : String();
String beg = doc_comment.get_slicec(' ', 0);
String end = doc_comment.get_slice_count(" ") > 1 ? doc_comment.get_slicec(' ', 1) : String();
add_color_region(ColorRegion::TYPE_COMMENT, beg, end, doc_comment_color, end.is_empty());
}

View File

@@ -5574,7 +5574,7 @@ GDScriptParser::DataType GDScriptAnalyzer::type_from_property(const PropertyInfo
result.set_container_element_type(0, elem_type);
} else if (p_property.type == Variant::DICTIONARY && p_property.hint == PROPERTY_HINT_DICTIONARY_TYPE) {
// Check element type.
StringName key_elem_type_name = p_property.hint_string.get_slice(";", 0);
StringName key_elem_type_name = p_property.hint_string.get_slicec(';', 0);
GDScriptParser::DataType key_elem_type;
key_elem_type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;
@@ -5599,7 +5599,7 @@ GDScriptParser::DataType GDScriptAnalyzer::type_from_property(const PropertyInfo
}
key_elem_type.is_constant = false;
StringName value_elem_type_name = p_property.hint_string.get_slice(";", 1);
StringName value_elem_type_name = p_property.hint_string.get_slicec(';', 1);
GDScriptParser::DataType value_elem_type;
value_elem_type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT;

View File

@@ -530,9 +530,9 @@ String GDScriptLanguage::make_function(const String &p_class, const String &p_na
if (i > 0) {
s += ", ";
}
s += p_args[i].get_slice(":", 0);
s += p_args[i].get_slicec(':', 0);
if (th) {
String type = p_args[i].get_slice(":", 1);
String type = p_args[i].get_slicec(':', 1);
if (!type.is_empty()) {
s += ": " + type;
}
@@ -722,8 +722,8 @@ static String _get_visual_datatype(const PropertyInfo &p_info, bool p_is_arg, co
} else if (p_info.type == Variant::ARRAY && p_info.hint == PROPERTY_HINT_ARRAY_TYPE && !p_info.hint_string.is_empty()) {
return "Array[" + _trim_parent_class(p_info.hint_string, p_base_class) + "]";
} else if (p_info.type == Variant::DICTIONARY && p_info.hint == PROPERTY_HINT_DICTIONARY_TYPE && !p_info.hint_string.is_empty()) {
const String key = p_info.hint_string.get_slice(";", 0);
const String value = p_info.hint_string.get_slice(";", 1);
const String key = p_info.hint_string.get_slicec(';', 0);
const String value = p_info.hint_string.get_slicec(';', 1);
return "Dictionary[" + _trim_parent_class(key, p_base_class) + ", " + _trim_parent_class(value, p_base_class) + "]";
} else if (p_info.type == Variant::NIL) {
if (p_is_arg || (p_info.usage & PROPERTY_USAGE_NIL_IS_VARIANT)) {
@@ -1866,7 +1866,7 @@ static bool _guess_expression_type(GDScriptParser::CompletionContext &p_context,
if (all_is_const && call->function_name == SNAME("get_node") && ClassDB::is_parent_class(native_type.native_type, SNAME("Node")) && args.size()) {
String arg1 = args[0];
if (arg1.begins_with("/root/")) {
String which = arg1.get_slice("/", 2);
String which = arg1.get_slicec('/', 2);
if (!which.is_empty()) {
// Try singletons first
if (GDScriptLanguage::get_singleton()->get_named_globals_map().has(which)) {
@@ -2745,8 +2745,8 @@ static void _find_enumeration_candidates(GDScriptParser::CompletionContext &p_co
}
}
} else {
String class_name = p_enum_hint.get_slice(".", 0);
String enum_name = p_enum_hint.get_slice(".", 1);
String class_name = p_enum_hint.get_slicec('.', 0);
String enum_name = p_enum_hint.get_slicec('.', 1);
if (!ClassDB::class_exists(class_name)) {
return;
@@ -2949,7 +2949,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
if (!s.begins_with("autoload/")) {
continue;
}
String name = s.get_slice("/", 1);
String name = s.get_slicec('/', 1);
String path = ("/root/" + name).quote(quote_style);
if (use_node_paths) {
path = "^" + path;
@@ -2968,7 +2968,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
if (!s.begins_with("input/")) {
continue;
}
String name = s.get_slice("/", 1).quote(quote_style);
String name = s.get_slicec('/', 1).quote(quote_style);
if (use_string_names) {
name = "&" + name;
}
@@ -3491,7 +3491,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
for (const MethodInfo &mi : virtual_methods) {
String method_hint = mi.name;
if (method_hint.contains_char(':')) {
method_hint = method_hint.get_slice(":", 0);
method_hint = method_hint.get_slicec(':', 0);
}
method_hint += "(";