|
|
|
@ -1577,61 +1577,62 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file |
|
|
|
return std::string(); |
|
|
|
return std::string(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
get_methods = [this]() { |
|
|
|
if(language && (language->get_id() == "chdr" || language->get_id() == "cpphdr")) { |
|
|
|
std::vector<std::pair<Offset, std::string>> methods; |
|
|
|
get_methods = [this]() { |
|
|
|
if(!parsed) { |
|
|
|
std::vector<std::pair<Offset, std::string>> methods; |
|
|
|
Info::get().print("Buffer is parsing"); |
|
|
|
if(!parsed) { |
|
|
|
return methods; |
|
|
|
Info::get().print("Buffer is parsing"); |
|
|
|
} |
|
|
|
return methods; |
|
|
|
clangmm::Offset last_offset{static_cast<unsigned>(-1), static_cast<unsigned>(-1)}; |
|
|
|
} |
|
|
|
for(auto &token : *clang_tokens) { |
|
|
|
clangmm::Offset last_offset{static_cast<unsigned>(-1), static_cast<unsigned>(-1)}; |
|
|
|
if(token.is_identifier()) { |
|
|
|
for(auto &token : *clang_tokens) { |
|
|
|
auto cursor = token.get_cursor(); |
|
|
|
if(token.is_identifier()) { |
|
|
|
auto kind = cursor.get_kind(); |
|
|
|
auto cursor = token.get_cursor(); |
|
|
|
if(kind == clangmm::Cursor::Kind::FunctionDecl || kind == clangmm::Cursor::Kind::CXXMethod || |
|
|
|
auto kind = cursor.get_kind(); |
|
|
|
kind == clangmm::Cursor::Kind::Constructor || kind == clangmm::Cursor::Kind::Destructor || |
|
|
|
if(kind == clangmm::Cursor::Kind::FunctionDecl || kind == clangmm::Cursor::Kind::CXXMethod || |
|
|
|
kind == clangmm::Cursor::Kind::FunctionTemplate || kind == clangmm::Cursor::Kind::ConversionFunction) { |
|
|
|
kind == clangmm::Cursor::Kind::Constructor || kind == clangmm::Cursor::Kind::Destructor || |
|
|
|
auto offset = cursor.get_source_location().get_offset(); |
|
|
|
kind == clangmm::Cursor::Kind::FunctionTemplate || kind == clangmm::Cursor::Kind::ConversionFunction) { |
|
|
|
if(offset == last_offset) |
|
|
|
auto offset = cursor.get_source_location().get_offset(); |
|
|
|
continue; |
|
|
|
if(offset == last_offset) |
|
|
|
last_offset = offset; |
|
|
|
continue; |
|
|
|
|
|
|
|
last_offset = offset; |
|
|
|
std::string prefix; |
|
|
|
|
|
|
|
auto parent = cursor.get_semantic_parent(); |
|
|
|
std::string scope; |
|
|
|
while(parent && parent.get_kind() != clangmm::Cursor::Kind::TranslationUnit) { |
|
|
|
auto parent = cursor.get_semantic_parent(); |
|
|
|
prefix.insert(0, parent.get_display_name() + (prefix.empty() ? "" : "::")); |
|
|
|
while(parent && parent.get_kind() != clangmm::Cursor::Kind::TranslationUnit) { |
|
|
|
parent = parent.get_semantic_parent(); |
|
|
|
scope.insert(0, parent.get_display_name() + (scope.empty() ? "" : "::")); |
|
|
|
} |
|
|
|
parent = parent.get_semantic_parent(); |
|
|
|
if(!prefix.empty()) |
|
|
|
} |
|
|
|
prefix += ':'; |
|
|
|
if(!scope.empty()) |
|
|
|
prefix += std::to_string(offset.line) + ": "; |
|
|
|
scope += "::"; |
|
|
|
prefix = Glib::Markup::escape_text(prefix); |
|
|
|
scope = Glib::Markup::escape_text(scope); |
|
|
|
|
|
|
|
|
|
|
|
std::string ret; |
|
|
|
std::string ret; |
|
|
|
if(kind != clangmm::Cursor::Kind::Constructor && kind != clangmm::Cursor::Kind::Destructor) { |
|
|
|
if(kind != clangmm::Cursor::Kind::Constructor && kind != clangmm::Cursor::Kind::Destructor) { |
|
|
|
ret += cursor.get_type().get_result().get_spelling(); |
|
|
|
ret += cursor.get_type().get_result().get_spelling(); |
|
|
|
if(!ret.empty() && ret.back() != '&' && ret.back() != '*') |
|
|
|
if(!ret.empty() && ret.back() != '&' && ret.back() != '*') |
|
|
|
ret += ' '; |
|
|
|
ret += ' '; |
|
|
|
} |
|
|
|
} |
|
|
|
ret = Glib::Markup::escape_text(ret); |
|
|
|
ret = Glib::Markup::escape_text(ret); |
|
|
|
|
|
|
|
|
|
|
|
auto method = Glib::Markup::escape_text(cursor.get_display_name()); |
|
|
|
auto method = Glib::Markup::escape_text(cursor.get_display_name()); |
|
|
|
// Add bold method token
|
|
|
|
// Add bold method token
|
|
|
|
auto end = method.find('('); |
|
|
|
auto end = method.find('('); |
|
|
|
if(end == std::string::npos) |
|
|
|
if(end == std::string::npos) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
method.insert(end, "</b>"); |
|
|
|
method.insert(end, "</b>"); |
|
|
|
method.insert(0, "<b>"); |
|
|
|
method.insert(0, "<b>"); |
|
|
|
|
|
|
|
|
|
|
|
methods.emplace_back(Offset(offset.line - 1, offset.index - 1), prefix + ret + method); |
|
|
|
methods.emplace_back(Offset(offset.line - 1, offset.index - 1), std::to_string(offset.line) + ": " + ret + scope + method); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(methods.empty()) |
|
|
|
if(methods.empty()) |
|
|
|
Info::get().print("No methods found in current buffer"); |
|
|
|
Info::get().print("No methods found in current buffer"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return methods; |
|
|
|
return methods; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
get_token_data = [this]() -> std::vector<std::string> { |
|
|
|
get_token_data = [this]() -> std::vector<std::string> { |
|
|
|
clangmm::Cursor cursor; |
|
|
|
clangmm::Cursor cursor; |
|
|
|
|