|
|
|
|
@ -50,7 +50,7 @@ std::string clangmm::Cursor::get_usr_extended() const {
|
|
|
|
|
for(size_t i=0;i<spelling.size();++i) { |
|
|
|
|
if(spelling[i]=='<' || spelling[i]=='(') { |
|
|
|
|
if(i>0 && spelling[0]=='~') |
|
|
|
|
return spelling.substr(1, i); |
|
|
|
|
return spelling.substr(1, i-1); |
|
|
|
|
return spelling.substr(0, i); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -62,16 +62,18 @@ std::string clangmm::Cursor::get_usr_extended() const {
|
|
|
|
|
auto cursor=*this; |
|
|
|
|
auto kind=cursor.get_kind(); |
|
|
|
|
// If constructor, destructor or function template, and the token spelling is equal, set cursor to parent
|
|
|
|
|
if(kind==clangmm::Cursor::Kind::Constructor || kind==clangmm::Cursor::Kind::Destructor || |
|
|
|
|
kind==clangmm::Cursor::Kind::FunctionTemplate) { |
|
|
|
|
if(kind==Cursor::Kind::Constructor || kind==Cursor::Kind::Destructor || |
|
|
|
|
kind==Cursor::Kind::FunctionTemplate) { |
|
|
|
|
auto parent=cursor.get_semantic_parent(); |
|
|
|
|
if(token_spelling(cursor.get_spelling())==token_spelling(parent.get_spelling())) |
|
|
|
|
auto parent_kind=parent.get_kind(); |
|
|
|
|
if((parent_kind==Cursor::Kind::ClassDecl || parent_kind==Cursor::Kind::StructDecl || parent_kind==Cursor::Kind::ClassTemplate) && |
|
|
|
|
token_spelling(cursor.get_spelling())==token_spelling(parent.get_spelling())) |
|
|
|
|
cursor=parent; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string usr=token_spelling(cursor.get_spelling()); |
|
|
|
|
cursor=cursor.get_semantic_parent(); |
|
|
|
|
while((kind=cursor.get_kind())!=Kind::TranslationUnit && cursor.is_valid_kind()) { |
|
|
|
|
auto parent=cursor.get_semantic_parent(); |
|
|
|
|
while((kind=parent.get_kind())!=Kind::TranslationUnit && parent.is_valid_kind()) { |
|
|
|
|
if(kind==Kind::CXXMethod || kind==Kind::FunctionDecl || kind==Kind::FunctionTemplate || |
|
|
|
|
kind==Kind::Constructor || kind==Kind::Destructor) { |
|
|
|
|
auto canonical=cursor.get_canonical(); |
|
|
|
|
@ -79,8 +81,8 @@ std::string clangmm::Cursor::get_usr_extended() const {
|
|
|
|
|
auto offset=location.get_offset(); |
|
|
|
|
return std::to_string(offset.line)+':'+std::to_string(offset.index)+':'+location.get_path(); |
|
|
|
|
} |
|
|
|
|
usr+=':'+token_spelling(cursor.get_spelling()); |
|
|
|
|
cursor=cursor.get_semantic_parent(); |
|
|
|
|
usr+=':'+token_spelling(parent.get_spelling()); |
|
|
|
|
parent=parent.get_semantic_parent(); |
|
|
|
|
} |
|
|
|
|
return usr; |
|
|
|
|
} |
|
|
|
|
|