[clangd] Inject context provider rather than config into ClangdServer. NFC
authorSam McCall <sam.mccall@gmail.com>
Wed, 20 Jan 2021 21:34:24 +0000 (22:34 +0100)
committerSam McCall <sam.mccall@gmail.com>
Fri, 22 Jan 2021 13:34:30 +0000 (14:34 +0100)
commit60cd75a098d4f18d9c8903ddcb466b4e7deb0580
treebfefbadd81f2f35984d32430596b49e783d0e59b
parent7388c34685954862e5f1fa4734f42f7087e697a2
[clangd] Inject context provider rather than config into ClangdServer. NFC

This is a step towards allowing CDB behavior to being configurable.

Previously ClangdServer itself created the configs and installed them into
contexts. This was natural as it knows how to deal with resulting diagnostics.

However this prevents config being used in CDB, which must be created before
ClangdServer. So we extract the context provider (config loader) as a separate
object, which publishes diagnostics to a ClangdServer::Callbacks itself.

Now initialization looks like:
 - First create the config::Provider
 - Then create the ClangdLSPServer, passing config provider
 - Next, create the context provider, passing config provider + diagnostic callbacks
 - now create the CDB, passing context provider
 - finally create ClangdServer, passing CDB, context provider, and diagnostic callbacks

Differential Revision: https://reviews.llvm.org/D95087
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/unittests/ClangdTests.cpp