mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-06-24 12:21:58 +02:00
4b2fa3193a
Introduce `SourceKitDCore` as the protocol boundary between dylib lifecycle management and the high-level `SourceKitD` API. Its single lifecycle entry point, `initializeService(api:notificationCallback:)`, receives the already-loaded `sourcekitd_api_functions_t` from `SourceKitD.init(core:)`. `SourceKitDCoreImpl` is the standard implementation: `init` opens the dylib; `initializeService` registers any plugin paths, calls `api.initialize()`, and wires the notification handler; `deinit` calls `shutdown()` and closes the handle. Pre-initialized conformances implement `initializeService` as a no-op. Wire a `sourcekitdCoreInjector` hook through `Hooks` so an embedding host can return a pre-initialized `SourceKitDCore` for a given toolchain path, preventing `sourcekitd_initialize()` from being called a second time. Declare `SourceKitDCoreForPlugin` at its use sites so each call site can express the exact deinit behavior it needs: `dlclose` for handles acquired via `RTLD_NOLOAD`, and `leak` for externally-owned handles.