mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 23:55:08 +00:00
Serialize {type,func}->def.kind for semantic highlighting
This commit is contained in:
parent
6661410483
commit
332a3b5240
@ -47,32 +47,61 @@ bool IsScopeSemanticContainer(CXCursorKind kind) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inverse of libclang/CXIndexDataConsumer.cpp getEntityKindFromSymbolKind
|
||||||
ClangSymbolKind GetSymbolKind(CXIdxEntityKind kind) {
|
ClangSymbolKind GetSymbolKind(CXIdxEntityKind kind) {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
default:
|
default:
|
||||||
return ClangSymbolKind::Unknown;
|
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:
|
case CXIdxEntity_Enum:
|
||||||
return ClangSymbolKind::Enum;
|
return ClangSymbolKind::Enum;
|
||||||
case CXIdxEntity_CXXClass:
|
|
||||||
case CXIdxEntity_ObjCClass:
|
|
||||||
return ClangSymbolKind::Class;
|
|
||||||
case CXIdxEntity_Struct:
|
case CXIdxEntity_Struct:
|
||||||
return ClangSymbolKind::Struct;
|
return ClangSymbolKind::Struct;
|
||||||
case CXIdxEntity_Union:
|
case CXIdxEntity_Union:
|
||||||
return ClangSymbolKind::Union;
|
return ClangSymbolKind::Union;
|
||||||
|
case CXIdxEntity_CXXTypeAlias:
|
||||||
|
case CXIdxEntity_Typedef:
|
||||||
|
return ClangSymbolKind::TypeAlias;
|
||||||
|
|
||||||
|
case CXIdxEntity_Function:
|
||||||
|
return ClangSymbolKind::Function;
|
||||||
|
case CXIdxEntity_Variable:
|
||||||
|
// Can also be Parameter
|
||||||
|
return ClangSymbolKind::Variable;
|
||||||
|
case CXIdxEntity_Field:
|
||||||
|
case CXIdxEntity_ObjCIvar:
|
||||||
|
return ClangSymbolKind::Field;
|
||||||
|
case CXIdxEntity_EnumConstant:
|
||||||
|
return ClangSymbolKind::EnumConstant;
|
||||||
|
case CXIdxEntity_CXXClass:
|
||||||
|
case CXIdxEntity_ObjCClass:
|
||||||
|
return ClangSymbolKind::Class;
|
||||||
|
case CXIdxEntity_CXXInterface:
|
||||||
|
case CXIdxEntity_ObjCProtocol:
|
||||||
|
return ClangSymbolKind::Protocol;
|
||||||
|
case CXIdxEntity_ObjCCategory:
|
||||||
|
return ClangSymbolKind::Extension;
|
||||||
|
case CXIdxEntity_CXXInstanceMethod:
|
||||||
|
case CXIdxEntity_ObjCInstanceMethod:
|
||||||
|
return ClangSymbolKind::InstanceMethod;
|
||||||
|
case CXIdxEntity_ObjCClassMethod:
|
||||||
|
return ClangSymbolKind::ClassMethod;
|
||||||
|
case CXIdxEntity_CXXStaticMethod:
|
||||||
|
return ClangSymbolKind::StaticMethod;
|
||||||
|
case CXIdxEntity_ObjCProperty:
|
||||||
|
return ClangSymbolKind::InstanceProperty;
|
||||||
|
case CXIdxEntity_CXXStaticVariable:
|
||||||
|
return ClangSymbolKind::StaticProperty;
|
||||||
|
case CXIdxEntity_CXXNamespace:
|
||||||
|
return ClangSymbolKind::Namespace;
|
||||||
|
case CXIdxEntity_CXXNamespaceAlias:
|
||||||
|
return ClangSymbolKind::NamespaceAlias;
|
||||||
|
case CXIdxEntity_CXXConstructor:
|
||||||
|
return ClangSymbolKind::Constructor;
|
||||||
|
case CXIdxEntity_CXXDestructor:
|
||||||
|
return ClangSymbolKind::Destructor;
|
||||||
|
case CXIdxEntity_CXXConversionFunction:
|
||||||
|
return ClangSymbolKind::ConversionFunction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,7 +466,7 @@ void OnIndexReference_Function(IndexFile* db,
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// static
|
// static
|
||||||
int IndexFile::kCurrentVersion = 7;
|
int IndexFile::kCurrentVersion = 8;
|
||||||
|
|
||||||
IndexFile::IndexFile(const std::string& path) : id_cache(path), path(path) {
|
IndexFile::IndexFile(const std::string& path) : id_cache(path), path(path) {
|
||||||
// TODO: Reconsider if we should still be reusing the same id_cache.
|
// TODO: Reconsider if we should still be reusing the same id_cache.
|
||||||
@ -1244,12 +1273,10 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
|||||||
!decl->isRedeclaration, db, param);
|
!decl->isRedeclaration, db, param);
|
||||||
|
|
||||||
// FIXME https://github.com/jacobdufault/cquery/issues/239
|
// FIXME https://github.com/jacobdufault/cquery/issues/239
|
||||||
if (IsGlobalContainer(decl->semanticContainer))
|
var->def.kind = GetSymbolKind(decl->entityInfo->kind);
|
||||||
var->def.kind = ClangSymbolKind::Module;
|
if (var->def.kind == ClangSymbolKind::Variable &&
|
||||||
else if (IsTypeDefinition(decl->semanticContainer))
|
decl->cursor.kind == CXCursor_ParmDecl)
|
||||||
var->def.kind = ClangSymbolKind::Field;
|
var->def.kind = ClangSymbolKind::Parameter;
|
||||||
else
|
|
||||||
var->def.kind = ClangSymbolKind::Variable;
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (decl->isDefinition) {
|
if (decl->isDefinition) {
|
||||||
@ -1468,7 +1495,7 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
|||||||
type->def.short_name = decl->entityInfo->name;
|
type->def.short_name = decl->entityInfo->name;
|
||||||
type->def.detailed_name =
|
type->def.detailed_name =
|
||||||
ns->QualifiedName(decl->semanticContainer, type->def.short_name);
|
ns->QualifiedName(decl->semanticContainer, type->def.short_name);
|
||||||
type->def.kind = ClangSymbolKind::TypeAlias;
|
type->def.kind = GetSymbolKind(decl->entityInfo->kind);
|
||||||
|
|
||||||
type->def.comments = decl_cursor.get_comments();
|
type->def.comments = decl_cursor.get_comments();
|
||||||
|
|
||||||
|
@ -128,10 +128,13 @@ void EmitSemanticHighlighting(QueryDatabase* db,
|
|||||||
if (!var->def)
|
if (!var->def)
|
||||||
continue; // applies to for loop
|
continue; // applies to for loop
|
||||||
switch (var->def->kind) {
|
switch (var->def->kind) {
|
||||||
|
// TODO
|
||||||
|
case ClangSymbolKind::EnumConstant:
|
||||||
case ClangSymbolKind::Field:
|
case ClangSymbolKind::Field:
|
||||||
case ClangSymbolKind::Macro:
|
case ClangSymbolKind::Macro:
|
||||||
case ClangSymbolKind::Module:
|
case ClangSymbolKind::Module:
|
||||||
case ClangSymbolKind::Parameter:
|
case ClangSymbolKind::Parameter:
|
||||||
|
case ClangSymbolKind::StaticProperty:
|
||||||
case ClangSymbolKind::Variable:
|
case ClangSymbolKind::Variable:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -99,11 +99,12 @@ void Reflect(Writer& visitor, IndexInclude& value) {
|
|||||||
|
|
||||||
template <typename TVisitor>
|
template <typename TVisitor>
|
||||||
void Reflect(TVisitor& visitor, IndexType& value) {
|
void Reflect(TVisitor& visitor, IndexType& value) {
|
||||||
REFLECT_MEMBER_START(16);
|
REFLECT_MEMBER_START(17);
|
||||||
REFLECT_MEMBER2("id", value.id);
|
REFLECT_MEMBER2("id", value.id);
|
||||||
REFLECT_MEMBER2("usr", value.usr);
|
REFLECT_MEMBER2("usr", value.usr);
|
||||||
REFLECT_MEMBER2("short_name", value.def.short_name);
|
REFLECT_MEMBER2("short_name", value.def.short_name);
|
||||||
REFLECT_MEMBER2("detailed_name", value.def.detailed_name);
|
REFLECT_MEMBER2("detailed_name", value.def.detailed_name);
|
||||||
|
REFLECT_MEMBER2("kind", value.def.kind);
|
||||||
REFLECT_MEMBER2("hover", value.def.hover);
|
REFLECT_MEMBER2("hover", value.def.hover);
|
||||||
REFLECT_MEMBER2("comments", value.def.comments);
|
REFLECT_MEMBER2("comments", value.def.comments);
|
||||||
REFLECT_MEMBER2("definition_spelling", value.def.definition_spelling);
|
REFLECT_MEMBER2("definition_spelling", value.def.definition_spelling);
|
||||||
@ -121,12 +122,13 @@ void Reflect(TVisitor& visitor, IndexType& value) {
|
|||||||
|
|
||||||
template <typename TVisitor>
|
template <typename TVisitor>
|
||||||
void Reflect(TVisitor& visitor, IndexFunc& value) {
|
void Reflect(TVisitor& visitor, IndexFunc& value) {
|
||||||
REFLECT_MEMBER_START(16);
|
REFLECT_MEMBER_START(17);
|
||||||
REFLECT_MEMBER2("id", value.id);
|
REFLECT_MEMBER2("id", value.id);
|
||||||
REFLECT_MEMBER2("is_operator", value.def.is_operator);
|
REFLECT_MEMBER2("is_operator", value.def.is_operator);
|
||||||
REFLECT_MEMBER2("usr", value.usr);
|
REFLECT_MEMBER2("usr", value.usr);
|
||||||
REFLECT_MEMBER2("short_name", value.def.short_name);
|
REFLECT_MEMBER2("short_name", value.def.short_name);
|
||||||
REFLECT_MEMBER2("detailed_name", value.def.detailed_name);
|
REFLECT_MEMBER2("detailed_name", value.def.detailed_name);
|
||||||
|
REFLECT_MEMBER2("kind", value.def.kind);
|
||||||
REFLECT_MEMBER2("hover", value.def.hover);
|
REFLECT_MEMBER2("hover", value.def.hover);
|
||||||
REFLECT_MEMBER2("comments", value.def.comments);
|
REFLECT_MEMBER2("comments", value.def.comments);
|
||||||
REFLECT_MEMBER2("declarations", value.declarations);
|
REFLECT_MEMBER2("declarations", value.declarations);
|
||||||
|
Loading…
Reference in New Issue
Block a user