Browse Source

use space before comment

merge-requests/413/head
Jørgen Sverre Lien Sellæg 4 years ago
parent
commit
e81b8f78b4
  1. 2
      src/cmake.cpp
  2. 4
      src/ctags.cpp
  3. 8
      src/debug_lldb.cpp
  4. 2
      src/debug_lldb.hpp
  5. 4
      src/filesystem.cpp
  6. 2
      src/git.cpp
  7. 4
      src/git.hpp
  8. 9
      src/info.cpp
  9. 4
      src/juci.cpp
  10. 9
      src/notebook.cpp
  11. 2
      src/notebook.hpp
  12. 1
      src/project_build.hpp
  13. 8
      src/selection_dialog.cpp
  14. 4
      src/source_base.cpp
  15. 8
      src/source_diff.cpp
  16. 6
      src/source_spellcheck.cpp
  17. 2
      src/terminal.cpp
  18. 2
      src/tooltips.cpp
  19. 2
      src/usages_clang.cpp
  20. 8
      tests/language_protocol_client_test.cpp
  21. 16
      tests/source_clang_test.cpp
  22. 8
      tests/source_key_test.cpp
  23. 8
      tests/source_test.cpp
  24. 8
      tests/terminal_test.cpp
  25. 8
      tests/usages_clang_test.cpp

2
src/cmake.cpp

@ -82,7 +82,7 @@ bool CMake::update_default_build(const boost::filesystem::path &default_build_pa
}
message.hide();
if(exit_status == 0) {
#ifdef _WIN32 //Temporary fix to MSYS2's libclang
#ifdef _WIN32 // Temporary fix to MSYS2's libclang
auto compile_commands_file = filesystem::read(compile_commands_path);
auto replace_drive = [&compile_commands_file](const std::string &param) {
size_t pos = 0;

4
src/ctags.cpp

@ -238,7 +238,7 @@ std::vector<Ctags::Location> Ctags::get_locations(const boost::filesystem::path
if(!ctags)
return {};
//insert name into type
// insert name into type
size_t c = 0;
size_t bracket_count = 0;
for(; c < type.size(); ++c) {
@ -272,7 +272,7 @@ std::vector<Ctags::Location> Ctags::get_locations(const boost::filesystem::path
auto source_parts = get_type_parts(location.source);
//Find match score
// Find match score
long score = 0;
size_t source_index = 0;
for(auto &part : parts) {

8
src/debug_lldb.cpp

@ -102,7 +102,7 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat
listener = std::make_unique<lldb::SBListener>("juCi++ lldb listener");
}
//Create executable string and argument array
// Create executable string and argument array
auto parsed_run_arguments = parse_run_arguments(command);
auto &environment_from_arguments = std::get<0>(parsed_run_arguments);
auto &executable = std::get<1>(parsed_run_arguments);
@ -127,7 +127,7 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat
return;
}
//Set breakpoints
// Set breakpoints
for(auto &breakpoint : breakpoints) {
if(!(target.BreakpointCreateByLocation(breakpoint.first.string().c_str(), breakpoint.second)).IsValid()) {
Terminal::get().async_print("\e[31mError (debug)\e[m: Could not create breakpoint at: " + breakpoint.first.string() + ":" + std::to_string(breakpoint.second) + '\n', true);
@ -244,7 +244,7 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat
while((n = process->GetSTDOUT(buffer, buffer_size)) != 0)
Terminal::get().async_print(std::string(buffer, n));
}
//TODO: for some reason stderr is redirected to stdout
// TODO: for some reason stderr is redirected to stdout
if((event.GetType() & lldb::SBProcess::eBroadcastBitSTDERR) > 0) {
char buffer[buffer_size];
size_t n;
@ -427,7 +427,7 @@ std::string Debug::LLDB::get_value(const std::string &variable, const boost::fil
auto frame = process->GetSelectedThread().GetSelectedFrame();
auto values = frame.GetVariables(true, true, true, false);
//First try to find variable based on name, file and line number
// First try to find variable based on name, file and line number
if(!file_path.empty()) {
for(uint32_t value_index = 0; value_index < values.GetSize(); value_index++) {
lldb::SBStream stream;

2
src/debug_lldb.hpp

@ -59,7 +59,7 @@ namespace Debug {
void start(const std::string &command, const boost::filesystem::path &path = "",
const std::vector<std::pair<boost::filesystem::path, int>> &breakpoints = {},
const std::vector<std::string> &startup_commands = {}, const std::string &remote_host = "") EXCLUDES(mutex);
void continue_debug() EXCLUDES(mutex); //can't use continue as function name
void continue_debug() EXCLUDES(mutex); // can't use continue as function name
void stop() EXCLUDES(mutex);
void kill() EXCLUDES(mutex);
void step_over() EXCLUDES(mutex);

4
src/filesystem.cpp

@ -10,7 +10,7 @@ boost::optional<boost::filesystem::path> filesystem::rust_sysroot_path;
boost::optional<boost::filesystem::path> filesystem::rust_nightly_sysroot_path;
boost::optional<std::vector<boost::filesystem::path>> filesystem::executable_search_paths;
//Only use on small files
// Only use on small files
std::string filesystem::read(const std::string &path) {
std::string str;
std::ifstream input(path, std::ios::binary);
@ -25,7 +25,7 @@ std::string filesystem::read(const std::string &path) {
return str;
}
//Only use on small files
// Only use on small files
bool filesystem::write(const std::string &path, const std::string &new_content) {
std::ofstream output(path, std::ios::binary);
if(output)

2
src/git.cpp

@ -38,7 +38,7 @@ Git::Repository::Diff::Lines Git::Repository::Diff::get_lines(const std::string
LockGuard lock(mutex);
error.code = git_diff_blob_to_buffer(
blob.get(), nullptr, buffer.c_str(), buffer.size(), nullptr, &options, nullptr, nullptr, [](const git_diff_delta *delta, const git_diff_hunk *hunk, void *payload) {
//Based on https://github.com/atom/git-diff/blob/master/lib/git-diff-view.coffee
// Based on https://github.com/atom/git-diff/blob/master/lib/git-diff-view.coffee
auto lines = static_cast<Lines *>(payload);
auto start = hunk->new_start - 1;
auto end = hunk->new_start + hunk->new_lines - 1;

4
src/git.hpp

@ -91,12 +91,12 @@ public:
private:
static bool initialized GUARDED_BY(mutex);
///Mutex for thread safe operations
/// Mutex for thread safe operations
static Mutex mutex;
static Error error GUARDED_BY(mutex);
///Call initialize in public static methods
/// Call initialize in public static methods
static void initialize() noexcept REQUIRES(mutex);
static boost::filesystem::path path(const char *cpath, boost::optional<size_t> cpath_length = {}) noexcept REQUIRES(mutex);

9
src/info.cpp

@ -11,9 +11,9 @@ Info::Info() {
get_style_context()->add_class("juci_info");
//Workaround from https://bugzilla.gnome.org/show_bug.cgi?id=710888
//Issue described at the same issue report
//TODO: remove later
// Workaround from https://bugzilla.gnome.org/show_bug.cgi?id=710888
// Issue described at the same issue report
// TODO: remove later
auto revealer = gtk_widget_get_template_child(GTK_WIDGET(gobj()), GTK_TYPE_INFO_BAR, "revealer");
if(revealer) {
gtk_revealer_set_transition_type(GTK_REVEALER(revealer), GTK_REVEALER_TRANSITION_TYPE_NONE);
@ -21,9 +21,10 @@ Info::Info() {
}
}
void Info::print(const std::string &text) {
timeout_connection.disconnect();
//Timeout based on https://en.wikipedia.org/wiki/Words_per_minute
// Timeout based on https://en.wikipedia.org/wiki/Words_per_minute
//(average_words_per_minute*average_letters_per_word)/60 => (228*4.5)/60 = 17.1
double timeout = 1000.0 * std::max(3.0, 1.0 + text.size() / 17.1);
timeout_connection = Glib::signal_timeout().connect(

4
src/juci.cpp

@ -38,7 +38,7 @@ int Application::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>
else if(boost::filesystem::is_directory(path, ec))
directories.emplace_back(path);
}
//Open new file if parent path exists
// Open new file if parent path exists
else {
if(path.is_absolute() && boost::filesystem::is_directory(path.parent_path(), ec))
files.emplace_back(path, 0);
@ -134,7 +134,7 @@ void Application::on_startup() {
Application::Application() : Gtk::Application("no.sout.juci", Gio::APPLICATION_NON_UNIQUE | Gio::APPLICATION_HANDLES_COMMAND_LINE) {
Glib::set_application_name("juCi++");
//Gtk::MessageDialog without buttons caused text to be selected, this prevents that
// Gtk::MessageDialog without buttons caused text to be selected, this prevents that
Gtk::Settings::get_default()->property_gtk_label_select_on_focus() = false;
}

9
src/notebook.cpp

@ -13,6 +13,7 @@
#include <gtksourceview-3.0/gtksourceview/gtksourcemap.h>
#include <regex>
Notebook::TabLabel::TabLabel(const std::function<void()> &on_close) {
set_can_focus(false);
@ -115,7 +116,7 @@ Source::View *Notebook::get_current_view() {
if(view == current_view)
return view;
}
//In case there exist a tab that has not yet received focus again in a different notebook
// In case there exist a tab that has not yet received focus again in a different notebook
for(int notebook_index = 0; notebook_index < 2; ++notebook_index) {
auto page = notebooks[notebook_index].get_current_page();
if(page >= 0)
@ -463,7 +464,7 @@ bool Notebook::open(const boost::filesystem::path &file_path_, Position position
configure(source_views.size() - 1);
//Set up tab label
// Set up tab label
tab_labels.emplace_back(new TabLabel([this, view]() {
close(view);
}));
@ -836,8 +837,8 @@ void Notebook::toggle_split() {
pack2(notebooks[1], true, true);
set_position(get_width() / 2);
show_all();
//Make sure the position is correct
//TODO: report bug to gtk if it is not fixed in gtk3.22
// Make sure the position is correct
// TODO: report bug to gtk if it is not fixed in gtk3.22
Glib::signal_timeout().connect(
[this] {
set_position(get_width() / 2);

2
src/notebook.hpp

@ -87,7 +87,7 @@ private:
/// Throws if view is not found
std::pair<size_t, int> get_notebook_page(Source::View *view);
std::vector<Source::View *> source_views; //Is NOT freed in destructor, this is intended for quick program exit.
std::vector<Source::View *> source_views; // Is NOT freed in destructor, this is intended for quick program exit.
std::vector<std::unique_ptr<Gtk::Widget>> source_maps;
std::vector<std::unique_ptr<Gtk::ScrolledWindow>> scrolled_windows;
std::vector<std::unique_ptr<Gtk::Box>> hboxes;

1
src/project_build.hpp

@ -2,6 +2,7 @@
#include "cmake.hpp"
#include "meson.hpp"
#include <boost/filesystem.hpp>
#include <memory>
namespace Project {
class Build {

8
src/selection_dialog.cpp

@ -125,7 +125,7 @@ SelectionDialogBase::SelectionDialogBase(Source::BaseView *view_, const boost::o
auto screen_width = Gdk::Screen::get_default()->get_width();
root_x = root_x + window_width > screen_width ? screen_width - window_width : root_x;
window.move(root_x, root_y + 1); //TODO: replace 1 with some margin
window.move(root_x, root_y + 1); // TODO: replace 1 with some margin
}
}
else
@ -237,7 +237,7 @@ SelectionDialog::SelectionDialog(Source::BaseView *view, const boost::optional<G
search_entry.signal_changed().connect([this, search_text, filter_model]() {
*search_text = search_entry.get_text();
filter_model->refilter();
list_view_text.set_search_entry(search_entry); //TODO:Report the need of this to GTK's git (bug)
list_view_text.set_search_entry(search_entry); // TODO:Report the need of this to GTK's git (bug)
if(search_text->empty()) {
if(list_view_text.get_model()->children().size() > 0)
list_view_text.set_cursor(list_view_text.get_model()->get_path(list_view_text.get_model()->children().begin()));
@ -304,7 +304,7 @@ bool SelectionDialog::on_key_press(GdkEventKey *event) {
return false;
}
else if(show_search_entry) {
#ifdef __APPLE__ //OS X bug most likely: Gtk::Entry will not work if window is of type POPUP
#ifdef __APPLE__ // OS X bug most likely: Gtk::Entry will not work if window is of type POPUP
if(event->is_modifier)
return true;
else if(event->keyval == GDK_KEY_BackSpace) {
@ -379,7 +379,7 @@ CompletionDialog::CompletionDialog(Source::BaseView *view, const Gtk::TextIter &
search_entry.signal_changed().connect([this, search_text, filter_model]() {
*search_text = search_entry.get_text();
filter_model->refilter();
list_view_text.set_search_entry(search_entry); //TODO:Report the need of this to GTK's git (bug)
list_view_text.set_search_entry(search_entry); // TODO:Report the need of this to GTK's git (bug)
});
list_view_text.signal_row_activated().connect([this](const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *) {

4
src/source_base.cpp

@ -578,7 +578,7 @@ std::pair<char, unsigned> Source::BaseView::find_tab_char_and_size() {
long last_tab_count = 0;
bool single_quoted = false;
bool double_quoted = false;
//For bracket languages, TODO: add more language ids
// For bracket languages, TODO: add more language ids
if(is_bracket_language && language_id != "html") {
bool line_comment = false;
bool comment = false;
@ -1126,7 +1126,7 @@ bool Source::BaseView::on_key_press_event(GdkEventKey *event) {
scroll_to(get_buffer()->get_insert());
return true;
}
//Move cursor one paragraph up
// Move cursor one paragraph up
else if((event->keyval == GDK_KEY_Up || event->keyval == GDK_KEY_KP_Up) && (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_META_MASK)) == GDK_CONTROL_MASK) {
auto selection_start_iter = get_buffer()->get_selection_bound()->get_iter();
auto iter = get_buffer()->get_iter_at_line(get_buffer()->get_insert()->get_iter().get_line());

8
src/source_diff.cpp

@ -120,7 +120,7 @@ void Source::DiffView::configure() {
buffer_insert_connection = get_buffer()->signal_insert().connect(
[this](const Gtk::TextIter &iter, const Glib::ustring &text, int) {
//Do not perform git diff if no newline is added and line is already marked as added
// Do not perform git diff if no newline is added and line is already marked as added
if(!iter.starts_line() && iter.has_tag(renderer->tag_added)) {
bool newline = false;
for(auto &c : text.raw()) {
@ -132,7 +132,7 @@ void Source::DiffView::configure() {
if(!newline)
return;
}
//Remove tag_removed_above/below if newline is inserted
// Remove tag_removed_above/below if newline is inserted
else if(!text.empty() && text[0] == '\n' && iter.has_tag(renderer->tag_removed)) {
auto start_iter = get_buffer()->get_iter_at_line(iter.get_line());
auto end_iter = get_iter_at_line_end(iter.get_line());
@ -153,7 +153,7 @@ void Source::DiffView::configure() {
buffer_erase_connection = get_buffer()->signal_erase().connect(
[this](const Gtk::TextIter &start_iter, const Gtk::TextIter &end_iter) {
//Do not perform git diff if start_iter and end_iter is at the same line in addition to the line is tagged added
// Do not perform git diff if start_iter and end_iter is at the same line in addition to the line is tagged added
if(start_iter.get_line() == end_iter.get_line() && start_iter.has_tag(renderer->tag_added))
return;
@ -332,7 +332,7 @@ std::string Source::DiffView::get_diff_details() {
return details;
}
///Return repository diff instance. Throws exception on error
/// Return repository diff instance. Throws exception on error
std::unique_ptr<Git::Repository::Diff> Source::DiffView::get_diff() {
auto work_path = filesystem::get_normal_path(repository->get_work_path());
boost::filesystem::path relative_path;

6
src/source_spellcheck.cpp

@ -29,7 +29,7 @@ Source::SpellCheckView::SpellCheckView(const boost::filesystem::path &file_path,
},
false);
//The following signal is added in case SpellCheckView is not subclassed
// The following signal is added in case SpellCheckView is not subclassed
signal_key_press_event().connect([this](GdkEventKey *event) {
last_keyval = event->keyval;
return false;
@ -70,7 +70,7 @@ Source::SpellCheckView::SpellCheckView(const boost::filesystem::path &file_path,
}
else {
auto previous_iter = iter;
//When for instance using space to split two words
// When for instance using space to split two words
if(!iter.starts_line() && !iter.ends_line() && is_word_iter(iter) &&
previous_iter.backward_char() && !previous_iter.starts_line() && !is_word_iter(previous_iter)) {
auto first = previous_iter;
@ -374,7 +374,7 @@ bool Source::SpellCheckView::is_spellcheck_iter(const Gtk::TextIter &iter) {
if(comment_tag) {
if(iter.has_tag(comment_tag) && !iter.begins_tag(comment_tag))
return true;
//Exception at the end of /**/
// Exception at the end of /**/
else if(iter.ends_tag(comment_tag)) {
auto previous_iter = iter;
if(previous_iter.backward_char() && *previous_iter == '/') {

2
src/terminal.cpp

@ -554,7 +554,7 @@ void Terminal::clear() {
}
bool Terminal::on_button_press_event(GdkEventButton *button_event) {
//open clicked link in terminal
// open clicked link in terminal
if(button_event->type == GDK_BUTTON_PRESS && button_event->button == GDK_BUTTON_PRIMARY) {
Gtk::TextIter iter;
int location_x, location_y;

2
src/tooltips.cpp

@ -45,7 +45,7 @@ void Tooltip::show(bool disregard_drawn, const std::function<void()> &on_motion)
Tooltips::shown_tooltips.emplace(this);
if(!window) {
//init window
// init window
window = std::make_unique<Gtk::Window>(Gtk::WindowType::WINDOW_POPUP);
if(auto active_window = Glib::RefPtr<Gtk::Application>::cast_dynamic(Gtk::Application::get_default())->get_active_window())

2
src/usages_clang.cpp

@ -127,7 +127,7 @@ boost::optional<std::vector<Usages::Clang::Usages>> Usages::Clang::get_usages(co
PathSet visited;
auto usr_extended = cursor.get_usr_extended();
if(!usr_extended.empty() && usr_extended[0] >= '0' && usr_extended[0] <= '9') { //if declared within a function, return
if(!usr_extended.empty() && usr_extended[0] >= '0' && usr_extended[0] <= '9') { // if declared within a function, return
if(!translation_units.empty())
add_usages(project_path, build_path, boost::filesystem::path(), usages, visited, spelling, cursor, translation_units.front(), false);
return usages;

8
tests/language_protocol_client_test.cpp

@ -1,10 +1,10 @@
#include "source_language_protocol.hpp"
#include <glib.h>
//Requires display server to work
//However, it is possible to use the Broadway backend if the test is run in a pure terminal environment:
//broadwayd&
//make test
// Requires display server to work
// However, it is possible to use the Broadway backend if the test is run in a pure terminal environment:
// broadwayd&
// make test
void flush_events() {
while(Gtk::Main::events_pending())

16
tests/source_clang_test.cpp

@ -9,10 +9,10 @@ std::string main_error = R"(int main() {
}
)";
//Requires display server to work
//However, it is possible to use the Broadway backend if the test is run in a pure terminal environment:
//broadwayd&
//make test
// Requires display server to work
// However, it is possible to use the Broadway backend if the test is run in a pure terminal environment:
// broadwayd&
// make test
void flush_events() {
while(Gtk::Main::events_pending())
@ -40,7 +40,7 @@ int main() {
flush_events();
g_assert_cmpuint(clang_view->clang_diagnostics.size(), ==, 0);
//test get_declaration and get_implementation
// test get_declaration and get_implementation
clang_view->place_cursor_at_line_index(15, 7);
auto locations = clang_view->get_declaration_locations();
g_assert(locations.size() == 1);
@ -56,7 +56,7 @@ int main() {
g_assert(locations.size() == 1);
g_assert_cmpuint(locations[0].line, ==, 6);
//test get_usages and get_methods
// test get_usages and get_methods
{
auto locations = clang_view->get_usages();
g_assert_cmpuint(locations.size(), >, 0);
@ -65,7 +65,7 @@ int main() {
g_assert_cmpuint(locations.size(), >, 0);
}
//Test rename class (error if not constructor and destructor is renamed as well)
// Test rename class (error if not constructor and destructor is renamed as well)
auto saved_main = clang_view->get_buffer()->get_text();
clang_view->place_cursor_at_line_index(0, 6);
auto token = clang_view->get_token(clang_view->get_buffer()->get_insert()->get_iter());
@ -84,7 +84,7 @@ int main() {
clang_view->get_buffer()->set_text(saved_main);
clang_view->save();
//test error
// test error
clang_view->get_buffer()->set_text(main_error);
while(!clang_view->parsed)
flush_events();

8
tests/source_key_test.cpp

@ -2,10 +2,10 @@
#include "source.hpp"
#include <glib.h>
//Requires display server to work
//However, it is possible to use the Broadway backend if the test is run in a pure terminal environment:
//broadwayd&
//make test
// Requires display server to work
// However, it is possible to use the Broadway backend if the test is run in a pure terminal environment:
// broadwayd&
// make test
int main() {
auto app = Gtk::Application::create();

8
tests/source_test.cpp

@ -16,10 +16,10 @@ int main() {
}
)";
//Requires display server to work
//However, it is possible to use the Broadway backend if the test is run in a pure terminal environment:
//broadwayd&
//make test
// Requires display server to work
// However, it is possible to use the Broadway backend if the test is run in a pure terminal environment:
// broadwayd&
// make test
int main() {
auto app = Gtk::Application::create();

8
tests/terminal_test.cpp

@ -4,10 +4,10 @@
#include <glib.h>
#include <gtksourceviewmm.h>
//Requires display server to work
//However, it is possible to use the Broadway backend if the test is run in a pure terminal environment:
//broadwayd&
//make test
// Requires display server to work
// However, it is possible to use the Broadway backend if the test is run in a pure terminal environment:
// broadwayd&
// make test
int main() {
auto app = Gtk::Application::create();

8
tests/usages_clang_test.cpp

@ -7,10 +7,10 @@
#include <fstream>
#include <gtksourceviewmm.h>
//Requires display server to work
//However, it is possible to use the Broadway backend if the test is run in a pure terminal environment:
//broadwayd&
//make test
// Requires display server to work
// However, it is possible to use the Broadway backend if the test is run in a pure terminal environment:
// broadwayd&
// make test
int main() {
auto app = Gtk::Application::create();

Loading…
Cancel
Save