@@ -83,8 +83,33 @@ extension LogEntry {
83
83
self = . opaque( name: name, typeName: typeName, summary: summary, preferBriefSummary: false , representation: playgroundQuickLook. opaqueRepresentation)
84
84
}
85
85
86
+ private static let superclassLogEntryName = " super "
87
+
86
88
private init ( structureFrom mirror: Mirror , name: String , typeName: String , summary: String ) {
87
- self = . structured( name: name, typeName: typeName, summary: summary, totalChildrenCount: Int ( mirror. children. count) , children: mirror. children. map { LogEntry ( describing: $0. value, name: $0. label) } , disposition: . init( displayStyle: mirror. displayStyle) )
89
+ let totalChildrenCount : Int
90
+ var childEntries : [ LogEntry ] = [ ]
91
+
92
+ // If our Mirror has a superclassMirror, then we need to include that as the first "child" (and include it in the total children count).
93
+ if let superclassMirror = mirror. superclassMirror {
94
+ let superclassTypeName = _typeName ( superclassMirror. subjectType)
95
+ childEntries. append ( LogEntry ( structureFrom: superclassMirror, name: LogEntry . superclassLogEntryName, typeName: superclassTypeName, summary: superclassTypeName) )
96
+
97
+ totalChildrenCount = Int ( mirror. children. count) + 1
98
+ }
99
+ else {
100
+ totalChildrenCount = Int ( mirror. children. count)
101
+ }
102
+
103
+ // Next, we need to generate log entries for all of the "real" children of this mirror.
104
+ childEntries += mirror. children. map { LogEntry ( describing: $0. value, name: $0. label) }
105
+
106
+ self = . structured( name: name,
107
+ typeName: typeName,
108
+ summary: summary,
109
+ totalChildrenCount: totalChildrenCount,
110
+ children: childEntries,
111
+ disposition: . init( displayStyle: mirror. displayStyle)
112
+ )
88
113
}
89
114
}
90
115
0 commit comments