Browse Source

Improvement of implementation lookup of C/C++ symbols

pipelines/235045657
eidheim 6 years ago
parent
commit
fa6cc3c92a
  1. 9
      src/ctags.cpp
  2. 4
      src/ctags.hpp
  3. 2
      src/source_clang.cpp

9
src/ctags.cpp

@ -6,7 +6,7 @@
#include <climits>
#include <vector>
Ctags::Ctags(const boost::filesystem::path &path, bool enable_scope, bool enable_kind) : enable_scope(enable_scope), enable_kind(enable_kind) {
Ctags::Ctags(const boost::filesystem::path &path, bool enable_scope, bool enable_kind, const std::string &languages) : enable_scope(enable_scope), enable_kind(enable_kind) {
std::string fields(" --fields=n");
if(enable_scope)
fields += 's';
@ -24,7 +24,8 @@ Ctags::Ctags(const boost::filesystem::path &path, bool enable_scope, bool enable
}
else
project_path = path;
command = Config::get().project.ctags_command + exclude + fields + " --sort=foldcase -I \"override noexcept\" -f - -R *";
auto extra = !languages.empty() ? " --languages=" + languages : std::string();
command = Config::get().project.ctags_command + exclude + fields + extra + " --sort=foldcase -I \"override noexcept\" -f - -R *";
}
else {
project_path = path.parent_path();
@ -203,8 +204,8 @@ std::vector<std::string> Ctags::get_type_parts(const std::string &type) {
return parts;
}
std::vector<Ctags::Location> Ctags::get_locations(const boost::filesystem::path &path, const std::string &name, const std::string &type) {
Ctags ctags(path, true);
std::vector<Ctags::Location> Ctags::get_locations(const boost::filesystem::path &path, const std::string &name, const std::string &type, const std::string &languages) {
Ctags ctags(path, true, false, languages);
if(!ctags)
return {};

4
src/ctags.hpp

@ -18,7 +18,7 @@ public:
operator bool() const { return !file_path.empty(); }
};
Ctags(const boost::filesystem::path &path, bool enable_scope = false, bool enable_kind = false);
Ctags(const boost::filesystem::path &path, bool enable_scope = false, bool enable_kind = false, const std::string &languages = {});
operator bool();
@ -27,7 +27,7 @@ public:
boost::filesystem::path project_path;
std::stringstream output;
static std::vector<Location> get_locations(const boost::filesystem::path &path, const std::string &name, const std::string &type);
static std::vector<Location> get_locations(const boost::filesystem::path &path, const std::string &name, const std::string &type, const std::string &languages = {});
private:
bool enable_scope, enable_kind;

2
src/source_clang.cpp

@ -1391,7 +1391,7 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
name.insert(0, spelling);
parent = parent.get_semantic_parent();
}
auto ctags_locations = Ctags::get_locations(this->file_path.parent_path(), name, identifier.cursor.get_type_description());
auto ctags_locations = Ctags::get_locations(this->file_path.parent_path(), name, identifier.cursor.get_type_description(), is_cpp ? "C++,C" : "C");
if(!ctags_locations.empty()) {
for(auto &ctags_location : ctags_locations) {
Offset offset;

Loading…
Cancel
Save