Skip to content

Commit f22e13d

Browse files
authored
Merge pull request #2162 from bnbarham/20250519-manual-merge
Merge main into release/6.2
2 parents 041e066 + a0a8f1e commit f22e13d

File tree

8 files changed

+32
-18
lines changed

8 files changed

+32
-18
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ var targets: [Target] = [
229229
.product(name: "SwiftDocC", package: "swift-docc"),
230230
.product(name: "SymbolKit", package: "swift-docc-symbolkit"),
231231
],
232-
exclude: ["CMakeLists.txt"],
232+
exclude: [],
233233
swiftSettings: globalSwiftSettings
234234
),
235235

@@ -807,7 +807,7 @@ var dependencies: [Package.Dependency] {
807807
.package(url: "https://github.com/swiftlang/swift-docc.git", branch: relatedDependenciesBranch),
808808
.package(url: "https://github.com/swiftlang/swift-docc-symbolkit.git", branch: relatedDependenciesBranch),
809809
.package(url: "https://github.com/swiftlang/swift-markdown.git", branch: relatedDependenciesBranch),
810-
.package(url: "https://github.com/apple/swift-tools-support-core.git", branch: relatedDependenciesBranch),
810+
.package(url: "https://github.com/swiftlang/swift-tools-support-core.git", branch: relatedDependenciesBranch),
811811
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.4.0"),
812812
.package(url: "https://github.com/swiftlang/swift-syntax.git", branch: relatedDependenciesBranch),
813813
.package(url: "https://github.com/apple/swift-crypto.git", from: "3.0.0"),

Sources/BuildSystemIntegration/SwiftPMBuildSystem.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -203,19 +203,25 @@ package actor SwiftPMBuildSystem: BuiltInBuildSystem {
203203
throw Error.cannotDetermineHostToolchain
204204
}
205205

206+
var absProjectRoot = try AbsolutePath(validating: projectRoot.filePath)
206207
let hostSDK = try SwiftSDK.hostSwiftSDK(AbsolutePath(validating: destinationToolchainBinDir.filePath))
207208
let hostSwiftPMToolchain = try UserToolchain(swiftSDK: hostSDK)
208209

209210
let destinationSDK = try SwiftSDK.deriveTargetSwiftSDK(
210211
hostSwiftSDK: hostSDK,
211212
hostTriple: hostSwiftPMToolchain.targetTriple,
212-
customToolsets: options.swiftPMOrDefault.toolsets?.map { try AbsolutePath(validating: $0) } ?? [],
213+
customToolsets: options.swiftPMOrDefault.toolsets?.map {
214+
try AbsolutePath(validating: $0, relativeTo: absProjectRoot)
215+
} ?? [],
213216
customCompileTriple: options.swiftPMOrDefault.triple.map { try Triple($0) },
214217
swiftSDKSelector: options.swiftPMOrDefault.swiftSDK,
215218
store: SwiftSDKBundleStore(
216219
swiftSDKsDirectory: localFileSystem.getSharedSwiftSDKsDirectory(
217-
explicitDirectory: options.swiftPMOrDefault.swiftSDKsDirectory.map { try AbsolutePath(validating: $0) }
220+
explicitDirectory: options.swiftPMOrDefault.swiftSDKsDirectory.map {
221+
try AbsolutePath(validating: $0, relativeTo: absProjectRoot)
222+
}
218223
),
224+
hostToolchainBinDir: hostSwiftPMToolchain.swiftCompilerPath.parentDirectory,
219225
fileSystem: localFileSystem,
220226
observabilityScope: observabilitySystem.topScope.makeChildScope(description: "SwiftPM Bundle Store"),
221227
outputHandler: { _ in }
@@ -227,20 +233,14 @@ package actor SwiftPMBuildSystem: BuiltInBuildSystem {
227233
let destinationSwiftPMToolchain = try UserToolchain(swiftSDK: destinationSDK)
228234

229235
var location = try Workspace.Location(
230-
forRootPackage: try AbsolutePath(validating: projectRoot.filePath),
236+
forRootPackage: absProjectRoot,
231237
fileSystem: localFileSystem
232238
)
239+
233240
if options.backgroundIndexingOrDefault {
234-
location.scratchDirectory = try AbsolutePath(
235-
validating: projectRoot.appendingPathComponent(".build").appendingPathComponent("index-build").filePath
236-
)
237-
} else if let scratchDirectory = options.swiftPMOrDefault.scratchPath,
238-
let scratchDirectoryPath = try? AbsolutePath(
239-
validating: scratchDirectory,
240-
relativeTo: AbsolutePath(validating: projectRoot.filePath)
241-
)
242-
{
243-
location.scratchDirectory = scratchDirectoryPath
241+
location.scratchDirectory = absProjectRoot.appending(components: ".build", "index-build")
242+
} else if let scratchDirectory = options.swiftPMOrDefault.scratchPath {
243+
location.scratchDirectory = try AbsolutePath(validating: scratchDirectory, relativeTo: absProjectRoot)
244244
}
245245

246246
var configuration = WorkspaceConfiguration.default

Sources/SemanticIndex/PreparationTaskDescription.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ package struct PreparationTaskDescription: IndexTaskDescription {
105105
do {
106106
try await buildSystemManager.prepare(targets: Set(targetsToPrepare))
107107
} catch {
108-
logger.error(
109-
"Preparation failed: \(error.forLogging)"
110-
)
108+
logger.error("Preparation failed: \(error.forLogging)")
111109
}
112110
await hooks.preparationTaskDidFinish?(self)
113111
if !Task.isCancelled {

Sources/SemanticIndex/TaskScheduler.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,14 @@ package actor QueuedTask<TaskDescription: TaskDescriptionProtocol> {
249249
_isExecuting.value = true
250250
executionTask = task
251251
executionTaskCreatedContinuation.yield(task)
252+
if self.resultTaskCancelled.value {
253+
// The queued task might have been cancelled after the execution ask was started but before the task was yielded
254+
// to `executionTaskCreatedContinuation`. In that case the result task will simply cancel the await on the
255+
// `executionTaskCreatedStream` and hence not call `valuePropagatingCancellation` on the execution task. This
256+
// means that the queued task cancellation wouldn't be propagated to the execution task. To address this, check if
257+
// `resultTaskCancelled` was set and, if so, explicitly cancel the execution task here.
258+
task.cancel()
259+
}
252260
await executionStateChangedCallback?(self, .executing)
253261
return await task.value
254262
}
@@ -513,6 +521,9 @@ package actor TaskScheduler<TaskDescription: TaskDescriptionProtocol> {
513521
///
514522
/// This will continue calling itself until the queue is empty.
515523
private func poke() {
524+
if isShutDown {
525+
return
526+
}
516527
pendingTasks.sort(by: { $0.priority > $1.priority })
517528
for task in pendingTasks {
518529
guard

Sources/SourceKitLSP/Swift/MacroExpansion.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ actor MacroExpansionManager {
9494
let length = snapshot.utf8OffsetRange(of: range).count
9595

9696
let skreq = swiftLanguageService.sourcekitd.dictionary([
97+
keys.cancelOnSubsequentRequest: 0,
9798
keys.request: swiftLanguageService.requests.semanticRefactoring,
9899
// Preferred name for e.g. an extracted variable.
99100
// Empty string means sourcekitd chooses a name automatically.

Sources/SourceKitLSP/Swift/RefactoringResponse.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ extension SwiftLanguageService {
117117
let utf8Column = snapshot.lineTable.utf8ColumnAt(line: line, utf16Column: utf16Column)
118118

119119
let skreq = sourcekitd.dictionary([
120+
keys.cancelOnSubsequentRequest: 0,
120121
keys.request: self.requests.semanticRefactoring,
121122
// Preferred name for e.g. an extracted variable.
122123
// Empty string means sourcekitd chooses a name automatically.

Sources/SourceKitLSP/Swift/VariableTypeInfo.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ extension SwiftLanguageService {
8686
let snapshot = try await self.latestSnapshot(for: uri)
8787

8888
let skreq = sourcekitd.dictionary([
89+
keys.cancelOnSubsequentRequest: 0,
8990
keys.request: requests.collectVariableType,
9091
keys.sourceFile: snapshot.uri.sourcekitdSourceFile,
9192
keys.primaryFile: snapshot.uri.primaryFile?.pseudoPath,

Sources/sourcekit-lsp/SourceKitLSP.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ struct SourceKitLSP: AsyncParsableCommand {
237237
fatalError("failed to redirect stdout -> stderr: \(strerror(errno)!)")
238238
}
239239

240+
logger.log("sourcekit-lsp launched from \(ProcessInfo.processInfo.arguments.first ?? "<nil>")")
241+
240242
let globalConfigurationOptions = globalConfigurationOptions
241243
if let logLevelStr = globalConfigurationOptions.loggingOrDefault.level,
242244
let logLevel = NonDarwinLogLevel(logLevelStr)

0 commit comments

Comments
 (0)