From ce2d116cee174fd27896f21d97281e7add37f98c Mon Sep 17 00:00:00 2001 From: eidheim Date: Mon, 20 Feb 2017 12:04:28 +0100 Subject: [PATCH] Added Source::is_implementation --- src/source.h | 1 + src/source_clang.cc | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/source.h b/src/source.h index 574afee..87d8b1a 100644 --- a/src/source.h +++ b/src/source.h @@ -68,6 +68,7 @@ namespace Source { std::function non_interactive_completion; std::function format_style; std::function get_declaration_location; + std::function is_implementation; std::function(const std::vector &views)> get_implementation_locations; std::function >(const std::vector &views)> get_usages; std::function get_method; diff --git a/src/source_clang.cc b/src/source_clang.cc index 4ae874e..c5efa0b 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -1078,6 +1078,21 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file return Offset(); }; + is_implementation=[this]() { + if(!parsed) + return false; + auto iter=get_buffer()->get_insert()->get_iter(); + auto line=static_cast(iter.get_line()); + auto index=static_cast(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 &views){ std::vector locations; if(!parsed) {