From 043e9a4d44bd852494838057c4e07abb6a2d7205 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 21 Dec 2017 22:46:45 -0800 Subject: [PATCH] [indexer] Fix hover info of class member functions --- src/indexer.cc | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/indexer.cc b/src/indexer.cc index 397d69d1..91b40f03 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -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 container_cursor_to_qualified_name; @@ -73,7 +87,8 @@ struct NamespaceHelper { ClangCursor cursor = container->cursor; std::vector 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) {