@@ -159,9 +159,11 @@ public final class IndexStoreDB {
159
159
/// Stop iteration if `body` returns `false`.
160
160
/// - Returns: `false` if iteration was terminated by `body` returning `true` or `true` if iteration finished.
161
161
@discardableResult
162
- public func forEachSymbolOccurrence( byUSR usr: String , roles: SymbolRole , _ body: @escaping ( SymbolOccurrence ) -> Bool ) -> Bool {
163
- return indexstoredb_index_symbol_occurrences_by_usr ( impl, usr, roles. rawValue) { occur in
164
- return body ( SymbolOccurrence ( occur) )
162
+ public func forEachSymbolOccurrence( byUSR usr: String , roles: SymbolRole , _ body: ( SymbolOccurrence ) -> Bool ) -> Bool {
163
+ return withoutActuallyEscaping ( body) { body in
164
+ return indexstoredb_index_symbol_occurrences_by_usr ( impl, usr, roles. rawValue) { occur in
165
+ return body ( SymbolOccurrence ( occur) )
166
+ }
165
167
}
166
168
}
167
169
@@ -176,9 +178,12 @@ public final class IndexStoreDB {
176
178
}
177
179
178
180
@discardableResult
179
- public func forEachRelatedSymbolOccurrence( byUSR usr: String , roles: SymbolRole , _ body: @escaping ( SymbolOccurrence ) -> Bool ) -> Bool {
180
- return indexstoredb_index_related_symbol_occurrences_by_usr ( impl, usr, roles. rawValue) { occur in
181
- return body ( SymbolOccurrence ( occur) )
181
+ public func forEachRelatedSymbolOccurrence( byUSR usr: String , roles: SymbolRole , _ body: ( SymbolOccurrence ) -> Bool ) -> Bool {
182
+ return withoutActuallyEscaping ( body) { body in
183
+ return indexstoredb_index_related_symbol_occurrences_by_usr ( impl, usr, roles. rawValue) {
184
+ occur in
185
+ return body ( SymbolOccurrence ( occur) )
186
+ }
182
187
}
183
188
}
184
189
@@ -191,9 +196,11 @@ public final class IndexStoreDB {
191
196
return result
192
197
}
193
198
194
- @discardableResult public func forEachCanonicalSymbolOccurrence( byName: String , body: @escaping ( SymbolOccurrence ) -> Bool ) -> Bool {
195
- return indexstoredb_index_canonical_symbol_occurences_by_name ( impl, byName) { occur in
196
- return body ( SymbolOccurrence ( occur) )
199
+ @discardableResult public func forEachCanonicalSymbolOccurrence( byName: String , body: ( SymbolOccurrence ) -> Bool ) -> Bool {
200
+ return withoutActuallyEscaping ( body) { body in
201
+ return indexstoredb_index_canonical_symbol_occurences_by_name ( impl, byName) { occur in
202
+ return body ( SymbolOccurrence ( occur) )
203
+ }
197
204
}
198
205
}
199
206
@@ -212,17 +219,19 @@ public final class IndexStoreDB {
212
219
anchorEnd: Bool ,
213
220
subsequence: Bool ,
214
221
ignoreCase: Bool ,
215
- body: @escaping ( SymbolOccurrence ) -> Bool
222
+ body: ( SymbolOccurrence ) -> Bool
216
223
) -> Bool {
217
- return indexstoredb_index_canonical_symbol_occurences_containing_pattern (
218
- impl,
219
- pattern,
220
- anchorStart,
221
- anchorEnd,
222
- subsequence,
223
- ignoreCase
224
- ) { occur in
225
- body ( SymbolOccurrence ( occur) )
224
+ return withoutActuallyEscaping ( body) { body in
225
+ return indexstoredb_index_canonical_symbol_occurences_containing_pattern (
226
+ impl,
227
+ pattern,
228
+ anchorStart,
229
+ anchorEnd,
230
+ subsequence,
231
+ ignoreCase
232
+ ) { occur in
233
+ body ( SymbolOccurrence ( occur) )
234
+ }
226
235
}
227
236
}
228
237
@@ -248,15 +257,19 @@ public final class IndexStoreDB {
248
257
}
249
258
250
259
@discardableResult
251
- public func forEachMainFileContainingFile( path: String , crossLanguage: Bool , body: @escaping ( String ) -> Bool ) -> Bool {
260
+ public func forEachMainFileContainingFile(
261
+ path: String , crossLanguage: Bool , body: ( String ) -> Bool
262
+ ) -> Bool {
252
263
let fromSwift = path. hasSuffix ( " .swift " )
253
- return indexstoredb_index_units_containing_file ( impl, path) { unit in
254
- let mainFileStr = String ( cString: indexstoredb_unit_info_main_file_path ( unit) )
255
- let toSwift = mainFileStr. hasSuffix ( " .swift " )
256
- if !crossLanguage && fromSwift != toSwift {
257
- return true // continue
264
+ return withoutActuallyEscaping ( body) { body in
265
+ return indexstoredb_index_units_containing_file ( impl, path) { unit in
266
+ let mainFileStr = String ( cString: indexstoredb_unit_info_main_file_path ( unit) )
267
+ let toSwift = mainFileStr. hasSuffix ( " .swift " )
268
+ if !crossLanguage && fromSwift != toSwift {
269
+ return true // continue
270
+ }
271
+ return body ( mainFileStr)
258
272
}
259
- return body ( mainFileStr)
260
273
}
261
274
}
262
275
@@ -270,10 +283,12 @@ public final class IndexStoreDB {
270
283
}
271
284
272
285
@discardableResult
273
- public func forEachUnitNameContainingFile( path: String , body: @escaping ( String ) -> Bool ) -> Bool {
274
- return indexstoredb_index_units_containing_file ( impl, path) { unit in
275
- let unitName = String ( cString: indexstoredb_unit_info_unit_name ( unit) )
276
- return body ( unitName)
286
+ public func forEachUnitNameContainingFile( path: String , body: ( String ) -> Bool ) -> Bool {
287
+ return withoutActuallyEscaping ( body) { body in
288
+ return indexstoredb_index_units_containing_file ( impl, path) { unit in
289
+ let unitName = String ( cString: indexstoredb_unit_info_unit_name ( unit) )
290
+ return body ( unitName)
291
+ }
277
292
}
278
293
}
279
294
@@ -322,10 +337,12 @@ public final class IndexStoreDB {
322
337
}
323
338
324
339
@discardableResult
325
- public func foreachFileIncludedByFile( path: String , body: @escaping ( String ) -> Bool ) -> Bool {
326
- return indexstoredb_index_files_included_by_file ( impl, path) { targetPath, line in
340
+ public func foreachFileIncludedByFile( path: String , body: ( String ) -> Bool ) -> Bool {
341
+ return withoutActuallyEscaping ( body) { body in
342
+ return indexstoredb_index_files_included_by_file ( impl, path) { targetPath, line in
327
343
let targetPathStr = String ( cString: targetPath)
328
344
return body ( targetPathStr)
345
+ }
329
346
}
330
347
}
331
348
@@ -339,10 +356,12 @@ public final class IndexStoreDB {
339
356
}
340
357
341
358
@discardableResult
342
- public func foreachFileIncludingFile( path: String , body: @escaping ( String ) -> Bool ) -> Bool {
343
- return indexstoredb_index_files_including_file ( impl, path) { sourcePath, line in
359
+ public func foreachFileIncludingFile( path: String , body: ( String ) -> Bool ) -> Bool {
360
+ return withoutActuallyEscaping ( body) { body in
361
+ return indexstoredb_index_files_including_file ( impl, path) { sourcePath, line in
344
362
let sourcePathStr = String ( cString: sourcePath)
345
363
return body ( sourcePathStr)
364
+ }
346
365
}
347
366
}
348
367
@@ -373,11 +392,14 @@ public final class IndexStoreDB {
373
392
374
393
/// Iterates over recorded `#include`s of a unit.
375
394
@discardableResult
376
- public func forEachIncludeOfUnit( unitName: String , body: @escaping ( UnitIncludeEntry ) -> Bool ) -> Bool {
377
- return indexstoredb_index_includes_of_unit ( impl, unitName) { sourcePath, targetPath, line in
378
- let sourcePathStr = String ( cString: sourcePath)
379
- let targetPathStr = String ( cString: targetPath)
380
- return body ( UnitIncludeEntry ( sourcePath: sourcePathStr, targetPath: targetPathStr, line: line) )
395
+ public func forEachIncludeOfUnit( unitName: String , body: ( UnitIncludeEntry ) -> Bool ) -> Bool {
396
+ return withoutActuallyEscaping ( body) { body in
397
+ return indexstoredb_index_includes_of_unit ( impl, unitName) { sourcePath, targetPath, line in
398
+ let sourcePathStr = String ( cString: sourcePath)
399
+ let targetPathStr = String ( cString: targetPath)
400
+ return body (
401
+ UnitIncludeEntry ( sourcePath: sourcePathStr, targetPath: targetPathStr, line: line) )
402
+ }
381
403
}
382
404
}
383
405
@@ -396,9 +418,11 @@ public final class IndexStoreDB {
396
418
/// - Parameter body: A closure to be called for each symbol. The closure should return true to
397
419
/// continue iterating.
398
420
@discardableResult
399
- public func forEachSymbolName( body: @escaping ( String ) -> Bool ) -> Bool {
400
- return indexstoredb_index_symbol_names ( impl) { name in
401
- body ( String ( cString: name) )
421
+ public func forEachSymbolName( body: ( String ) -> Bool ) -> Bool {
422
+ return withoutActuallyEscaping ( body) { body in
423
+ return indexstoredb_index_symbol_names ( impl) { name in
424
+ body ( String ( cString: name) )
425
+ }
402
426
}
403
427
}
404
428
@@ -422,9 +446,11 @@ public final class IndexStoreDB {
422
446
}
423
447
424
448
@discardableResult
425
- func forEachSymbol( inFilePath filePath: String , body: @escaping ( Symbol ) -> Bool ) -> Bool {
426
- return indexstoredb_index_symbols_contained_in_file_path ( impl, filePath) { symbol in
427
- return body ( Symbol ( symbol) )
449
+ func forEachSymbol( inFilePath filePath: String , body: ( Symbol ) -> Bool ) -> Bool {
450
+ return withoutActuallyEscaping ( body) { body in
451
+ return indexstoredb_index_symbols_contained_in_file_path ( impl, filePath) { symbol in
452
+ return body ( Symbol ( symbol) )
453
+ }
428
454
}
429
455
}
430
456
0 commit comments