|
|
|
@ -922,19 +922,20 @@ Source::ClangViewAutocomplete(file_path, language) { |
|
|
|
get_implementation_location=[this](const Token &token){ |
|
|
|
get_implementation_location=[this](const Token &token){ |
|
|
|
Offset location; |
|
|
|
Offset location; |
|
|
|
if(parsed && this->language && this->language->get_id()!="chdr" && this->language->get_id()!="cpphdr") { |
|
|
|
if(parsed && this->language && this->language->get_id()!="chdr" && this->language->get_id()!="cpphdr") { |
|
|
|
for(auto &a_token: *clang_tokens) { |
|
|
|
for(auto token_it=clang_tokens->rbegin();token_it!=clang_tokens->rend();++token_it) { |
|
|
|
auto cursor=a_token.get_cursor(); |
|
|
|
auto cursor=token_it->get_cursor(); |
|
|
|
auto kind=cursor.get_kind(); |
|
|
|
auto kind=cursor.get_kind(); |
|
|
|
if((kind==clang::CursorKind::CXXMethod || kind==clang::CursorKind::Constructor || kind==clang::CursorKind::Destructor) && |
|
|
|
if((kind==clang::CursorKind::FunctionDecl || kind==clang::CursorKind::CXXMethod || |
|
|
|
a_token.get_kind()==clang::Token_Identifier && cursor.has_type()) { |
|
|
|
kind==clang::CursorKind::Constructor || kind==clang::CursorKind::Destructor) && |
|
|
|
|
|
|
|
token_it->get_kind()==clang::Token_Identifier && cursor.has_type()) { |
|
|
|
auto referenced=cursor.get_referenced(); |
|
|
|
auto referenced=cursor.get_referenced(); |
|
|
|
if(referenced && static_cast<clang::CursorKind>(token.type)==referenced.get_kind() && |
|
|
|
if(referenced && static_cast<clang::CursorKind>(token.type)==referenced.get_kind() && |
|
|
|
token.spelling==a_token.get_spelling() && token.usr==referenced.get_usr()) { |
|
|
|
token.spelling==token_it->get_spelling() && token.usr==referenced.get_usr()) { |
|
|
|
location.file_path=cursor.get_source_location().get_path(); |
|
|
|
location.file_path=cursor.get_source_location().get_path(); |
|
|
|
auto clang_offset=cursor.get_source_location().get_offset(); |
|
|
|
auto clang_offset=cursor.get_source_location().get_offset(); |
|
|
|
location.line=clang_offset.line; |
|
|
|
location.line=clang_offset.line; |
|
|
|
location.index=clang_offset.index; |
|
|
|
location.index=clang_offset.index; |
|
|
|
//do not break here, choose last occurrence in case declaration and implementation is in the same file
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|