Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 6.1
// swift-tools-version: 6.2

import Foundation
import PackageDescription
Expand Down
4 changes: 2 additions & 2 deletions Sources/BuildServerIntegration/LegacyBuildServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import SKOptions
import SwiftExtensions
import ToolchainRegistry

#if compiler(>=6.3)
#warning("We have had a one year transition period to the pull based build server. Consider removing this build server")
#if compiler(>=6.5)
#warning("We have had a two year transition period to the pull based build server. Consider removing this build server")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/SolaWing/xcode-build-server is the only BSP server that I am aware of, which uses the legacy push-based model. While it has transitioned to the pull-based model (SolaWing/xcode-build-server@a030fea), it has not released a version that includes this change. Add another year of transition period to allow all BSP servers to transition.

#endif

/// Bridges the gap between the legacy push-based BSP settings model and the new pull based BSP settings model.
Expand Down
5 changes: 0 additions & 5 deletions Sources/CompletionScoring/Utilities/SwiftExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,6 @@ protocol ContiguousZeroBasedIndexedCollection: Collection where Index == Int {
var indices: Range<Int> { get }
}

#if compiler(<6.2)
/// Provide a compatibility layer for `SendableMetatype` if it doesn't exist in the compiler
typealias SendableMetatype = Any
#endif

extension ContiguousZeroBasedIndexedCollection {
func slicedConcurrentForEachSliceRange(body: @Sendable (Range<Index>) -> Void) where Self: SendableMetatype {
// We want to use `DispatchQueue.concurrentPerform`, but we want to be called only a few times. So that we
Expand Down
12 changes: 0 additions & 12 deletions Sources/SourceKitD/SourceKitD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,6 @@ package actor SourceKitD {
pluginPaths: PluginPaths?
) async throws -> SourceKitD {
try await SourceKitDRegistry.shared.getOrAdd(dylibPath, pluginPaths: pluginPaths) {
#if canImport(Darwin)
#if compiler(>=6.3)
#warning("Remove this when we no longer need to support sourcekitd_plugin_initialize")
#endif
if let pluginPaths {
try setenv(
name: "SOURCEKIT_LSP_PLUGIN_SOURCEKITD_PATH_\(pluginPaths.clientPlugin.realpath.filePath)",
value: dylibPath.filePath,
override: false
)
}
#endif
return try SourceKitD(dylib: dylibPath, pluginPaths: pluginPaths)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ import SourceKitLSP
import SwiftRefactor
import SwiftSyntax

#if compiler(<6.2)
/// Provide a compatibility layer for `SendableMetatype` if it doesn't exist in the compiler
typealias SendableMetatype = Any
#endif

/// Describes types that provide one or more code actions based on purely
/// syntactic information.
protocol SyntaxCodeActionProvider: SendableMetatype {
Expand Down
36 changes: 1 addition & 35 deletions Sources/SwiftSourceKitClientPlugin/ClientPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,11 @@ import SourceKitD
import SwiftExtensions
import SwiftSourceKitPluginCommon

#if compiler(>=6.3)
#warning("Remove sourcekitd_plugin_initialize when we no longer support toolchains that call it")
#endif

/// Legacy plugin initialization logic in which sourcekitd does not inform the plugin about the sourcekitd path it was
/// loaded from.
@_cdecl("sourcekitd_plugin_initialize")
public func sourcekitd_plugin_initialize(_ params: sourcekitd_api_plugin_initialize_params_t) {
#if canImport(Darwin)
var dlInfo = Dl_info()
dladdr(#dsohandle, &dlInfo)
let path = String(cString: dlInfo.dli_fname)
let clientPluginDylibUrl = URL(fileURLWithPath: path, isDirectory: false)
var url = clientPluginDylibUrl
while url.pathExtension != "framework" && url.lastPathComponent != "/" {
url.deleteLastPathComponent()
}
url =
url
.deletingLastPathComponent()
.appendingPathComponent("sourcekitd.framework")
.appendingPathComponent("sourcekitd")
if !FileManager.default.fileExists(at: url),
let clientPluginDylibUrlRealpath = try? clientPluginDylibUrl.realpath.filePath,
let sourcekitdPath = ProcessInfo.processInfo.environment[
"SOURCEKIT_LSP_PLUGIN_SOURCEKITD_PATH_\(clientPluginDylibUrlRealpath)"
]
{
// When using a SourceKit plugin from the build directory, we can't find sourcekitd relative to the plugin.
// Respect the sourcekitd path that was passed to us via an environment variable from
// `SourceKitD.getOrCreate`.
url = URL(fileURLWithPath: sourcekitdPath)
}
try! url.filePath.withCString { sourcekitdPath in
sourcekitd_plugin_initialize_2(params, sourcekitdPath)
}
#else
fatalError("sourcekitd_plugin_initialize is not supported on non-Darwin platforms")
#endif
fatalError("sourcekitd_plugin_initialize has been removed in favor of sourcekitd_plugin_initialize_2")
}

@_cdecl("sourcekitd_plugin_initialize_2")
Expand Down
32 changes: 1 addition & 31 deletions Sources/SwiftSourceKitPlugin/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,41 +157,11 @@ final class RequestHandler: Sendable {
}
}

#if compiler(>=6.3)
#warning("Remove sourcekitd_plugin_initialize when we no longer support toolchains that call it")
#endif

/// Legacy plugin initialization logic in which sourcekitd does not inform the plugin about the sourcekitd path it was
/// loaded from.
@_cdecl("sourcekitd_plugin_initialize")
public func sourcekitd_plugin_initialize(_ params: sourcekitd_api_plugin_initialize_params_t) {
#if canImport(Darwin)
var dlInfo = Dl_info()
dladdr(#dsohandle, &dlInfo)
let path = String(cString: dlInfo.dli_fname)
var url = URL(fileURLWithPath: path, isDirectory: false)
while url.pathExtension != "framework" && url.lastPathComponent != "/" {
url.deleteLastPathComponent()
}
url =
url
.deletingLastPathComponent()
.appendingPathComponent("sourcekitd.framework")
.appendingPathComponent("sourcekitd")
if FileManager.default.fileExists(at: url) {
try! url.filePath.withCString { sourcekitdPath in
sourcekitd_plugin_initialize_2(params, sourcekitdPath)
}
} else {
// When using a SourceKit plugin from the build directory, we can't find sourcekitd relative to the plugin.
// Since sourcekitd_plugin_initialize is only called on Darwin from Xcode toolchains, we know that we are getting
// called from an XPC sourcekitd. Thus, all sourcekitd symbols that we need should be loaded in the current process
// already and we can use `RTLD_DEFAULT` for the sourcekitd library.
sourcekitd_plugin_initialize_2(params, "SOURCEKIT_LSP_PLUGIN_PARENT_LIBRARY_RTLD_DEFAULT")
}
#else
fatalError("sourcekitd_plugin_initialize is not supported on non-Darwin platforms")
#endif
fatalError("sourcekitd_plugin_initialize has been removed in favor of sourcekitd_plugin_initialize_2")
}

#if canImport(Darwin)
Expand Down