File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,27 @@ public final class IndexStoreDB {
187
187
}
188
188
return result
189
189
}
190
+
191
+ /// Iterates over the name of every symbol in the index.
192
+ ///
193
+ /// - Parameter body: A closure to be called for each symbol. The closure should return true to
194
+ /// continue iterating.
195
+ @discardableResult
196
+ public func forEachSymbolName( body: @escaping ( String ) -> Bool ) -> Bool {
197
+ return indexstoredb_index_symbol_names ( impl) { name in
198
+ body ( String ( cString: name) )
199
+ }
200
+ }
201
+
202
+ /// Returns an array with every symbol name in the index.
203
+ public func allSymbolNames( ) -> [ String ] {
204
+ var result : [ String ] = [ ]
205
+ forEachSymbolName { name in
206
+ result. append ( name)
207
+ return true
208
+ }
209
+ return result
210
+ }
190
211
}
191
212
192
213
public protocol IndexStoreLibraryProvider {
Original file line number Diff line number Diff line change @@ -279,4 +279,14 @@ final class IndexTests: XCTestCase {
279
279
XCTAssertEqual ( mainFiles ( unknown, true ) , [ ] )
280
280
XCTAssertEqual ( mainFiles ( unknown, false ) , [ ] )
281
281
}
282
+
283
+ func testAllSymbolNames( ) throws {
284
+ guard let ws = try staticTibsTestWorkspace ( name: " proj1 " ) else { return }
285
+ try ws. buildAndIndex ( )
286
+ let index = ws. index
287
+
288
+ let expectedSymbolNames = [ " a() " , " b() " , " c() " ]
289
+
290
+ XCTAssertEqual ( index. allSymbolNames ( ) , expectedSymbolNames)
291
+ }
282
292
}
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ extension IndexTests {
16
16
// `swift test --generate-linuxmain`
17
17
// to regenerate.
18
18
static let __allTests__IndexTests = [
19
+ ( " testAllSymbolNames " , testAllSymbolNames) ,
19
20
( " testBasic " , testBasic) ,
20
21
( " testDelegate " , testDelegate) ,
21
22
( " testEditsSimple " , testEditsSimple) ,
You can’t perform that action at this time.
0 commit comments