[SourceKit] Move UIDsFromDeclAttributes function to SwiftLangSupport header so it can be re-used, NFC.

This commit is contained in:
Argyrios Kyrtzidis
2016-05-05 15:48:52 -07:00
parent b9809d8770
commit af21c7d4b1
3 changed files with 74 additions and 71 deletions

View File

@@ -607,6 +607,76 @@ UIdent SwiftLangSupport::getUIDForSymbol(SymbolKind kind, SymbolSubKindSet subKi
#undef UID_FOR
}
std::vector<UIdent> SwiftLangSupport::UIDsFromDeclAttributes(const DeclAttributes &Attrs) {
std::vector<UIdent> AttrUIDs;
#define ATTR(X) \
if (Attrs.has(AK_##X)) { \
static UIdent Attr_##X("source.decl.attribute."#X); \
AttrUIDs.push_back(Attr_##X); \
}
#include "swift/AST/Attr.def"
for (auto Attr : Attrs) {
// Check special-case names first.
switch (Attr->getKind()) {
case DAK_IBAction: {
static UIdent Attr_IBAction("source.decl.attribute.ibaction");
AttrUIDs.push_back(Attr_IBAction);
continue;
}
case DAK_IBOutlet: {
static UIdent Attr_IBOutlet("source.decl.attribute.iboutlet");
AttrUIDs.push_back(Attr_IBOutlet);
continue;
}
case DAK_IBDesignable: {
static UIdent Attr_IBDesignable("source.decl.attribute.ibdesignable");
AttrUIDs.push_back(Attr_IBDesignable);
continue;
}
case DAK_IBInspectable: {
static UIdent Attr_IBInspectable("source.decl.attribute.ibinspectable");
AttrUIDs.push_back(Attr_IBInspectable);
continue;
}
case DAK_ObjC: {
static UIdent Attr_Objc("source.decl.attribute.objc");
static UIdent Attr_ObjcNamed("source.decl.attribute.objc.name");
if (cast<ObjCAttr>(Attr)->hasName()) {
AttrUIDs.push_back(Attr_ObjcNamed);
} else {
AttrUIDs.push_back(Attr_Objc);
}
continue;
}
// We handle accessibility explicitly.
case DAK_Accessibility:
case DAK_SetterAccessibility:
// Ignore these.
case DAK_ShowInInterface:
continue;
default:
break;
}
switch (Attr->getKind()) {
case DAK_Count:
break;
#define DECL_ATTR(X, CLASS, ...)\
case DAK_##CLASS: {\
static UIdent Attr_##X("source.decl.attribute."#X); \
AttrUIDs.push_back(Attr_##X); \
break;\
}
#include "swift/AST/Attr.def"
}
}
return AttrUIDs;
}
bool SwiftLangSupport::printDisplayName(const swift::ValueDecl *D,
llvm::raw_ostream &OS) {
if (!D->hasName())