Browse Source

Added Source::is_implementation

merge-requests/365/head
eidheim 9 years ago
parent
commit
ce2d116cee
  1. 1
      src/source.h
  2. 15
      src/source_clang.cc

1
src/source.h

@ -68,6 +68,7 @@ namespace Source {
std::function<void()> non_interactive_completion; std::function<void()> non_interactive_completion;
std::function<void()> format_style; std::function<void()> format_style;
std::function<Offset()> get_declaration_location; std::function<Offset()> get_declaration_location;
std::function<bool()> is_implementation;
std::function<std::vector<Offset>(const std::vector<Source::View*> &views)> get_implementation_locations; std::function<std::vector<Offset>(const std::vector<Source::View*> &views)> get_implementation_locations;
std::function<std::vector<std::pair<Offset, std::string> >(const std::vector<Source::View*> &views)> get_usages; std::function<std::vector<std::pair<Offset, std::string> >(const std::vector<Source::View*> &views)> get_usages;
std::function<std::string()> get_method; std::function<std::string()> get_method;

15
src/source_clang.cc

@ -1078,6 +1078,21 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
return Offset(); return Offset();
}; };
is_implementation=[this]() {
if(!parsed)
return false;
auto iter=get_buffer()->get_insert()->get_iter();
auto line=static_cast<unsigned>(iter.get_line());
auto index=static_cast<unsigned>(iter.get_line_index());
for(auto &token: *clang_tokens) {
if(token.is_identifier()) {
if(line==token.offsets.first.line-1 && index>=token.offsets.first.index-1 && index <=token.offsets.second.index-1)
return clang_isCursorDefinition(token.get_cursor().cx_cursor)>0;
}
}
return false;
};
get_implementation_locations=[this](const std::vector<Source::View*> &views){ get_implementation_locations=[this](const std::vector<Source::View*> &views){
std::vector<Offset> locations; std::vector<Offset> locations;
if(!parsed) { if(!parsed) {

Loading…
Cancel
Save