[SourceKit] Add mechanism to load plugins for request handling into SourceKit

This allows us to load plugins into the sourcekitd service to handle requests (currently only used for code completion). This allows us to implement parts of sourcekitd in Swift and outside of the compiler repository, making it easier to iterated on them because the compiler doesn’t need to be rebuilt.
This commit is contained in:
Alex Hoppen
2025-01-03 14:04:21 +01:00
parent ed2f43e67d
commit b6c94aecc3
37 changed files with 3100 additions and 142 deletions

View File

@@ -40,6 +40,8 @@ SourceKit::Context::Context(
StringRef DiagnosticDocumentationPath,
llvm::function_ref<std::unique_ptr<LangSupport>(Context &)>
LangSupportFactoryFn,
llvm::function_ref<std::shared_ptr<PluginSupport>(Context &)>
PluginSupportFactoryFn,
bool shouldDispatchNotificationsOnMain)
: SwiftExecutablePath(SwiftExecutablePath), RuntimeLibPath(RuntimeLibPath),
DiagnosticDocumentationPath(DiagnosticDocumentationPath),
@@ -49,6 +51,7 @@ SourceKit::Context::Context(
SlowRequestSim(new SlowRequestSimulator(ReqTracker)) {
// Should be called last after everything is initialized.
SwiftLang = LangSupportFactoryFn(*this);
Plugins = PluginSupportFactoryFn(*this);
}
SourceKit::Context::~Context() {