mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-02 18:23:24 +01:00
Implement a syntactic workspace-wide test index
This workspace-wide syntactic test index is used for two purposes: - It is used for XCTests instead of the semantic index for files that have on-disk or in-memory modifications to files - It is uses for swift-testing tests, which are only discovered syntactically. rdar://119191037
This commit is contained in:
@@ -39,6 +39,9 @@ public actor CompilationDatabaseBuildSystem {
|
||||
/// Delegate to handle any build system events.
|
||||
public weak var delegate: BuildSystemDelegate? = nil
|
||||
|
||||
/// Callbacks that should be called if the list of possible test files has changed.
|
||||
public var testFilesDidChangeCallbacks: [() async -> Void] = []
|
||||
|
||||
public func setDelegate(_ delegate: BuildSystemDelegate?) async {
|
||||
self.delegate = delegate
|
||||
}
|
||||
@@ -167,6 +170,9 @@ extension CompilationDatabaseBuildSystem: BuildSystem {
|
||||
if let delegate = self.delegate {
|
||||
await delegate.fileBuildSettingsChanged(self.watchedFiles)
|
||||
}
|
||||
for testFilesDidChangeCallback in testFilesDidChangeCallbacks {
|
||||
await testFilesDidChangeCallback()
|
||||
}
|
||||
}
|
||||
|
||||
public func filesDidChange(_ events: [FileEvent]) async {
|
||||
@@ -185,4 +191,12 @@ extension CompilationDatabaseBuildSystem: BuildSystem {
|
||||
return .unhandled
|
||||
}
|
||||
}
|
||||
|
||||
public func testFiles() async -> [DocumentURI] {
|
||||
return compdb?.allCommands.map { DocumentURI($0.url) } ?? []
|
||||
}
|
||||
|
||||
public func addTestFilesDidChangeCallback(_ callback: @escaping () async -> Void) async {
|
||||
testFilesDidChangeCallbacks.append(callback)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user