[index] Add 'call' and 'isDynamic' roles

This commit is contained in:
Ben Langmuir
2016-04-29 13:30:30 -07:00
parent 1b1320b9f1
commit 50eeeb7430
3 changed files with 5 additions and 4 deletions

View File

@@ -106,8 +106,6 @@ struct FuncDeclIndexSymbol : public IndexSymbol {
struct CallRefIndexSymbol : public IndexSymbol { struct CallRefIndexSymbol : public IndexSymbol {
StringRef ReceiverUSR; StringRef ReceiverUSR;
bool IsDynamic = false;
CallRefIndexSymbol() : IndexSymbol(CallReference) {} CallRefIndexSymbol() : IndexSymbol(CallReference) {}
}; };

View File

@@ -867,6 +867,8 @@ bool IndexSwiftASTWalker::initCallRefIndexSymbol(Expr *CurrentE, Expr *ParentE,
if (initIndexSymbol(D, Loc, /*IsRef=*/true, Info)) if (initIndexSymbol(D, Loc, /*IsRef=*/true, Info))
return true; return true;
Info.roles |= (unsigned)SymbolRole::Call;
Expr *BaseE = nullptr; Expr *BaseE = nullptr;
if (auto DotE = dyn_cast<DotSyntaxCallExpr>(ParentE)) if (auto DotE = dyn_cast<DotSyntaxCallExpr>(ParentE))
BaseE = DotE->getBase(); BaseE = DotE->getBase();
@@ -888,7 +890,8 @@ bool IndexSwiftASTWalker::initCallRefIndexSymbol(Expr *CurrentE, Expr *ParentE,
StringRef unused; StringRef unused;
if (getNameAndUSR(TyD, unused, Info.ReceiverUSR)) if (getNameAndUSR(TyD, unused, Info.ReceiverUSR))
return true; return true;
Info.IsDynamic = isDynamicCall(BaseE, D); if (isDynamicCall(BaseE, D))
Info.roles |= (unsigned)SymbolRole::Dynamic;
} }
} }

View File

@@ -121,7 +121,7 @@ private:
initEntity(info, symbol); initEntity(info, symbol);
auto call = static_cast<const CallRefIndexSymbol &>(symbol); auto call = static_cast<const CallRefIndexSymbol &>(symbol);
info.ReceiverUSR = call.ReceiverUSR; info.ReceiverUSR = call.ReceiverUSR;
info.IsDynamic = call.IsDynamic; info.IsDynamic = call.roles & (unsigned)SymbolRole::Dynamic;
return func(info); return func(info);
} }
} }