@@ -16,14 +16,15 @@ import Foundation
16
16
private enum Element {
17
17
case type( Any . Type )
18
18
case index( Int )
19
- case id( UniqueIdentifier )
20
19
case header( AnySupplementaryViewModel ? )
21
20
case footer( AnySupplementaryViewModel ? )
22
21
case cells( [ AnyCellViewModel ] )
23
22
case supplementaryViews( [ AnySupplementaryViewModel ] )
24
23
case sections( [ SectionViewModel ] )
25
24
case registrations( Set < ViewRegistration > )
26
- case isEmpty( Bool )
25
+ case field( label: String , value: Any ? )
26
+ case options( CollectionViewDriverOptions )
27
+ case viewModel( CollectionViewModel )
27
28
case end
28
29
}
29
30
@@ -48,9 +49,6 @@ private func debugDescriptionBuilder<Target: TextOutputStream>(
48
49
case let . index( index) :
49
50
buildString ( " [ \( index) ]: " , indent: indent, to: & output)
50
51
51
- case let . id( id) :
52
- buildString ( " id: \( id) " , indent: indent, to: & output)
53
-
54
52
case let . header( header) :
55
53
if let header {
56
54
buildString ( " header: \( header. id) ( \( header. reuseIdentifier) ) " , indent: indent, to: & output)
@@ -98,12 +96,12 @@ private func debugDescriptionBuilder<Target: TextOutputStream>(
98
96
debugDescriptionBuilder (
99
97
elements: [
100
98
( . index( index) , indent + 2 ) ,
101
- ( . id ( section. id) , indent + 4 ) ,
99
+ ( . field ( label : " id " , value : section. id) , indent + 4 ) ,
102
100
( . header( section. header) , indent + 4 ) ,
103
101
( . footer( section. footer) , indent + 4 ) ,
104
102
( . cells( section. cells) , indent + 4 ) ,
105
103
( . supplementaryViews( section. supplementaryViews) , indent + 4 ) ,
106
- ( . isEmpty ( section. isEmpty) , indent + 4 )
104
+ ( . field ( label : " isEmpty " , value : section. isEmpty) , indent + 4 )
107
105
] ,
108
106
to: & output
109
107
)
@@ -120,8 +118,40 @@ private func debugDescriptionBuilder<Target: TextOutputStream>(
120
118
buildString ( " - \( registration. reuseIdentifier) ( \( registration. viewType. kind) ) " , indent: indent + 2 , to: & output)
121
119
}
122
120
123
- case let . isEmpty( isEmpty) :
124
- buildString ( " isEmpty: \( isEmpty) " , indent: indent, to: & output)
121
+ case let . field( label, value) :
122
+ if let value {
123
+ buildString ( " \( label) : \( value) " , indent: indent, to: & output)
124
+ } else {
125
+ buildString ( " \( label) : nil " , indent: indent, to: & output)
126
+ }
127
+
128
+ case let . options( options) :
129
+ buildString ( " options: " , indent: indent, to: & output)
130
+
131
+ debugDescriptionBuilder (
132
+ elements: [
133
+ ( . type( CollectionViewDriverOptions . self) , indent + 2 ) ,
134
+ ( . field( label: " diffOnBackgroundQueue " , value: options. diffOnBackgroundQueue) , indent + 4 ) ,
135
+ ( . field( label: " reloadDataOnReplacingViewModel " , value: options. reloadDataOnReplacingViewModel) , indent + 4 ) ,
136
+ ( . end, indent + 2 )
137
+ ] ,
138
+ to: & output
139
+ )
140
+
141
+ case let . viewModel( viewModel) :
142
+ buildString ( " viewModel: " , indent: indent, to: & output)
143
+
144
+ debugDescriptionBuilder (
145
+ elements: [
146
+ ( . type( CollectionViewModel . self) , indent + 2 ) ,
147
+ ( . field( label: " id " , value: viewModel. id) , indent + 4 ) ,
148
+ ( . sections( viewModel. sections) , indent + 4 ) ,
149
+ ( . registrations( viewModel. allRegistrations ( ) ) , indent + 4 ) ,
150
+ ( . field( label: " isEmpty " , value: viewModel. isEmpty) , indent + 4 ) ,
151
+ ( . end, indent + 2 )
152
+ ] ,
153
+ to: & output
154
+ )
125
155
126
156
case . end:
127
157
buildString ( " } " , indent: indent, to: & output)
@@ -134,10 +164,10 @@ func collectionDebugDescription(_ collection: CollectionViewModel) -> String {
134
164
debugDescriptionBuilder (
135
165
elements: [
136
166
( . type( CollectionViewModel . self) , 0 ) ,
137
- ( . id ( collection. id) , 2 ) ,
167
+ ( . field ( label : " id " , value : collection. id) , 2 ) ,
138
168
( . sections( collection. sections) , 2 ) ,
139
169
( . registrations( collection. allRegistrations ( ) ) , 2 ) ,
140
- ( . isEmpty ( collection. isEmpty) , 2 ) ,
170
+ ( . field ( label : " isEmpty " , value : collection. isEmpty) , 2 ) ,
141
171
( . end, 0 )
142
172
] ,
143
173
to: & output
@@ -150,13 +180,51 @@ func sectionDebugDescription(_ section: SectionViewModel) -> String {
150
180
debugDescriptionBuilder (
151
181
elements: [
152
182
( . type( SectionViewModel . self) , 0 ) ,
153
- ( . id ( section. id) , 2 ) ,
183
+ ( . field ( label : " id " , value : section. id) , 2 ) ,
154
184
( . header( section. header) , 2 ) ,
155
185
( . footer( section. footer) , 2 ) ,
156
186
( . cells( section. cells) , 2 ) ,
157
187
( . supplementaryViews( section. supplementaryViews) , 2 ) ,
158
188
( . registrations( section. allRegistrations ( ) ) , 2 ) ,
159
- ( . isEmpty( section. isEmpty) , 2 ) ,
189
+ ( . field( label: " isEmpty " , value: section. isEmpty) , 2 ) ,
190
+ ( . end, 0 )
191
+ ] ,
192
+ to: & output
193
+ )
194
+ return output
195
+ }
196
+
197
+ func driverOptionsDebugDescription( _ options: CollectionViewDriverOptions ) -> String {
198
+ var output = " "
199
+ debugDescriptionBuilder (
200
+ elements: [
201
+ ( . type( CollectionViewDriverOptions . self) , 0 ) ,
202
+ ( . field( label: " diffOnBackgroundQueue " , value: options. diffOnBackgroundQueue) , 2 ) ,
203
+ ( . field( label: " reloadDataOnReplacingViewModel " , value: options. reloadDataOnReplacingViewModel) , 2 ) ,
204
+ ( . end, 0 )
205
+ ] ,
206
+ to: & output
207
+ )
208
+ return output
209
+ }
210
+
211
+ @MainActor
212
+ func driverDebugDescription(
213
+ _ driver: CollectionViewDriver ,
214
+ _ emptyViewProvider: EmptyViewProvider ? ,
215
+ _ cellEventCoordinator: CellEventCoordinator ?
216
+ ) -> String {
217
+ var output = " "
218
+ debugDescriptionBuilder (
219
+ elements: [
220
+ ( . type( CollectionViewDriver . self) , 0 ) ,
221
+ ( . options( driver. options) , 2 ) ,
222
+ ( . viewModel( driver. viewModel) , 2 ) ,
223
+ ( . field( label: " emptyViewProvider " , value: emptyViewProvider) , 2 ) ,
224
+ ( . field( label: " cellEventCoordinator " , value: cellEventCoordinator) , 2 ) ,
225
+ ( . field( label: " scrollViewDelegate " , value: driver. scrollViewDelegate) , 2 ) ,
226
+ ( . field( label: " flowLayoutDelegate " , value: driver. flowLayoutDelegate) , 2 ) ,
227
+ ( . field( label: " view " , value: driver. view) , 2 ) ,
160
228
( . end, 0 )
161
229
] ,
162
230
to: & output
0 commit comments