[indexer] Fix hover info of class member functions

This commit is contained in:
Fangrui Song 2017-12-21 22:46:45 -08:00
parent 57b95d8a8c
commit 043e9a4d44

View File

@ -53,6 +53,20 @@ Range ResolveExtent(const CXCursor& cx_cursor, CXFile* cx_file = nullptr) {
return Resolve(cx_range, cx_file);
}
bool IsLocalSemanticContainer(CXCursorKind kind) {
switch (kind) {
case CXCursor_Namespace:
case CXCursor_TranslationUnit:
case CXCursor_StructDecl:
case CXCursor_UnionDecl:
case CXCursor_ClassDecl:
case CXCursor_EnumDecl:
return false;
default:
return true;
}
}
struct NamespaceHelper {
std::unordered_map<ClangCursor, std::string>
container_cursor_to_qualified_name;
@ -73,7 +87,8 @@ struct NamespaceHelper {
ClangCursor cursor = container->cursor;
std::vector<ClangCursor> namespaces;
std::string qualifier;
while (cursor.get_kind() == CXCursor_Namespace) {
while (cursor.get_kind() != CXCursor_TranslationUnit &&
!IsLocalSemanticContainer(cursor.get_kind())) {
auto it = container_cursor_to_qualified_name.find(cursor);
if (it != container_cursor_to_qualified_name.end()) {
qualifier = it->second;
@ -274,20 +289,6 @@ IndexFile* ConsumeFile(IndexParam* param, CXFile file) {
return db;
}
bool IsLocalSemanticContainer(CXCursorKind kind) {
switch (kind) {
case CXCursor_Namespace:
case CXCursor_TranslationUnit:
case CXCursor_StructDecl:
case CXCursor_UnionDecl:
case CXCursor_ClassDecl:
case CXCursor_EnumDecl:
return false;
default:
return true;
}
}
// Returns true if the given entity kind can be called implicitly, ie, without
// actually being written in the source code.
bool CanBeCalledImplicitly(CXIdxEntityKind kind) {