@@ -45,6 +45,8 @@ package struct UpdateSymbolGraphTaskDescription: IndexTaskDescription {
4545 /// The build server manager that is used to get the toolchain and build settings.
4646 private let buildServerManager : BuildServerManager
4747
48+ private let symbolGraphUpToDateTracker : UpToDateTracker < BuildTargetIdentifier , DummySecondaryKey >
49+
4850 private let logMessageToIndexLog :
4951 @Sendable (
5052 _ message: String , _ type: WindowMessageType , _ structure: LanguageServerProtocol . StructuredLogKind
@@ -80,6 +82,7 @@ package struct UpdateSymbolGraphTaskDescription: IndexTaskDescription {
8082 target: BuildTargetIdentifier ,
8183 language: Language ,
8284 buildServerManager: BuildServerManager ,
85+ symbolGraphUpToDateTracker: UpToDateTracker < BuildTargetIdentifier , DummySecondaryKey > ,
8386 logMessageToIndexLog:
8487 @escaping @Sendable (
8588 _ message: String , _ type: WindowMessageType , _ structure: LanguageServerProtocol . StructuredLogKind
@@ -90,6 +93,7 @@ package struct UpdateSymbolGraphTaskDescription: IndexTaskDescription {
9093 self . target = target
9194 self . language = language
9295 self . buildServerManager = buildServerManager
96+ self . symbolGraphUpToDateTracker = symbolGraphUpToDateTracker
9397 self . logMessageToIndexLog = logMessageToIndexLog
9498 self . timeout = timeout
9599 }
@@ -98,6 +102,12 @@ package struct UpdateSymbolGraphTaskDescription: IndexTaskDescription {
98102 await withLoggingSubsystemAndScope ( subsystem: indexLoggingSubsystem, scope: " update-symbolgraph- \( id % 100 ) " ) {
99103 guard language == . swift else { return }
100104
105+ if await symbolGraphUpToDateTracker. isUpToDate ( target) {
106+ logger. debug ( " Not regenerating symbol graph for \( target. forLogging) because it is already up to date " )
107+ return
108+ }
109+
110+ let startDate = Date ( )
101111 let buildSettings : FileBuildSettings
102112 let swiftc : URL
103113
@@ -108,7 +118,7 @@ package struct UpdateSymbolGraphTaskDescription: IndexTaskDescription {
108118 for: firstFile,
109119 in: target,
110120 language: language,
111- fallbackAfterTimeout: true
121+ fallbackAfterTimeout: false
112122 )
113123 else { return }
114124 buildSettings = resolvedSettings
@@ -164,10 +174,7 @@ package struct UpdateSymbolGraphTaskDescription: IndexTaskDescription {
164174 {
165175 if i + 1 < rawArgs. count {
166176 baseArgs. append ( arg)
167- var next = rawArgs [ i + 1 ]
168- if next. contains ( " vscode-local: " ) {
169- next = next. replacingOccurrences ( of: " vscode-local: " , with: " file: " )
170- }
177+ let next = rawArgs [ i + 1 ]
171178 baseArgs. append ( next)
172179 i += 2
173180 } else {
@@ -195,14 +202,7 @@ package struct UpdateSymbolGraphTaskDescription: IndexTaskDescription {
195202 baseArgs. append ( " -wmo " )
196203 }
197204
198- // --- Clean environment ---
199- var cleanEnvironment = ProcessInfo . processInfo. environment
200- cleanEnvironment. removeValue ( forKey: " SWIFT_DRIVER_SUPPLEMENTARY_OUTPUT_FILE_MAP " )
201- cleanEnvironment. removeValue ( forKey: " SWIFT_DRIVER_OUTPUT_FILE_MAP " )
202- cleanEnvironment. removeValue ( forKey: " SWIFT_DRIVER_TEMP_DIR " )
203- cleanEnvironment. removeValue ( forKey: " SWIFT_DRIVER_RESPONSE_FILE_PATH " )
204- cleanEnvironment. removeValue ( forKey: " SWIFT_DRIVER_TOOLNAME " )
205-
205+ let environment = ProcessInfo . processInfo. environment
206206 let taskId = " symbol-graph- \( id) "
207207
208208 logMessageToIndexLog (
@@ -219,11 +219,14 @@ package struct UpdateSymbolGraphTaskDescription: IndexTaskDescription {
219219 " -Xfrontend " , " -emit-symbol-graph " ,
220220 " -Xfrontend " , " -emit-symbol-graph-dir " , " -Xfrontend " , symbolGraphDir. pathString,
221221 " -Xfrontend " , " -experimental-skip-all-function-bodies " ,
222+ " -Xfrontend " , " -experimental-lazy-typecheck " ,
223+ " -Xfrontend " , " -experimental-skip-non-exportable-decls " ,
224+ " -Xfrontend " , " -experimental-allow-module-with-compiler-errors " ,
222225 ]
223226 do {
224227 let process = Process (
225228 arguments: args,
226- environment: cleanEnvironment ,
229+ environment: environment ,
227230 workingDirectory: baseDir,
228231 outputRedirection: . none
229232 )
@@ -232,8 +235,14 @@ package struct UpdateSymbolGraphTaskDescription: IndexTaskDescription {
232235
233236 let result = try await process. waitUntilExit ( )
234237 let exitStatus = result. exitStatus. exhaustivelySwitchable
238+ let elapsed = Date ( ) . timeIntervalSince ( startDate) * 1000
239+
240+ logger. log (
241+ " Finished updating symbol graph in \( elapsed, privacy: . public) ms "
242+ )
235243
236244 if exitStatus. isSuccess {
245+ await symbolGraphUpToDateTracker. markUpToDate ( [ target] , updateOperationStartDate: startDate)
237246 logMessageToIndexLog (
238247 """
239248 Symbol graph generation completed successfully.
0 commit comments