Browse Source

Added info messages when no action happens from menu items

merge-requests/365/head
eidheim 9 years ago
parent
commit
c9f2aa0fd7
  1. 8
      src/project.cc
  2. 23
      src/source_clang.cc
  3. 24
      src/source_diff.cc
  4. 2
      src/source_spellcheck.cc
  5. 8
      src/window.cc

8
src/project.cc

@ -479,8 +479,10 @@ void Project::Clang::debug_backtrace() {
auto iter=view->get_iter_for_dialog(); auto iter=view->get_iter_for_dialog();
view->selection_dialog=std::make_unique<SelectionDialog>(*view, view->get_buffer()->create_mark(iter), true, true); view->selection_dialog=std::make_unique<SelectionDialog>(*view, view->get_buffer()->create_mark(iter), true, true);
auto rows=std::make_shared<std::unordered_map<std::string, Debug::LLDB::Frame> >(); auto rows=std::make_shared<std::unordered_map<std::string, Debug::LLDB::Frame> >();
if(backtrace.size()==0) if(backtrace.size()==0) {
Info::get().print("No backtrace found");
return; return;
}
bool cursor_set=false; bool cursor_set=false;
for(auto &frame: backtrace) { for(auto &frame: backtrace) {
@ -529,8 +531,10 @@ void Project::Clang::debug_show_variables() {
auto iter=view->get_iter_for_dialog(); auto iter=view->get_iter_for_dialog();
view->selection_dialog=std::make_unique<SelectionDialog>(*view, view->get_buffer()->create_mark(iter), true, true); view->selection_dialog=std::make_unique<SelectionDialog>(*view, view->get_buffer()->create_mark(iter), true, true);
auto rows=std::make_shared<std::unordered_map<std::string, Debug::LLDB::Variable> >(); auto rows=std::make_shared<std::unordered_map<std::string, Debug::LLDB::Variable> >();
if(variables.size()==0) if(variables.size()==0) {
Info::get().print("No variables found");
return; return;
}
for(auto &variable: variables) { for(auto &variable: variables) {
std::string row="#"+std::to_string(variable.thread_index_id)+":#"+std::to_string(variable.frame_index)+":"+variable.file_path.filename().string()+":"+std::to_string(variable.line_nr)+" - <b>"+Glib::Markup::escape_text(variable.name)+"</b>"; std::string row="#"+std::to_string(variable.thread_index_id)+":#"+std::to_string(variable.frame_index)+":"+variable.file_path.filename().string()+":"+std::to_string(variable.line_nr)+" - <b>"+Glib::Markup::escape_text(variable.name)+"</b>";

23
src/source_clang.cc

@ -823,7 +823,10 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
Info::get().print("Buffer is parsing"); Info::get().print("Buffer is parsing");
return std::string(); return std::string();
} }
return get_identifier().spelling; auto identifier=get_identifier();
if(identifier.spelling.empty())
Info::get().print("No symbol found at current cursor location");
return identifier.spelling;
}; };
rename_similar_tokens=[this](const std::vector<Source::View*> &views, const std::string &text) { rename_similar_tokens=[this](const std::vector<Source::View*> &views, const std::string &text) {
@ -918,6 +921,7 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
auto offset=source_location.get_offset(); auto offset=source_location.get_offset();
return Offset(offset.line-1, offset.index-1, source_location.get_path()); return Offset(offset.line-1, offset.index-1, source_location.get_path());
} }
Info::get().print("No declaration found");
return Offset(); return Offset();
}; };
@ -989,9 +993,8 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
} }
return locations; return locations;
} }
Info::get().print("Could not find implementation");
} }
Info::get().print("No implementation found");
return locations; return locations;
}; };
@ -1046,7 +1049,8 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
} }
} }
} }
if(usages.empty())
Info::get().print("No symbol found at current cursor location");
return usages; return usages;
}; };
@ -1111,6 +1115,7 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
} }
} }
} }
Info::get().print("No method found at current cursor location");
return std::string(); return std::string();
}; };
@ -1178,6 +1183,8 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
} }
} }
} }
if(methods.empty())
Info::get().print("No methods found in current buffer");
return methods; return methods;
}; };
@ -1279,6 +1286,8 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
} }
} }
} }
if(data.empty())
Info::get().print("No symbol found at current cursor location");
return data; return data;
}; };
@ -1295,7 +1304,9 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
return; return;
} }
} }
if(diagnostic_offsets.size()>0) { if(diagnostic_offsets.size()==0)
Info::get().print("No diagnostics found in current buffer");
else {
auto iter=get_buffer()->get_iter_at_offset(*diagnostic_offsets.begin()); auto iter=get_buffer()->get_iter_at_offset(*diagnostic_offsets.begin());
get_buffer()->place_cursor(iter); get_buffer()->place_cursor(iter);
scroll_to(get_buffer()->get_insert(), 0.0, 1.0, 0.5); scroll_to(get_buffer()->get_insert(), 0.0, 1.0, 0.5);
@ -1307,6 +1318,8 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
Info::get().print("Buffer is parsing"); Info::get().print("Buffer is parsing");
return std::vector<FixIt>(); return std::vector<FixIt>();
} }
if(fix_its.empty())
Info::get().print("No fix-its found in current buffer");
return fix_its; return fix_its;
}; };
} }

24
src/source_diff.cc

@ -2,6 +2,7 @@
#include "config.h" #include "config.h"
#include "terminal.h" #include "terminal.h"
#include "filesystem.h" #include "filesystem.h"
#include "info.h"
#include <boost/version.hpp> #include <boost/version.hpp>
namespace sigc { namespace sigc {
@ -284,18 +285,23 @@ void Source::DiffView::git_goto_next_diff() {
wrapped=true; wrapped=true;
} }
} }
Info::get().print("No changes found in current buffer");
} }
std::string Source::DiffView::git_get_diff_details() { std::string Source::DiffView::git_get_diff_details() {
if(!diff) std::string details;
return std::string(); if(diff) {
auto line_nr=get_buffer()->get_insert()->get_iter().get_line(); auto line_nr=get_buffer()->get_insert()->get_iter().get_line();
auto iter=get_buffer()->get_iter_at_line(line_nr); auto iter=get_buffer()->get_iter_at_line(line_nr);
if(iter.has_tag(renderer->tag_removed_above)) if(iter.has_tag(renderer->tag_removed_above))
--line_nr; --line_nr;
std::unique_lock<std::mutex> lock(parse_mutex); std::unique_lock<std::mutex> lock(parse_mutex);
parse_buffer=get_buffer()->get_text(); parse_buffer=get_buffer()->get_text();
return diff->get_details(parse_buffer.raw(), line_nr); details=diff->get_details(parse_buffer.raw(), line_nr);
}
if(details.empty())
Info::get().print("No changes found at current line");
return details;
} }
///Return repository diff instance. Throws exception on error ///Return repository diff instance. Throws exception on error

2
src/source_spellcheck.cc

@ -1,5 +1,6 @@
#include "source_spellcheck.h" #include "source_spellcheck.h"
#include "config.h" #include "config.h"
#include "info.h"
#include <iostream> #include <iostream>
namespace sigc { namespace sigc {
@ -324,6 +325,7 @@ void Source::SpellCheckView::goto_next_spellcheck_error() {
wrapped=true; wrapped=true;
} }
} }
Info::get().print("No spelling errors found in current buffer");
} }
bool Source::SpellCheckView::is_code_iter(const Gtk::TextIter &iter) { bool Source::SpellCheckView::is_code_iter(const Gtk::TextIter &iter) {

8
src/window.cc

@ -438,10 +438,8 @@ void Window::set_menu_actions() {
menu.add_action("source_git_show_diff", [this]() { menu.add_action("source_git_show_diff", [this]() {
if(auto view=Notebook::get().get_current_view()) { if(auto view=Notebook::get().get_current_view()) {
auto diff_details=view->git_get_diff_details(); auto diff_details=view->git_get_diff_details();
if(diff_details.empty()) { if(diff_details.empty())
Info::get().print("Could not find any changes at the current line");
return; return;
}
std::string postfix; std::string postfix;
if(diff_details.size()>2) { if(diff_details.size()>2) {
size_t pos=diff_details.find("@@", 2); size_t pos=diff_details.find("@@", 2);
@ -483,8 +481,10 @@ void Window::set_menu_actions() {
auto path=std::move(pair.first); auto path=std::move(pair.first);
auto stream=std::move(pair.second); auto stream=std::move(pair.second);
stream->seekg(0, std::ios::end); stream->seekg(0, std::ios::end);
if(stream->tellg()==0) if(stream->tellg()==0) {
Info::get().print("No symbols found in current project");
return; return;
}
stream->seekg(0, std::ios::beg); stream->seekg(0, std::ios::beg);
auto dialog_iter=view->get_iter_for_dialog(); auto dialog_iter=view->get_iter_for_dialog();

Loading…
Cancel
Save