File tree Expand file tree Collapse file tree 4 files changed +9
-18
lines changed Expand file tree Collapse file tree 4 files changed +9
-18
lines changed Original file line number Diff line number Diff line change @@ -238,7 +238,7 @@ extension BuildSystemManager: BuildSystemDelegate {
238
238
}
239
239
}
240
240
241
- extension BuildSystemManager : MainFilesDelegate {
241
+ extension BuildSystemManager {
242
242
// FIXME: Consider debouncing/limiting this, seems to trigger often during a build.
243
243
/// Checks if there are any files in `mainFileAssociations` where the main file
244
244
/// that we have stored has changed.
Original file line number Diff line number Diff line change @@ -25,10 +25,3 @@ public protocol MainFilesProvider: AnyObject {
25
25
/// ```
26
26
func mainFilesContainingFile( _: DocumentURI ) async -> Set < DocumentURI >
27
27
}
28
-
29
- /// Delegate that responds to possible main file changes.
30
- public protocol MainFilesDelegate : AnyObject {
31
-
32
- /// The mapping from files to main files (may have) changed.
33
- func mainFilesChanged( ) async
34
- }
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ public actor SourceKitIndexDelegate: IndexDelegate {
23
23
let queue = AsyncQueue < Serial > ( )
24
24
25
25
/// Registered `MainFilesDelegate`s to notify when main files change.
26
- var mainFilesDelegates : [ MainFilesDelegate ] = [ ]
26
+ var mainFilesChangedCallbacks : [ ( ) async -> Void ] = [ ]
27
27
28
28
/// The count of pending unit events. Whenever this transitions to 0, it represents a time where
29
29
/// the index finished processing known events. Of course, that may have already changed by the
@@ -62,20 +62,16 @@ public actor SourceKitIndexDelegate: IndexDelegate {
62
62
}
63
63
64
64
func _indexChanged( ) {
65
- for delegate in mainFilesDelegates {
65
+ for callback in mainFilesChangedCallbacks {
66
66
queue. async {
67
- await delegate . mainFilesChanged ( )
67
+ await callback ( )
68
68
}
69
69
}
70
70
}
71
71
72
72
/// Register a delegate to receive notifications when main files change.
73
- public func registerMainFileChanged ( _ delegate : MainFilesDelegate ) {
74
- mainFilesDelegates . append ( delegate )
73
+ public func addMainFileChangedCallback ( _ callback : @escaping ( ) async -> Void ) {
74
+ mainFilesChangedCallbacks . append ( callback )
75
75
}
76
76
77
- /// Un-register a delegate to receive notifications when main files change.
78
- public func unregisterMainFileChanged( _ delegate: MainFilesDelegate ) {
79
- mainFilesDelegates. removeAll ( where: { $0 === delegate } )
80
- }
81
77
}
Original file line number Diff line number Diff line change @@ -88,7 +88,9 @@ public final class Workspace {
88
88
fallbackBuildSystem: FallbackBuildSystem ( buildSetup: buildSetup) ,
89
89
mainFilesProvider: index
90
90
)
91
- await indexDelegate? . registerMainFileChanged ( buildSystemManager)
91
+ await indexDelegate? . addMainFileChangedCallback { [ weak self] in
92
+ await self ? . buildSystemManager. mainFilesChanged ( )
93
+ }
92
94
}
93
95
94
96
/// Creates a workspace for a given root `URL`, inferring the `ExternalWorkspace` if possible.
You can’t perform that action at this time.
0 commit comments