@@ -16,45 +16,11 @@ import SourceKitD
1616import SwiftExtensions
1717import SwiftSourceKitPluginCommon
1818
19- #if compiler(>=6.3)
20- #warning("Remove sourcekitd_plugin_initialize when we no longer support toolchains that call it")
21- #endif
22-
2319/// Legacy plugin initialization logic in which sourcekitd does not inform the plugin about the sourcekitd path it was
2420/// loaded from.
2521@_cdecl ( " sourcekitd_plugin_initialize " )
2622public func sourcekitd_plugin_initialize( _ params: sourcekitd_api_plugin_initialize_params_t ) {
27- #if canImport(Darwin)
28- var dlInfo = Dl_info ( )
29- dladdr ( #dsohandle, & dlInfo)
30- let path = String ( cString: dlInfo. dli_fname)
31- let clientPluginDylibUrl = URL ( fileURLWithPath: path, isDirectory: false )
32- var url = clientPluginDylibUrl
33- while url. pathExtension != " framework " && url. lastPathComponent != " / " {
34- url. deleteLastPathComponent ( )
35- }
36- url =
37- url
38- . deletingLastPathComponent ( )
39- . appendingPathComponent ( " sourcekitd.framework " )
40- . appendingPathComponent ( " sourcekitd " )
41- if !FileManager. default. fileExists ( at: url) ,
42- let clientPluginDylibUrlRealpath = try ? clientPluginDylibUrl. realpath. filePath,
43- let sourcekitdPath = ProcessInfo . processInfo. environment [
44- " SOURCEKIT_LSP_PLUGIN_SOURCEKITD_PATH_ \( clientPluginDylibUrlRealpath) "
45- ]
46- {
47- // When using a SourceKit plugin from the build directory, we can't find sourcekitd relative to the plugin.
48- // Respect the sourcekitd path that was passed to us via an environment variable from
49- // `SourceKitD.getOrCreate`.
50- url = URL ( fileURLWithPath: sourcekitdPath)
51- }
52- try ! url. filePath. withCString { sourcekitdPath in
53- sourcekitd_plugin_initialize_2 ( params, sourcekitdPath)
54- }
55- #else
56- fatalError ( " sourcekitd_plugin_initialize is not supported on non-Darwin platforms " )
57- #endif
23+ fatalError ( " sourcekitd_plugin_initialize has been removed in favor of sourcekitd_plugin_initialize_2 " )
5824}
5925
6026@_cdecl ( " sourcekitd_plugin_initialize_2 " )
0 commit comments