File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed
SwiftCompilerSources/Sources/AST Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ public class Decl: CustomStringConvertible, Hashable {
23
23
/// The module in which this declaration resides.
24
24
public var parentModule : ModuleDecl { bridged. getModuleContext ( ) . getAs ( ModuleDecl . self) }
25
25
26
+ /// The parent DeclContext if it is a Decl.
27
+ public var parent : Decl ? { bridged. getParent ( ) . decl }
28
+
26
29
// True if this declaration is imported from C/C++/ObjC.
27
30
public var hasClangNode : Bool { bridged. hasClangNode ( ) }
28
31
@@ -69,7 +72,9 @@ final public class ClassDecl: NominalTypeDecl {
69
72
}
70
73
}
71
74
72
- final public class ProtocolDecl : NominalTypeDecl { }
75
+ final public class ProtocolDecl : NominalTypeDecl {
76
+ public var requiresClass : Bool { bridged. ProtocolDecl_requiresClass ( ) }
77
+ }
73
78
74
79
final public class BuiltinTupleDecl : NominalTypeDecl { }
75
80
Original file line number Diff line number Diff line change @@ -379,6 +379,7 @@ struct BridgedDeclObj {
379
379
BridgedOwnedString getDebugDescription () const ;
380
380
BRIDGED_INLINE BridgedSourceLoc getLoc () const ;
381
381
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclObj getModuleContext () const ;
382
+ SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedDeclObj getParent () const ;
382
383
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef Type_getName () const ;
383
384
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef Value_getUserFacingName () const ;
384
385
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSourceLoc Value_getNameLoc () const ;
@@ -391,6 +392,7 @@ struct BridgedDeclObj {
391
392
BRIDGED_INLINE bool Struct_hasUnreferenceableStorage () const ;
392
393
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType Class_getSuperclass () const ;
393
394
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclObj Class_getDestructor () const ;
395
+ BRIDGED_INLINE bool ProtocolDecl_requiresClass () const ;
394
396
BRIDGED_INLINE bool AbstractFunction_isOverridden () const ;
395
397
BRIDGED_INLINE bool Destructor_isIsolated () const ;
396
398
};
Original file line number Diff line number Diff line change @@ -180,6 +180,10 @@ BridgedDeclObj BridgedDeclObj::getModuleContext() const {
180
180
return {unbridged ()-> getModuleContext ()};
181
181
}
182
182
183
+ OptionalBridgedDeclObj BridgedDeclObj ::getParent () const {
184
+ return {unbridged ()-> getDeclContext ()-> getAsDecl ()};
185
+ }
186
+
183
187
BridgedStringRef BridgedDeclObj ::Type_getName () const {
184
188
return getAs < swift ::TypeDecl > ()-> getName ().str ();
185
189
}
@@ -228,6 +232,10 @@ BridgedDeclObj BridgedDeclObj::Class_getDestructor() const {
228
232
return {getAs < swift ::ClassDecl > ( )-> getDestructor ()};
229
233
}
230
234
235
+ bool BridgedDeclObj ::ProtocolDecl_requiresClass () const {
236
+ return getAs < swift ::ProtocolDecl > ( )-> requiresClass ();
237
+ }
238
+
231
239
bool BridgedDeclObj ::AbstractFunction_isOverridden () const {
232
240
return getAs < swift ::AbstractFunctionDecl > ( )-> isOverridden ();
233
241
}
You can’t perform that action at this time.
0 commit comments