diff --git a/src/Cursor.cc b/src/Cursor.cc index 7b61124..d5cbd9c 100644 --- a/src/Cursor.cc +++ b/src/Cursor.cc @@ -34,6 +34,10 @@ std::string clang::Cursor::get_spelling() const { return to_string(clang_getCursorSpelling(cx_cursor)); } +std::string clang::Cursor::get_display_name() const { + return to_string(clang_getCursorDisplayName(cx_cursor)); +} + std::string clang::Cursor::get_usr() const { return to_string(clang_getCursorUSR(cx_cursor)); } diff --git a/src/Cursor.h b/src/Cursor.h index 083f747..6d14003 100644 --- a/src/Cursor.h +++ b/src/Cursor.h @@ -193,6 +193,7 @@ namespace clang { SourceLocation get_source_location() const; SourceRange get_source_range() const; std::string get_spelling() const; + std::string get_display_name() const; std::string get_usr() const; Cursor get_referenced() const; Cursor get_canonical() const; diff --git a/src/Tokens.cc b/src/Tokens.cc index 1de9a07..ba8cc9f 100644 --- a/src/Tokens.cc +++ b/src/Tokens.cc @@ -1,7 +1,5 @@ #include "Tokens.h" #include "Utility.h" -#include //TODO: remove -using namespace std; //TODO: remove clang::Tokens::Tokens(CXTranslationUnit &cx_tu, const SourceRange &range): cx_tu(cx_tu) { clang_tokenize(cx_tu, range.cx_range, &cx_tokens, &num_tokens); @@ -36,40 +34,3 @@ std::vector > clang::Tokens::get_similar } return offsets; } - -std::vector > clang::Tokens::get_cxx_methods() { - std::vector > methods; - Offset last_offset={(unsigned)-1,(unsigned) -1}; - for(auto &token: *this) { - if(token.get_kind()==Token::Kind::Identifier) { - auto cursor=token.get_cursor(); - auto kind=cursor.get_kind(); - if(kind==Cursor::Kind::CXXMethod || kind==Cursor::Kind::Constructor || kind==Cursor::Kind::Destructor) { - auto offset=cursor.get_source_location().get_offset(); - if(offset!=last_offset) { - std::string method; - if(kind==Cursor::Kind::CXXMethod) { - auto type=clang_getResultType(clang_getCursorType(cursor.cx_cursor)); - method+=to_string(clang_getTypeSpelling(type)); - auto pos=method.find(" "); - if(pos!=std::string::npos) - method.erase(pos, 1); - method+=" "; - } - - std::string parent_str; - auto parent=cursor.get_semantic_parent(); - while(parent && parent.get_kind()!=Cursor::Kind::TranslationUnit) { - parent_str.insert(0, to_string(clang_getCursorDisplayName(parent.cx_cursor))+"::"); - parent=parent.get_semantic_parent(); - } - - method+=parent_str+to_string(clang_getCursorDisplayName(cursor.cx_cursor)); - methods.emplace_back(method, offset); - } - last_offset=offset; - } - } - } - return methods; -} diff --git a/src/Tokens.h b/src/Tokens.h index 13bd62a..6fb52ce 100644 --- a/src/Tokens.h +++ b/src/Tokens.h @@ -16,7 +16,6 @@ namespace clang { std::vector > get_similar_token_offsets(Cursor::Kind kind, const std::string &spelling, const std::string &usr); - std::vector > get_cxx_methods(); private: CXToken *cx_tokens; unsigned num_tokens;