@@ -15,6 +15,9 @@ import LSPLogging
15
15
import LanguageServerProtocol
16
16
import SKCore
17
17
18
+ /// The logging subsystem that should be used for all index-related logging.
19
+ let indexLoggingSubsystem = " org.swift.sourcekit-lsp.indexing "
20
+
18
21
/// A wrapper around `QueuedTask` that only allows equality comparison and inspection whether the `QueuedTask` is
19
22
/// currently executing.
20
23
///
@@ -186,26 +189,35 @@ public final actor SemanticIndexManager {
186
189
/// This method is intended to initially update the index of a project after it is opened.
187
190
public func scheduleBuildGraphGenerationAndBackgroundIndexAllFiles( ) async {
188
191
generateBuildGraphTask = Task ( priority: . low) {
189
- let signposter = Logger ( subsystem: LoggingScope . subsystem, category: " preparation " ) . makeSignposter ( )
190
- let signpostID = signposter. makeSignpostID ( )
191
- let state = signposter. beginInterval ( " Preparing " , id: signpostID, " Generating build graph " )
192
- defer {
193
- signposter. endInterval ( " Preparing " , state)
194
- }
195
- await testHooks. buildGraphGenerationDidStart ? ( )
196
- await orLog ( " Generating build graph " ) { try await self . buildSystemManager. generateBuildGraph ( ) }
197
- await testHooks. buildGraphGenerationDidFinish ? ( )
198
- let index = index. checked ( for: . modifiedFiles)
199
- let filesToIndex = await self . buildSystemManager. sourceFiles ( ) . lazy. map ( \. uri)
200
- . filter { uri in
201
- guard let url = uri. fileURL else {
202
- // The URI is not a file, so there's nothing we can index.
203
- return false
204
- }
205
- return !index. hasUpToDateUnit ( for: url)
192
+ await withLoggingSubsystemAndScope ( subsystem: indexLoggingSubsystem, scope: " build-graph-generation " ) {
193
+ logger. log (
194
+ " Starting build graph generation with priority \( Task . currentPriority. rawValue, privacy: . public) "
195
+ )
196
+ let signposter = logger. makeSignposter ( )
197
+ let signpostID = signposter. makeSignpostID ( )
198
+ let state = signposter. beginInterval ( " Preparing " , id: signpostID, " Generating build graph " )
199
+ let startDate = Date ( )
200
+ defer {
201
+ logger. log (
202
+ " Finished build graph generation in \( Date ( ) . timeIntervalSince ( startDate) * 1000 , privacy: . public) ms "
203
+ )
204
+ signposter. endInterval ( " Preparing " , state)
206
205
}
207
- await scheduleBackgroundIndex ( files: filesToIndex)
208
- generateBuildGraphTask = nil
206
+ await testHooks. buildGraphGenerationDidStart ? ( )
207
+ await orLog ( " Generating build graph " ) { try await self . buildSystemManager. generateBuildGraph ( ) }
208
+ await testHooks. buildGraphGenerationDidFinish ? ( )
209
+ let index = index. checked ( for: . modifiedFiles)
210
+ let filesToIndex = await self . buildSystemManager. sourceFiles ( ) . lazy. map ( \. uri)
211
+ . filter { uri in
212
+ guard let url = uri. fileURL else {
213
+ // The URI is not a file, so there's nothing we can index.
214
+ return false
215
+ }
216
+ return !index. hasUpToDateUnit ( for: url)
217
+ }
218
+ await scheduleBackgroundIndex ( files: filesToIndex)
219
+ generateBuildGraphTask = nil
220
+ }
209
221
}
210
222
indexStatusDidChange ( )
211
223
}
0 commit comments