@@ -42,8 +42,7 @@ struct swift::ide::api::SDKNodeInitInfo {
42
42
SDKNodeInitInfo (SDKContext &Ctx, Decl *D);
43
43
SDKNodeInitInfo (SDKContext &Ctx, ValueDecl *VD);
44
44
SDKNodeInitInfo (SDKContext &Ctx, OperatorDecl *D);
45
- SDKNodeInitInfo (SDKContext &Ctx, Type Ty, bool IsImplicitlyUnwrappedOptional,
46
- bool hasDefaultArgument);
45
+ SDKNodeInitInfo (SDKContext &Ctx, Type Ty, TypeInitInfo Info = TypeInitInfo());
47
46
SDKNode* createSDKNode (SDKNodeKind Kind);
48
47
};
49
48
@@ -86,7 +85,8 @@ SDKNodeDecl::SDKNodeDecl(SDKNodeInitInfo Info, SDKNodeKind Kind)
86
85
87
86
SDKNodeType::SDKNodeType (SDKNodeInitInfo Info, SDKNodeKind Kind):
88
87
SDKNode(Info, Kind), TypeAttributes(Info.TypeAttrs),
89
- HasDefaultArg(Info.HasDefaultArg) {}
88
+ HasDefaultArg(Info.HasDefaultArg),
89
+ ParamValueOwnership(Info.ParamValueOwnership) {}
90
90
91
91
SDKNodeTypeNominal::SDKNodeTypeNominal (SDKNodeInitInfo Info):
92
92
SDKNodeType(Info, SDKNodeKind::TypeNominal), USR(Info.Usr) {}
@@ -668,6 +668,8 @@ bool static isSDKNodeEqual(SDKContext &Ctx, const SDKNode &L, const SDKNode &R)
668
668
return false ;
669
669
if (Left->hasDefaultArgument () != Right->hasDefaultArgument ())
670
670
return false ;
671
+ if (Left->getParamValueOwnership () != Right->getParamValueOwnership ())
672
+ return false ;
671
673
if (Left->getPrintedName () == Right->getPrintedName ())
672
674
return true ;
673
675
return Left->getName () == Right->getName () &&
@@ -1013,12 +1015,11 @@ static Optional<uint8_t> getFixedBinaryOrder(ValueDecl *VD) {
1013
1015
return llvm::None;
1014
1016
}
1015
1017
1016
- SDKNodeInitInfo::SDKNodeInitInfo (SDKContext &Ctx, Type Ty,
1017
- bool IsImplicitlyUnwrappedOptional = false ,
1018
- bool hasDefaultArgument = false ) :
1019
- Ctx(Ctx), Name(getTypeName(Ctx, Ty, IsImplicitlyUnwrappedOptional)),
1020
- PrintedName(getPrintedName(Ctx, Ty, IsImplicitlyUnwrappedOptional)),
1021
- HasDefaultArg(hasDefaultArgument) {
1018
+ SDKNodeInitInfo::SDKNodeInitInfo (SDKContext &Ctx, Type Ty, TypeInitInfo Info) :
1019
+ Ctx(Ctx), Name(getTypeName(Ctx, Ty, Info.IsImplicitlyUnwrappedOptional)),
1020
+ PrintedName(getPrintedName(Ctx, Ty, Info.IsImplicitlyUnwrappedOptional)),
1021
+ ParamValueOwnership(Info.ValueOwnership),
1022
+ HasDefaultArg(Info.hasDefaultArgument) {
1022
1023
if (isFunctionTypeNoEscape (Ty))
1023
1024
TypeAttrs.push_back (TypeAttrKind::TAK_noescape);
1024
1025
// If this is a nominal type, get its Usr.
@@ -1123,14 +1124,11 @@ case SDKNodeKind::X: \
1123
1124
// Recursively construct a node that represents a type, for instance,
1124
1125
// representing the return value type of a function decl.
1125
1126
SDKNode *swift::ide::api::
1126
- SwiftDeclCollector::constructTypeNode (Type T,
1127
- bool IsImplicitlyUnwrappedOptional,
1128
- bool hasDefaultArgument) {
1127
+ SwiftDeclCollector::constructTypeNode (Type T, TypeInitInfo Info) {
1129
1128
if (Ctx.checkingABI ()) {
1130
1129
T = T->getCanonicalType ();
1131
1130
}
1132
- SDKNode* Root = SDKNodeInitInfo (Ctx, T, IsImplicitlyUnwrappedOptional,
1133
- hasDefaultArgument).createSDKNode (SDKNodeKind::TypeNominal);
1131
+ SDKNode* Root = SDKNodeInitInfo (Ctx, T, Info).createSDKNode (SDKNodeKind::TypeNominal);
1134
1132
1135
1133
if (auto NAT = dyn_cast<NameAliasType>(T.getPointer ())) {
1136
1134
SDKNode* Root = SDKNodeInitInfo (Ctx, T).createSDKNode (SDKNodeKind::TypeAlias);
@@ -1179,10 +1177,20 @@ std::vector<SDKNode*> swift::ide::api::
1179
1177
SwiftDeclCollector::createParameterNodes (ParameterList *PL) {
1180
1178
std::vector<SDKNode*> Result;
1181
1179
for (auto param: *PL) {
1182
- Result.push_back (constructTypeNode (param->getInterfaceType (),
1183
- param->getAttrs ().hasAttribute <ImplicitlyUnwrappedOptionalAttr>(),
1184
- param->getDefaultArgumentKind () != DefaultArgumentKind::None));
1185
-
1180
+ TypeInitInfo Info;
1181
+ Info.IsImplicitlyUnwrappedOptional = param->getAttrs ().
1182
+ hasAttribute<ImplicitlyUnwrappedOptionalAttr>();
1183
+ Info.hasDefaultArgument = param->getDefaultArgumentKind () !=
1184
+ DefaultArgumentKind::None;
1185
+ switch (param->getValueOwnership ()) {
1186
+ #define CASE (KIND ) case ValueOwnership::KIND: Info.ValueOwnership = #KIND; break ;
1187
+ CASE (Owned)
1188
+ CASE (InOut)
1189
+ CASE (Shared)
1190
+ case ValueOwnership::Default: break ;
1191
+ #undef CASE
1192
+ }
1193
+ Result.push_back (constructTypeNode (param->getInterfaceType (), Info));
1186
1194
}
1187
1195
return Result;
1188
1196
}
@@ -1195,8 +1203,10 @@ SDKNode *swift::ide::api::
1195
1203
SwiftDeclCollector::constructFunctionNode (FuncDecl* FD,
1196
1204
SDKNodeKind Kind) {
1197
1205
auto Func = SDKNodeInitInfo (Ctx, FD).createSDKNode (Kind);
1198
- Func->addChild (constructTypeNode (FD->getResultInterfaceType (),
1199
- FD->getAttrs ().hasAttribute <ImplicitlyUnwrappedOptionalAttr>()));
1206
+ TypeInitInfo Info;
1207
+ Info.IsImplicitlyUnwrappedOptional = FD->getAttrs ().
1208
+ hasAttribute<ImplicitlyUnwrappedOptionalAttr>();
1209
+ Func->addChild (constructTypeNode (FD->getResultInterfaceType (), Info));
1200
1210
for (auto *Node : createParameterNodes (FD->getParameters ()))
1201
1211
Func->addChild (Node);
1202
1212
return Func;
@@ -1295,8 +1305,10 @@ SwiftDeclCollector::constructExternalExtensionNode(NominalTypeDecl *NTD,
1295
1305
SDKNode *swift::ide::api::
1296
1306
SwiftDeclCollector::constructVarNode (ValueDecl *VD) {
1297
1307
auto Var = SDKNodeInitInfo (Ctx, VD).createSDKNode (SDKNodeKind::DeclVar);
1298
- Var->addChild (constructTypeNode (VD->getInterfaceType (),
1299
- VD->getAttrs ().hasAttribute <ImplicitlyUnwrappedOptionalAttr>()));
1308
+ TypeInitInfo Info;
1309
+ Info.IsImplicitlyUnwrappedOptional = VD->getAttrs ().
1310
+ hasAttribute<ImplicitlyUnwrappedOptionalAttr>();
1311
+ Var->addChild (constructTypeNode (VD->getInterfaceType (), Info));
1300
1312
if (auto VAD = dyn_cast<AbstractStorageDecl>(VD)) {
1301
1313
if (auto Getter = VAD->getGetter ())
1302
1314
Var->addChild (constructFunctionNode (Getter, SDKNodeKind::DeclGetter));
@@ -1513,6 +1525,7 @@ void SDKNodeType::jsonize(json::Output &out) {
1513
1525
SDKNode::jsonize (out);
1514
1526
out.mapOptional (getKeyContent (Ctx, KeyKind::KK_typeAttributes).data (), TypeAttributes);
1515
1527
output (out, KeyKind::KK_hasDefaultArg, HasDefaultArg);
1528
+ output (out, KeyKind::KK_paramValueOwnership, ParamValueOwnership);
1516
1529
}
1517
1530
1518
1531
void SDKNodeTypeNominal::jsonize (json::Output &out) {
0 commit comments