You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-13 13:31:48 +00:00
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
This commit is contained in:
@@ -64,23 +64,26 @@ void EditorAutoloadSettings::_notification(int p_what) {
|
||||
|
||||
bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, String *r_error) {
|
||||
if (!p_name.is_valid_identifier()) {
|
||||
if (r_error)
|
||||
if (r_error) {
|
||||
*r_error = TTR("Invalid name.") + "\n" + TTR("Valid characters:") + " a-z, A-Z, 0-9 or _";
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ClassDB::class_exists(p_name)) {
|
||||
if (r_error)
|
||||
if (r_error) {
|
||||
*r_error = TTR("Invalid name.") + "\n" + TTR("Must not collide with an existing engine class name.");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
|
||||
if (Variant::get_type_name(Variant::Type(i)) == p_name) {
|
||||
if (r_error)
|
||||
if (r_error) {
|
||||
*r_error = TTR("Invalid name.") + "\n" + TTR("Must not collide with an existing built-in type name.");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -88,8 +91,9 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin
|
||||
|
||||
for (int i = 0; i < GlobalConstants::get_global_constant_count(); i++) {
|
||||
if (GlobalConstants::get_global_constant_name(i) == p_name) {
|
||||
if (r_error)
|
||||
if (r_error) {
|
||||
*r_error = TTR("Invalid name.") + "\n" + TTR("Must not collide with an existing global constant name.");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -100,8 +104,9 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin
|
||||
ScriptServer::get_language(i)->get_reserved_words(&keywords);
|
||||
for (List<String>::Element *E = keywords.front(); E; E = E->next()) {
|
||||
if (E->get() == p_name) {
|
||||
if (r_error)
|
||||
if (r_error) {
|
||||
*r_error = TTR("Invalid name.") + "\n" + TTR("Keyword cannot be used as an autoload name.");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -112,8 +117,9 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin
|
||||
}
|
||||
|
||||
void EditorAutoloadSettings::_autoload_add() {
|
||||
if (autoload_add(autoload_add_name->get_text(), autoload_add_path->get_text()))
|
||||
if (autoload_add(autoload_add_name->get_text(), autoload_add_path->get_text())) {
|
||||
autoload_add_path->set_text("");
|
||||
}
|
||||
|
||||
autoload_add_name->set_text("");
|
||||
add_autoload->set_disabled(true);
|
||||
@@ -122,15 +128,17 @@ void EditorAutoloadSettings::_autoload_add() {
|
||||
void EditorAutoloadSettings::_autoload_selected() {
|
||||
TreeItem *ti = tree->get_selected();
|
||||
|
||||
if (!ti)
|
||||
if (!ti) {
|
||||
return;
|
||||
}
|
||||
|
||||
selected_autoload = "autoload/" + ti->get_text(0);
|
||||
}
|
||||
|
||||
void EditorAutoloadSettings::_autoload_edited() {
|
||||
if (updating_autoload)
|
||||
if (updating_autoload) {
|
||||
return;
|
||||
}
|
||||
|
||||
TreeItem *ti = tree->get_edited();
|
||||
int column = tree->get_edited_column();
|
||||
@@ -141,8 +149,9 @@ void EditorAutoloadSettings::_autoload_edited() {
|
||||
String name = ti->get_text(0);
|
||||
String old_name = selected_autoload.get_slice("/", 1);
|
||||
|
||||
if (name == old_name)
|
||||
if (name == old_name) {
|
||||
return;
|
||||
}
|
||||
|
||||
String error;
|
||||
if (!_autoload_name_is_valid(name, &error)) {
|
||||
@@ -192,12 +201,14 @@ void EditorAutoloadSettings::_autoload_edited() {
|
||||
int order = ProjectSettings::get_singleton()->get_order(base);
|
||||
String path = ProjectSettings::get_singleton()->get(base);
|
||||
|
||||
if (path.begins_with("*"))
|
||||
if (path.begins_with("*")) {
|
||||
path = path.substr(1, path.length());
|
||||
}
|
||||
|
||||
// Singleton autoloads are represented with a leading "*" in their path.
|
||||
if (checked)
|
||||
if (checked) {
|
||||
path = "*" + path;
|
||||
}
|
||||
|
||||
undo_redo->create_action(TTR("Toggle AutoLoad Globals"));
|
||||
|
||||
@@ -240,8 +251,9 @@ void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_colu
|
||||
swap = ti->get_next();
|
||||
}
|
||||
|
||||
if (!swap)
|
||||
if (!swap) {
|
||||
return;
|
||||
}
|
||||
|
||||
String swap_name = "autoload/" + swap->get_text(0);
|
||||
|
||||
@@ -288,8 +300,9 @@ void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_colu
|
||||
|
||||
void EditorAutoloadSettings::_autoload_activated() {
|
||||
TreeItem *ti = tree->get_selected();
|
||||
if (!ti)
|
||||
if (!ti) {
|
||||
return;
|
||||
}
|
||||
_autoload_open(ti->get_text(1));
|
||||
}
|
||||
|
||||
@@ -357,8 +370,9 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {
|
||||
}
|
||||
|
||||
void EditorAutoloadSettings::update_autoload() {
|
||||
if (updating_autoload)
|
||||
if (updating_autoload) {
|
||||
return;
|
||||
}
|
||||
|
||||
updating_autoload = true;
|
||||
|
||||
@@ -381,14 +395,16 @@ void EditorAutoloadSettings::update_autoload() {
|
||||
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
|
||||
const PropertyInfo &pi = E->get();
|
||||
|
||||
if (!pi.name.begins_with("autoload/"))
|
||||
if (!pi.name.begins_with("autoload/")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = pi.name.get_slice("/", 1);
|
||||
String path = ProjectSettings::get_singleton()->get(pi.name);
|
||||
|
||||
if (name.empty())
|
||||
if (name.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AutoLoadInfo info;
|
||||
info.is_singleton = path.begins_with("*");
|
||||
@@ -502,8 +518,9 @@ void EditorAutoloadSettings::update_autoload() {
|
||||
}
|
||||
|
||||
Variant EditorAutoloadSettings::get_drag_data_fw(const Point2 &p_point, Control *p_control) {
|
||||
if (autoload_cache.size() <= 1)
|
||||
if (autoload_cache.size() <= 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PackedStringArray autoloads;
|
||||
|
||||
@@ -514,8 +531,9 @@ Variant EditorAutoloadSettings::get_drag_data_fw(const Point2 &p_point, Control
|
||||
next = tree->get_next_selected(next);
|
||||
}
|
||||
|
||||
if (autoloads.size() == 0 || autoloads.size() == autoload_cache.size())
|
||||
if (autoloads.size() == 0 || autoloads.size() == autoload_cache.size()) {
|
||||
return Variant();
|
||||
}
|
||||
|
||||
VBoxContainer *preview = memnew(VBoxContainer);
|
||||
|
||||
@@ -539,19 +557,22 @@ Variant EditorAutoloadSettings::get_drag_data_fw(const Point2 &p_point, Control
|
||||
}
|
||||
|
||||
bool EditorAutoloadSettings::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control) const {
|
||||
if (updating_autoload)
|
||||
if (updating_autoload) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Dictionary drop_data = p_data;
|
||||
|
||||
if (!drop_data.has("type"))
|
||||
if (!drop_data.has("type")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (drop_data.has("type")) {
|
||||
TreeItem *ti = tree->get_item_at_position(p_point);
|
||||
|
||||
if (!ti)
|
||||
if (!ti) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int section = tree->get_drop_section_at_position(p_point);
|
||||
|
||||
@@ -564,13 +585,15 @@ bool EditorAutoloadSettings::can_drop_data_fw(const Point2 &p_point, const Varia
|
||||
void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control) {
|
||||
TreeItem *ti = tree->get_item_at_position(p_point);
|
||||
|
||||
if (!ti)
|
||||
if (!ti) {
|
||||
return;
|
||||
}
|
||||
|
||||
int section = tree->get_drop_section_at_position(p_point);
|
||||
|
||||
if (section < -1)
|
||||
if (section < -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
String name;
|
||||
bool move_to_back = false;
|
||||
@@ -736,14 +759,16 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
|
||||
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
|
||||
const PropertyInfo &pi = E->get();
|
||||
|
||||
if (!pi.name.begins_with("autoload/"))
|
||||
if (!pi.name.begins_with("autoload/")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = pi.name.get_slice("/", 1);
|
||||
String path = ProjectSettings::get_singleton()->get(pi.name);
|
||||
|
||||
if (name.empty())
|
||||
if (name.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AutoLoadInfo info;
|
||||
info.is_singleton = path.begins_with("*");
|
||||
|
||||
Reference in New Issue
Block a user