From 29345f067ca18d757d9bae2b06cbd18e96d87da0 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 7 Jan 2018 01:07:39 -0800 Subject: [PATCH] Set {func,type}->def.kind --- src/indexer.cc | 33 +++++++++++++++++++++++++++++++++ src/message_handler.cc | 1 + 2 files changed, 34 insertions(+) diff --git a/src/indexer.cc b/src/indexer.cc index 75d440c5..c141e966 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -47,6 +47,35 @@ bool IsScopeSemanticContainer(CXCursorKind kind) { } } +ClangSymbolKind GetSymbolKind(CXIdxEntityKind kind) { + switch (kind) { + default: + return ClangSymbolKind::Unknown; + case CXIdxEntity_CXXConstructor: + return ClangSymbolKind::Constructor; + case CXIdxEntity_CXXDestructor: + return ClangSymbolKind::Destructor; + case CXIdxEntity_CXXStaticMethod: + case CXIdxEntity_ObjCClassMethod: + return ClangSymbolKind::StaticMethod; + case CXIdxEntity_CXXInstanceMethod: + case CXIdxEntity_ObjCInstanceMethod: + return ClangSymbolKind::InstanceMethod; + case CXIdxEntity_Function: + return ClangSymbolKind::Function; + + case CXIdxEntity_Enum: + return ClangSymbolKind::Enum; + case CXIdxEntity_CXXClass: + case CXIdxEntity_ObjCClass: + return ClangSymbolKind::Class; + case CXIdxEntity_Struct: + return ClangSymbolKind::Struct; + case CXIdxEntity_Union: + return ClangSymbolKind::Union; + } +} + // Caches all instances of constructors, regardless if they are indexed or not. // The constructor may have a make_unique call associated with it that we need @@ -1289,6 +1318,7 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) { IndexFuncId func_id = db->ToFuncId(decl_cursor_resolved.cx_cursor); IndexFunc* func = db->Resolve(func_id); func->def.comments = decl_cursor.get_comments(); + func->def.kind = GetSymbolKind(decl->entityInfo->kind); // We don't actually need to know the return type, but we need to mark it // as an interesting usage. @@ -1436,6 +1466,7 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) { type->def.short_name = decl->entityInfo->name; type->def.detailed_name = ns->QualifiedName(decl->semanticContainer, type->def.short_name); + type->def.kind = ClangSymbolKind::TypeAlias; type->def.comments = decl_cursor.get_comments(); @@ -1490,6 +1521,8 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) { type->def.detailed_name = ns->QualifiedName(decl->semanticContainer, type->def.short_name); + type->def.kind = GetSymbolKind(decl->entityInfo->kind); + type->def.comments = decl_cursor.get_comments(); // } diff --git a/src/message_handler.cc b/src/message_handler.cc index 2c669c0a..ebe76abd 100644 --- a/src/message_handler.cc +++ b/src/message_handler.cc @@ -131,6 +131,7 @@ void EmitSemanticHighlighting(QueryDatabase* db, case ClangSymbolKind::Field: case ClangSymbolKind::Macro: case ClangSymbolKind::Module: + case ClangSymbolKind::Parameter: case ClangSymbolKind::Variable: break; default: