@@ -333,6 +333,7 @@ struct SDKNodeInitInfo {
333
333
std::vector<TypeAttrKind> TypeAttrs;
334
334
std::vector<StringRef> ConformingProtocols;
335
335
StringRef SuperclassUsr;
336
+ StringRef EnumRawTypeName;
336
337
ParentExtensionInfo *ExtInfo = nullptr ;
337
338
TypeInitInfo TypeInfo;
338
339
@@ -779,13 +780,26 @@ SDKNodeDecl *SDKNodeType::getClosestParentDecl() const {
779
780
class SDKNodeTypeDecl : public SDKNodeDecl {
780
781
StringRef SuperclassUsr;
781
782
std::vector<StringRef> ConformingProtocols;
783
+ StringRef EnumRawTypeName;
782
784
public:
783
785
SDKNodeTypeDecl (SDKNodeInitInfo Info) : SDKNodeDecl(Info, SDKNodeKind::TypeDecl),
784
786
SuperclassUsr (Info.SuperclassUsr),
785
- ConformingProtocols(Info.ConformingProtocols){}
787
+ ConformingProtocols(Info.ConformingProtocols),
788
+ EnumRawTypeName(Info.EnumRawTypeName) {}
786
789
static bool classof (const SDKNode *N);
787
790
StringRef getSuperClassUsr () const { return SuperclassUsr; }
788
791
ArrayRef<StringRef> getAllProtocols () const { return ConformingProtocols; }
792
+
793
+ #define NOMINAL_TYPE_DECL (ID, PARENT ) \
794
+ bool is##ID() const { return getDeclKind () == DeclKind::ID; }
795
+ #define DECL (ID, PARENT )
796
+ #include " swift/AST/DeclNodes.def"
797
+
798
+ StringRef getEnumRawTypeName () const {
799
+ assert (isEnum ());
800
+ return EnumRawTypeName;
801
+ }
802
+
789
803
Optional<SDKNodeTypeDecl*> getSuperclass () const {
790
804
if (SuperclassUsr.empty ())
791
805
return None;
@@ -959,6 +973,11 @@ SDKNode* SDKNode::constructSDKNode(SDKContext &Ctx,
959
973
}
960
974
break ;
961
975
}
976
+ case KeyKind::KK_enumRawTypeName: {
977
+ assert (Info.DKind == DeclKind::Enum);
978
+ Info.EnumRawTypeName = GetScalarString (Pair.getValue ());
979
+ break ;
980
+ }
962
981
case KeyKind::KK_printedName:
963
982
Info.PrintedName = GetScalarString (Pair.getValue ());
964
983
break ;
@@ -1294,6 +1313,15 @@ SDKNodeInitInfo::SDKNodeInitInfo(SDKContext &Ctx, ValueDecl *VD)
1294
1313
ConformingProtocols.push_back (P->getName ().str ());
1295
1314
}
1296
1315
}
1316
+
1317
+ // Get enum raw type name if this is an enum.
1318
+ if (auto *ED = dyn_cast<EnumDecl>(VD)) {
1319
+ if (auto RT = ED->getRawType ()) {
1320
+ if (auto *D = RT->getNominalOrBoundGenericNominal ()) {
1321
+ EnumRawTypeName = D->getName ().str ();
1322
+ }
1323
+ }
1324
+ }
1297
1325
}
1298
1326
1299
1327
SDKNode *SDKNodeInitInfo::createSDKNode (SDKNodeKind Kind) {
@@ -1675,6 +1703,14 @@ namespace swift {
1675
1703
KeyKind::KK_conformingProtocols).data (),
1676
1704
Pros);
1677
1705
}
1706
+
1707
+ auto RawTypeName = TD->isEnum () ? TD->getEnumRawTypeName () : StringRef ();
1708
+ if (!RawTypeName.empty ()) {
1709
+ out.mapRequired (getKeyContent (Ctx,
1710
+ KeyKind::KK_enumRawTypeName).data (),
1711
+ RawTypeName);
1712
+ }
1713
+
1678
1714
}
1679
1715
if (D->isFromExtension ()) {
1680
1716
// Even if we don't have any requirements on this parent extension,
0 commit comments