From b18935d82c70c6589692e89655a18c492351c458 Mon Sep 17 00:00:00 2001 From: eidheim Date: Tue, 22 Sep 2015 08:42:59 +0200 Subject: [PATCH] Fixed get_similar_token_offsets. --- src/Tokens.cc | 8 ++++---- src/Tokens.h | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Tokens.cc b/src/Tokens.cc index 5c82828..2b8e603 100644 --- a/src/Tokens.cc +++ b/src/Tokens.cc @@ -24,14 +24,14 @@ clang::Tokens::~Tokens() { //This works across TranslationUnits! However, to get rename refactoring to work, //one have to open all the files that might include a similar token //Similar tokens defined as tokens with equal referenced cursors. -std::vector > clang::Tokens::get_similar_token_offsets(const std::string &usr, CursorKind kind) { +std::vector > clang::Tokens::get_similar_token_offsets(CursorKind kind, + const std::string &spelling, + const std::string &usr) { std::vector > offsets; for(auto &token: *this) { if(token.get_kind()==clang::Token_Identifier) { - if(static_cast(token.get_cursor().get_kind())==103) //These cursors are buggy - continue; auto referenced=token.get_cursor().get_referenced(); - if(referenced && kind==referenced.get_kind() && usr==referenced.get_usr()) + if(referenced && kind==referenced.get_kind() && spelling==token.get_spelling() && usr==referenced.get_usr()) offsets.emplace_back(token.offsets); } } diff --git a/src/Tokens.h b/src/Tokens.h index c907b96..a6f0648 100644 --- a/src/Tokens.h +++ b/src/Tokens.h @@ -13,7 +13,9 @@ namespace clang { Tokens(CXTranslationUnit &cx_tu, const SourceRange &range); public: ~Tokens(); - std::vector > get_similar_token_offsets(const std::string &usr, CursorKind kind); + std::vector > get_similar_token_offsets(CursorKind kind, + const std::string &spelling, + const std::string &usr); std::vector > get_cxx_methods(); private: CXToken *cx_tokens;