Skip to content

Commit 24f361c

Browse files
authored
Merge pull request #2093 from ahoppen/remove-dynamically-loaded-sourcekitd
Remove the split between `SourceKitD` and `DynamicallyLoadedSourceKitD`
2 parents db981d9 + 53407f5 commit 24f361c

25 files changed

+339
-458
lines changed

Sources/BuildSystemIntegration/BuildSystemMessageDependencyTracker.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import BuildServerProtocol
1414
package import LanguageServerProtocol
1515
import LanguageServerProtocolExtensions
1616
import SKLogging
17-
package import SwiftExtensions
17+
import SwiftExtensions
1818

1919
/// A lightweight way of describing tasks that are created from handling BSP
2020
/// requests or notifications for the purpose of dependency tracking.

Sources/Csourcekitd/include/plugin.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ typedef const void *_Null_unspecified (*sourcekitd_api_variant_functions_data_ge
114114
typedef bool (^sourcekitd_api_cancellable_request_handler_t)(
115115
_Null_unspecified sourcekitd_api_object_t,
116116
_Null_unspecified sourcekitd_api_request_handle_t,
117-
void (^_Null_unspecified __attribute__((swift_attr("@Sendable"))))(_Null_unspecified sourcekitd_api_response_t)
117+
void (^_Null_unspecified SWIFT_SENDABLE)(_Null_unspecified sourcekitd_api_response_t)
118118
);
119119
typedef void (^sourcekitd_api_cancellation_handler_t)(_Null_unspecified sourcekitd_api_request_handle_t);
120120
typedef _Null_unspecified sourcekitd_api_uid_t (*sourcekitd_api_uid_get_from_cstr_t)(const char *_Null_unspecified string);
@@ -233,11 +233,11 @@ typedef struct {
233233
_Null_unspecified sourcekitd_api_plugin_initialize_params_t
234234
);
235235

236-
_Null_unspecified sourcekitd_api_uid_get_from_cstr_t (*_Nonnull plugin_initialize_uid_get_from_cstr)(
236+
_Null_unspecified SWIFT_SENDABLE sourcekitd_api_uid_get_from_cstr_t (*_Nonnull plugin_initialize_uid_get_from_cstr)(
237237
_Null_unspecified sourcekitd_api_plugin_initialize_params_t
238238
);
239239

240-
_Null_unspecified sourcekitd_api_uid_get_string_ptr_t (*_Nonnull plugin_initialize_uid_get_string_ptr)(
240+
_Null_unspecified SWIFT_SENDABLE sourcekitd_api_uid_get_string_ptr_t (*_Nonnull plugin_initialize_uid_get_string_ptr)(
241241
_Null_unspecified sourcekitd_api_plugin_initialize_params_t
242242
);
243243

@@ -251,7 +251,7 @@ typedef struct {
251251
typedef struct {
252252
void (*_Nonnull plugin_initialize_register_cancellable_request_handler)(
253253
_Nonnull sourcekitd_api_plugin_initialize_params_t,
254-
_Nonnull sourcekitd_api_cancellable_request_handler_t
254+
_Nonnull SWIFT_SENDABLE sourcekitd_api_cancellable_request_handler_t
255255
);
256256

257257
/// Adds a function that will be called when a request is cancelled.
@@ -260,7 +260,7 @@ typedef struct {
260260
/// handle to be cancelled, it should ignore the cancellation request.
261261
void (*_Nonnull plugin_initialize_register_cancellation_handler)(
262262
_Nonnull sourcekitd_api_plugin_initialize_params_t,
263-
_Nonnull sourcekitd_api_cancellation_handler_t
263+
_Nonnull SWIFT_SENDABLE sourcekitd_api_cancellation_handler_t
264264
);
265265

266266
void *_Null_unspecified(*_Nonnull plugin_initialize_get_swift_ide_inspection_instance)(

Sources/Csourcekitd/include/sourcekitd_functions.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <stddef.h>
1818
#include <stdint.h>
1919

20+
#define SWIFT_SENDABLE __attribute__((__swift_attr__("@Sendable")))
21+
2022
// Avoid including <sourcekitd/sourcekitd.h> to make sure we don't call the
2123
// functions directly. But we need the types to form the function pointers.
2224
// These are supposed to stay stable across toolchains.
@@ -315,17 +317,17 @@ typedef struct {
315317
void (*_Nonnull send_request)(
316318
sourcekitd_api_object_t _Nonnull req,
317319
_Nullable sourcekitd_api_request_handle_t *_Nullable out_handle,
318-
_Nullable sourcekitd_api_response_receiver_t receiver
320+
_Nullable SWIFT_SENDABLE sourcekitd_api_response_receiver_t receiver
319321
);
320322
void (*_Nonnull cancel_request)(
321323
_Nullable sourcekitd_api_request_handle_t handle
322324
);
323325
void (*_Nonnull set_notification_handler)(
324-
_Nullable sourcekitd_api_response_receiver_t receiver
326+
_Nullable SWIFT_SENDABLE sourcekitd_api_response_receiver_t receiver
325327
);
326328
void (*_Nonnull set_uid_handlers)(
327-
_Nullable sourcekitd_api_uid_from_str_handler_t uid_from_str,
328-
_Nullable sourcekitd_api_str_from_uid_handler_t str_from_uid
329+
_Nullable SWIFT_SENDABLE sourcekitd_api_uid_from_str_handler_t uid_from_str,
330+
_Nullable SWIFT_SENDABLE sourcekitd_api_str_from_uid_handler_t str_from_uid
329331
);
330332
} sourcekitd_api_functions_t;
331333

Sources/Diagnose/RunSourcekitdRequestCommand.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ package struct RunSourceKitdRequestCommand: AsyncParsableCommand {
5454
print("Did not find sourcekitd in the toolchain. Specify path to sourcekitd manually by passing --sourcekitd")
5555
throw ExitCode(1)
5656
}
57-
let sourcekitd = try await DynamicallyLoadedSourceKitD.getOrCreate(
57+
let sourcekitd = try await SourceKitD.getOrCreate(
5858
dylibPath: sourcekitdPath,
5959
pluginPaths: nil
6060
)

Sources/SKTestSupport/SkipUnless.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ package actor SkipUnless {
253253
guard let sourcekitdPath = await ToolchainRegistry.forTesting.default?.sourcekitd else {
254254
throw GenericError("Could not find SourceKitD")
255255
}
256-
let sourcekitd = try await DynamicallyLoadedSourceKitD.getOrCreate(
256+
let sourcekitd = try await SourceKitD.getOrCreate(
257257
dylibPath: sourcekitdPath,
258258
pluginPaths: try sourceKitPluginPaths
259259
)

Sources/SourceKitD/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ set(sources
66
SKDResponseArray.swift
77
SKDResponseDictionary.swift
88
SourceKitD.swift
9-
DynamicallyLoadedSourceKitD.swift
109
SourceKitDRegistry.swift
1110
sourcekitd_functions.swift
1211
sourcekitd_uids.swift)

Sources/SourceKitD/DynamicallyLoadedSourceKitD.swift

-288
This file was deleted.

0 commit comments

Comments
 (0)