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/plugins/version_control_editor_plugin.cpp | 58 ------------------------ 1 file changed, 58 deletions(-) (limited to 'editor/plugins/version_control_editor_plugin.cpp') diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp index fe8392593b..a1436e123d 100644 --- a/editor/plugins/version_control_editor_plugin.cpp +++ b/editor/plugins/version_control_editor_plugin.cpp @@ -38,7 +38,6 @@ VersionControlEditorPlugin *VersionControlEditorPlugin::singleton = nullptr; void VersionControlEditorPlugin::_bind_methods() { - ClassDB::bind_method(D_METHOD("popup_vcs_set_up_dialog"), &VersionControlEditorPlugin::popup_vcs_set_up_dialog); // Used to track the status of files in the staging area @@ -50,20 +49,16 @@ void VersionControlEditorPlugin::_bind_methods() { } void VersionControlEditorPlugin::_selected_a_vcs(int p_id) { - List available_addons = get_available_vcs_names(); const StringName selected_vcs = set_up_choice->get_item_text(p_id); } void VersionControlEditorPlugin::_populate_available_vcs_names() { - static bool called = false; if (!called) { - List available_addons = get_available_vcs_names(); for (int i = 0; i < available_addons.size(); i++) { - set_up_choice->add_item(available_addons[i]); } @@ -72,16 +67,13 @@ void VersionControlEditorPlugin::_populate_available_vcs_names() { } VersionControlEditorPlugin *VersionControlEditorPlugin::get_singleton() { - return singleton ? singleton : memnew(VersionControlEditorPlugin); } void VersionControlEditorPlugin::popup_vcs_set_up_dialog(const Control *p_gui_base) { - fetch_available_vcs_addon_names(); List available_addons = get_available_vcs_names(); if (available_addons.size() >= 1) { - Size2 popup_size = Size2(400, 100); Size2 window_size = p_gui_base->get_viewport_rect().size; popup_size.x = MIN(window_size.x * 0.5, popup_size.x); @@ -91,13 +83,11 @@ void VersionControlEditorPlugin::popup_vcs_set_up_dialog(const Control *p_gui_ba set_up_dialog->popup_centered_clamped(popup_size * EDSCALE); } else { - EditorNode::get_singleton()->show_warning(TTR("No VCS addons are available."), TTR("Error")); } } void VersionControlEditorPlugin::_initialize_vcs() { - register_editor(); ERR_FAIL_COND_MSG(EditorVCSInterface::get_singleton(), EditorVCSInterface::get_singleton()->get_vcs_name() + " is already active"); @@ -129,18 +119,14 @@ void VersionControlEditorPlugin::_initialize_vcs() { } void VersionControlEditorPlugin::_send_commit_msg() { - String msg = commit_message->get_text(); if (msg == "") { - commit_status->set_text(TTR("No commit message was provided")); return; } if (EditorVCSInterface::get_singleton()) { - if (staged_files_count == 0) { - commit_status->set_text(TTR("No files added to stage")); return; } @@ -150,7 +136,6 @@ void VersionControlEditorPlugin::_send_commit_msg() { commit_message->set_text(""); version_control_dock_button->set_pressed(false); } else { - WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu"); } @@ -160,20 +145,16 @@ void VersionControlEditorPlugin::_send_commit_msg() { } void VersionControlEditorPlugin::_refresh_stage_area() { - if (EditorVCSInterface::get_singleton()) { - staged_files_count = 0; clear_stage_area(); Dictionary modified_file_paths = EditorVCSInterface::get_singleton()->get_modified_files_data(); String file_path; for (int i = 0; i < modified_file_paths.size(); i++) { - file_path = modified_file_paths.get_key_at_index(i); TreeItem *found = stage_files->search_item_text(file_path, nullptr, true); if (!found) { - ChangeType change_index = (ChangeType)(int)modified_file_paths.get_value_at_index(i); String change_text = file_path + " (" + change_type_to_strings[change_index] + ")"; Color &change_color = change_type_to_color[change_index]; @@ -185,24 +166,19 @@ void VersionControlEditorPlugin::_refresh_stage_area() { new_item->set_checked(0, true); new_item->set_editable(0, true); } else { - if (found->get_metadata(0) == diff_file_name->get_text()) { - _refresh_file_diff(); } } commit_status->set_text("New changes detected"); } } else { - WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu."); } } void VersionControlEditorPlugin::_stage_selected() { - if (!EditorVCSInterface::get_singleton()) { - WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu"); return; } @@ -210,17 +186,13 @@ void VersionControlEditorPlugin::_stage_selected() { staged_files_count = 0; TreeItem *root = stage_files->get_root(); if (root) { - TreeItem *file_entry = root->get_children(); while (file_entry) { - if (file_entry->is_checked(0)) { - EditorVCSInterface::get_singleton()->stage_file(file_entry->get_metadata(0)); file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor")); staged_files_count++; } else { - EditorVCSInterface::get_singleton()->unstage_file(file_entry->get_metadata(0)); file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); } @@ -233,9 +205,7 @@ void VersionControlEditorPlugin::_stage_selected() { } void VersionControlEditorPlugin::_stage_all() { - if (!EditorVCSInterface::get_singleton()) { - WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu"); return; } @@ -243,10 +213,8 @@ void VersionControlEditorPlugin::_stage_all() { staged_files_count = 0; TreeItem *root = stage_files->get_root(); if (root) { - TreeItem *file_entry = root->get_children(); while (file_entry) { - EditorVCSInterface::get_singleton()->stage_file(file_entry->get_metadata(0)); file_entry->set_icon_modulate(0, EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor")); file_entry->set_checked(0, true); @@ -260,7 +228,6 @@ void VersionControlEditorPlugin::_stage_all() { } void VersionControlEditorPlugin::_view_file_diff() { - version_control_dock_button->set_pressed(true); String file_path = stage_files->get_selected()->get_metadata(0); @@ -269,7 +236,6 @@ void VersionControlEditorPlugin::_view_file_diff() { } void VersionControlEditorPlugin::_display_file_diff(String p_file_path) { - Array diff_content = EditorVCSInterface::get_singleton()->get_file_diff(p_file_path); diff_file_name->set_text(p_file_path); @@ -277,17 +243,13 @@ void VersionControlEditorPlugin::_display_file_diff(String p_file_path) { diff->clear(); diff->push_font(EditorNode::get_singleton()->get_gui_base()->get_theme_font("source", "EditorFonts")); for (int i = 0; i < diff_content.size(); i++) { - Dictionary line_result = diff_content[i]; if (line_result["status"] == "+") { - diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("success_color", "Editor")); } else if (line_result["status"] == "-") { - diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("error_color", "Editor")); } else { - diff->push_color(EditorNode::get_singleton()->get_gui_base()->get_theme_color("font_color", "Label")); } @@ -299,42 +261,33 @@ void VersionControlEditorPlugin::_display_file_diff(String p_file_path) { } void VersionControlEditorPlugin::_refresh_file_diff() { - String open_file = diff_file_name->get_text(); if (open_file != "") { - _display_file_diff(diff_file_name->get_text()); } } void VersionControlEditorPlugin::_clear_file_diff() { - diff->clear(); diff_file_name->set_text(""); version_control_dock_button->set_pressed(false); } void VersionControlEditorPlugin::_update_stage_status() { - String status; if (staged_files_count == 1) { - status = "Stage contains 1 file"; } else { - status = "Stage contains " + String::num_int64(staged_files_count) + " files"; } commit_status->set_text(status); } void VersionControlEditorPlugin::_update_commit_status() { - String status; if (staged_files_count == 1) { - status = "Committed 1 file"; } else { - status = "Committed " + String::num_int64(staged_files_count) + " files "; } commit_status->set_text(status); @@ -342,9 +295,7 @@ void VersionControlEditorPlugin::_update_commit_status() { } void VersionControlEditorPlugin::register_editor() { - if (!EditorVCSInterface::get_singleton()) { - EditorNode::get_singleton()->add_control_to_dock(EditorNode::DOCK_SLOT_RIGHT_UL, version_commit_dock); TabContainer *dock_vbc = (TabContainer *)version_commit_dock->get_parent_control(); dock_vbc->set_tab_title(version_commit_dock->get_index(), TTR("Commit")); @@ -355,30 +306,25 @@ void VersionControlEditorPlugin::register_editor() { } void VersionControlEditorPlugin::fetch_available_vcs_addon_names() { - List global_classes; ScriptServer::get_global_class_list(&global_classes); for (int i = 0; i != global_classes.size(); i++) { - String path = ScriptServer::get_global_class_path(global_classes[i]); Ref