From 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 13:23:58 +0200 Subject: Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027. --- editor/rename_dialog.cpp | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'editor/rename_dialog.cpp') diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 8ae8d0991d..fa44efda29 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -42,7 +42,6 @@ #include "scene/gui/tab_container.h" RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_undo_redo) { - scene_tree_editor = p_scene_tree_editor; undo_redo = p_undo_redo; preview_node = nullptr; @@ -341,12 +340,10 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_und } void RenameDialog::_bind_methods() { - ClassDB::bind_method("rename", &RenameDialog::rename); } void RenameDialog::_update_substitute() { - LineEdit *focus_owner_line_edit = Object::cast_to(scene_tree_editor->get_focus_owner()); bool is_main_field = _is_main_field(focus_owner_line_edit); @@ -367,7 +364,6 @@ void RenameDialog::_update_substitute() { } void RenameDialog::_post_popup() { - EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection(); preview_node = nullptr; @@ -385,7 +381,6 @@ void RenameDialog::_update_preview_int(int new_value) { } void RenameDialog::_update_preview(String new_text) { - if (lock_preview_update || preview_node == nullptr) return; @@ -395,7 +390,6 @@ void RenameDialog::_update_preview(String new_text) { String new_name = _apply_rename(preview_node, spn_count_start->get_value()); if (!has_errors) { - lbl_preview_title->set_text(TTR("Preview")); lbl_preview->set_text(new_name); @@ -413,7 +407,6 @@ void RenameDialog::_update_preview(String new_text) { } String RenameDialog::_apply_rename(const Node *node, int count) { - String search = lne_search->get_text(); String replace = lne_replace->get_text(); String prefix = lne_prefix->get_text(); @@ -428,7 +421,6 @@ String RenameDialog::_apply_rename(const Node *node, int count) { } if (cbut_regex->is_pressed()) { - new_name = _regex(search, new_name, replace); } else { new_name = new_name.replace(search, replace); @@ -444,7 +436,6 @@ String RenameDialog::_apply_rename(const Node *node, int count) { } String RenameDialog::_substitute(const String &subject, const Node *node, int count) { - String result = subject.replace("${COUNTER}", vformat("%0" + itos(spn_count_padding->get_value()) + "d", count)); if (node) { @@ -474,7 +465,6 @@ String RenameDialog::_substitute(const String &subject, const Node *node, int co } void RenameDialog::_error_handler(void *p_self, const char *p_func, const char *p_file, int p_line, const char *p_error, const char *p_errorexp, ErrorHandlerType p_type) { - RenameDialog *self = (RenameDialog *)p_self; String source_file(p_file); @@ -496,14 +486,12 @@ void RenameDialog::_error_handler(void *p_self, const char *p_func, const char * } String RenameDialog::_regex(const String &pattern, const String &subject, const String &replacement) { - RegEx regex(pattern); return regex.sub(subject, replacement, true); } String RenameDialog::_postprocess(const String &subject) { - int style_id = opt_style->get_selected(); String result = subject; @@ -550,12 +538,10 @@ String RenameDialog::_postprocess(const String &subject) { } void RenameDialog::_iterate_scene(const Node *node, const Array &selection, int *counter) { - if (!node) return; if (selection.has(node)) { - String new_name = _apply_rename(node, *counter); if (node->get_name() != new_name) { @@ -581,7 +567,6 @@ void RenameDialog::_iterate_scene(const Node *node, const Array &selection, int } void RenameDialog::rename() { - // Editor selection is not ordered via scene tree. Instead iterate // over scene tree until all selected nodes are found in order. @@ -596,12 +581,10 @@ void RenameDialog::rename() { _iterate_scene(root_node, selected_node_list, &global_count); if (undo_redo && !to_rename.empty()) { - undo_redo->create_action(TTR("Batch Rename")); // Make sure to iterate reversed so that child nodes will find parents. for (int i = to_rename.size() - 1; i >= 0; --i) { - Node *n = root_node->get_node(to_rename[i].first); const String &new_name = to_rename[i].second; @@ -620,7 +603,6 @@ void RenameDialog::rename() { } void RenameDialog::reset() { - lock_preview_update = true; lne_prefix->clear(); @@ -651,7 +633,6 @@ bool RenameDialog::_is_main_field(LineEdit *line_edit) { } void RenameDialog::_insert_text(String text) { - LineEdit *focus_owner = Object::cast_to(scene_tree_editor->get_focus_owner()); if (_is_main_field(focus_owner)) { -- cgit v1.2.3 From 0ee0fa42e6639b6fa474b7cf6afc6b1a78142185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 16:41:43 +0200 Subject: 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 --- editor/rename_dialog.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'editor/rename_dialog.cpp') diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index fa44efda29..6a54894f40 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -381,8 +381,9 @@ void RenameDialog::_update_preview_int(int new_value) { } void RenameDialog::_update_preview(String new_text) { - if (lock_preview_update || preview_node == nullptr) + if (lock_preview_update || preview_node == nullptr) { return; + } has_errors = false; add_error_handler(&eh); @@ -469,8 +470,9 @@ void RenameDialog::_error_handler(void *p_self, const char *p_func, const char * String source_file(p_file); // Only show first error that is related to "regex" - if (self->has_errors || source_file.find("regex") < 0) + if (self->has_errors || source_file.find("regex") < 0) { return; + } String err_str; if (p_errorexp && p_errorexp[0]) { @@ -538,8 +540,9 @@ String RenameDialog::_postprocess(const String &subject) { } void RenameDialog::_iterate_scene(const Node *node, const Array &selection, int *counter) { - if (!node) + if (!node) { return; + } if (selection.has(node)) { String new_name = _apply_rename(node, *counter); -- cgit v1.2.3