Skip to content

Commit

Permalink
Support BindingDecl and VarTemplate{,Partial}SpecializationDecl
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Jul 16, 2018
1 parent 814f054 commit 8912b00
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/indexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -457,16 +459,20 @@ class IndexDataConsumer : public index::IndexDataConsumer {
std::string_view qualified, IndexVar::Def &def) {
QualType T;
const Expr* init = nullptr;
bool binding = false;
if (auto *VD = dyn_cast<VarDecl>(D)) {
T = VD->getType();
init = VD->getAnyInitializer();
def.storage = VD->getStorageClass();
} else if (auto *FD = dyn_cast<FieldDecl>(D)) {
T = FD->getType();
init = FD->getInClassInitializer();
} else if (auto *BD = dyn_cast<BindingDecl>(D)) {
T = BD->getType();
binding = true;
}
auto BT = GetBaseType(T, false);
if (!BT.isNull() && BT->getAs<AutoType>()) {
if (!BT.isNull() && (binding || BT->getAs<AutoType>())) {
SmallString<256> Str;
llvm::raw_svector_ostream OS(Str);
PrintingPolicy PP = GetDefaultPolicy();
Expand Down Expand Up @@ -592,6 +598,8 @@ class IndexDataConsumer : public index::IndexDataConsumer {

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;
Expand All @@ -617,7 +625,7 @@ class IndexDataConsumer : public index::IndexDataConsumer {
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;
Expand Down Expand Up @@ -886,6 +894,10 @@ class IndexDataConsumer : public index::IndexDataConsumer {
// 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 =
Expand Down

0 comments on commit 8912b00

Please sign in to comment.