[SourceKit] Use a single PluginRegistry in multiple ASTContexts

Make a single 'PluginRegistry' and share it between SwiftASTManager,
IDEInspectionInstance, and CompileInstance. And inject the plugin
registry to ASTContext right after 'CompilerInstance.setup()'

That way, all sema-capable ASTContext in SourceKit share a single
PluginRegistry.
This commit is contained in:
Rintaro Ishizaki
2023-03-27 13:38:50 -07:00
parent 5bb6f79847
commit a4d1fc6abe
12 changed files with 60 additions and 25 deletions

View File

@@ -31,7 +31,9 @@ compile::SessionManager::getSession(StringRef name) {
}
bool inserted = false;
std::tie(i, inserted) = sessions.try_emplace(name, std::make_shared<compile::Session>(RuntimeResourcePath, DiagnosticDocumentationPath));
std::tie(i, inserted) = sessions.try_emplace(
name, std::make_shared<compile::Session>(
RuntimeResourcePath, DiagnosticDocumentationPath, Plugins));
assert(inserted);
return i->second;
}
@@ -141,10 +143,10 @@ void SwiftLangSupport::performCompile(
CancellationFlag->store(true, std::memory_order_relaxed);
});
CompileManager.performCompileAsync(Name, Args, std::move(fileSystem),
CancellationFlag, Receiver);
CompileManager->performCompileAsync(Name, Args, std::move(fileSystem),
CancellationFlag, Receiver);
}
void SwiftLangSupport::closeCompile(StringRef Name) {
CompileManager.clearSession(Name);
CompileManager->clearSession(Name);
}