From 0f63be2418be91130fd26a699bc60249b10878da Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 15 Jul 2018 18:26:48 -0700 Subject: [PATCH] Support BindingDecl and VarTemplate{,Partial}SpecializationDecl --- src/indexer.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/indexer.cc b/src/indexer.cc index f9c2c9ee..1f11b90b 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -125,6 +125,8 @@ SymbolKind GetSymbolKind(const Decl* D) { case Decl::ParmVar: case Decl::ImplicitParam: case Decl::Decomposition: + case Decl::VarTemplateSpecialization: + case Decl::VarTemplatePartialSpecialization: case Decl::EnumConstant: case Decl::UnresolvedUsingValue: return SymbolKind::Var; @@ -454,6 +456,7 @@ public: std::string_view qualified, IndexVar::Def &def) { QualType T; const Expr* init = nullptr; + bool binding = false; if (auto *VD = dyn_cast(D)) { T = VD->getType(); init = VD->getAnyInitializer(); @@ -461,9 +464,12 @@ public: } else if (auto *FD = dyn_cast(D)) { T = FD->getType(); init = FD->getInClassInitializer(); + } else if (auto *BD = dyn_cast(D)) { + T = BD->getType(); + binding = true; } auto BT = GetBaseType(T, false); - if (!BT.isNull() && BT->getAs()) { + if (!BT.isNull() && (binding || BT->getAs())) { SmallString<256> Str; llvm::raw_svector_ostream OS(Str); PrintingPolicy PP = GetDefaultPolicy(); @@ -589,6 +595,8 @@ public: bool is_decl = Roles & uint32_t(index::SymbolRole::Declaration); bool is_def = Roles & uint32_t(index::SymbolRole::Definition); + if (is_decl && D->getKind() == Decl::Binding) + is_def = true; IndexFunc *func = nullptr; IndexType *type = nullptr; IndexVar *var = nullptr; @@ -614,7 +622,7 @@ public: switch (kind) { case SymbolKind::Invalid: LOG_S(INFO) << "Unhandled " << int(D->getKind()) << " " << info->qualified - << " in " << db->path << ":" << loc.start.line; + << " in " << db->path << ":" << loc.start.line + 1; return true; case SymbolKind::File: return true; @@ -883,6 +891,10 @@ public: // ccls extension var->def.kind = lsSymbolKind::Parameter; break; + case Decl::VarTemplateSpecialization: + case Decl::VarTemplatePartialSpecialization: + var->def.kind = lsSymbolKind::Variable; + break; case Decl::EnumConstant: var->def.kind = lsSymbolKind::EnumMember; // TODO Pretty printer may print =