Browse Source

No longer shows info message when cancelling finding usages

pipelines/235045657
eidheim 5 years ago
parent
commit
d3105fdc63
  1. 9
      src/source_clang.cpp
  2. 4
      src/usages_clang.cpp
  3. 3
      src/usages_clang.hpp

9
src/source_clang.cpp

@ -1102,10 +1102,12 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
auto build = Project::Build::create(this->file_path); auto build = Project::Build::create(this->file_path);
auto usages = Usages::Clang::get_usages(build->project_path, build->get_default_path(), build->get_debug_path(), identifier.spelling, identifier.cursor, translation_units); auto usages = Usages::Clang::get_usages(build->project_path, build->get_default_path(), build->get_debug_path(), identifier.spelling, identifier.cursor, translation_units);
if(!usages)
return;
std::vector<Source::View *> renamed_views; std::vector<Source::View *> renamed_views;
std::vector<Usages::Clang::Usages *> usages_renamed; std::vector<Usages::Clang::Usages *> usages_renamed;
for(auto &usage : usages) { for(auto &usage : *usages) {
size_t line_c = usage.lines.size() - 1; size_t line_c = usage.lines.size() - 1;
auto view_it = views.end(); auto view_it = views.end();
for(auto it = views.begin(); it != views.end(); ++it) { for(auto it = views.begin(); it != views.end(); ++it) {
@ -1569,7 +1571,10 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
auto build = Project::Build::create(this->file_path); auto build = Project::Build::create(this->file_path);
auto usages_clang = Usages::Clang::get_usages(build->project_path, build->get_default_path(), build->get_debug_path(), {identifier.spelling}, {identifier.cursor}, translation_units); auto usages_clang = Usages::Clang::get_usages(build->project_path, build->get_default_path(), build->get_debug_path(), {identifier.spelling}, {identifier.cursor}, translation_units);
for(auto &usage : usages_clang) { if(!usages_clang)
return usages;
for(auto &usage : *usages_clang) {
for(size_t c = 0; c < usage.offsets.size(); ++c) { for(size_t c = 0; c < usage.offsets.size(); ++c) {
std::string line = Glib::Markup::escape_text(usage.lines[c]); std::string line = Glib::Markup::escape_text(usage.lines[c]);
embolden_token(line, usage.offsets[c].first.index - 1, usage.offsets[c].second.index - 1); embolden_token(line, usage.offsets[c].first.index - 1, usage.offsets[c].second.index - 1);

4
src/usages_clang.cpp

@ -115,12 +115,12 @@ std::vector<std::pair<clangmm::Offset, clangmm::Offset>> Usages::Clang::Cache::g
return offsets; return offsets;
} }
std::vector<Usages::Clang::Usages> Usages::Clang::get_usages(const boost::filesystem::path &project_path, const boost::filesystem::path &build_path, const boost::filesystem::path &debug_path, boost::optional<std::vector<Usages::Clang::Usages>> Usages::Clang::get_usages(const boost::filesystem::path &project_path, const boost::filesystem::path &build_path, const boost::filesystem::path &debug_path,
const std::string &spelling, const clangmm::Cursor &cursor, const std::vector<clangmm::TranslationUnit *> &translation_units) { const std::string &spelling, const clangmm::Cursor &cursor, const std::vector<clangmm::TranslationUnit *> &translation_units) {
std::vector<Usages> usages; std::vector<Usages> usages;
if(spelling.empty()) if(spelling.empty())
return usages; return {};
PathSet visited; PathSet visited;

3
src/usages_clang.hpp

@ -5,6 +5,7 @@
#include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_oarchive.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/optional.hpp>
#include <boost/serialization/map.hpp> #include <boost/serialization/map.hpp>
#include <boost/serialization/unordered_set.hpp> #include <boost/serialization/unordered_set.hpp>
#include <boost/serialization/vector.hpp> #include <boost/serialization/vector.hpp>
@ -108,7 +109,7 @@ namespace Usages {
static std::atomic<size_t> cache_in_progress_count; static std::atomic<size_t> cache_in_progress_count;
public: public:
static std::vector<Usages> get_usages(const boost::filesystem::path &project_path, const boost::filesystem::path &build_path, const boost::filesystem::path &debug_path, static boost::optional<std::vector<Usages>> get_usages(const boost::filesystem::path &project_path, const boost::filesystem::path &build_path, const boost::filesystem::path &debug_path,
const std::string &spelling, const clangmm::Cursor &cursor, const std::vector<clangmm::TranslationUnit *> &translation_units); const std::string &spelling, const clangmm::Cursor &cursor, const std::vector<clangmm::TranslationUnit *> &translation_units);
static void cache(const boost::filesystem::path &project_path, const boost::filesystem::path &build_path, const boost::filesystem::path &path, static void cache(const boost::filesystem::path &project_path, const boost::filesystem::path &build_path, const boost::filesystem::path &path,

Loading…
Cancel
Save