Skip to content

Expose the name of every symbol in the index #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 13, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Sources/IndexStoreDB/IndexStoreDB.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,27 @@ public final class IndexStoreDB {
}
return result
}

/// Iterates over the name of every symbol in the index.
///
/// - Parameter body: A closure to be called for each symbol. The closure should return true to
/// continue iterating.
@discardableResult
public func forEachSymbolName(body: @escaping (String) -> Bool) -> Bool {
return indexstoredb_index_symbol_names(impl) { name in
body(String(cString: name))
}
}

/// Returns a set with every symbol in the index.
public func allSymbolNames() -> Set<String> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be a Set, indexstoredb_index_symbol_names is going to return unique strings.
I'd recommend to change it to array.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

var result: Set<String> = []
forEachSymbolName { name in
result.insert(name)
return true
}
return result
}
}

public protocol IndexStoreLibraryProvider {
Expand Down