This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Inject context provider rather than config into ClangdServer. NFC
ClosedPublic

Authored by sammccall on Jan 20 2021, 1:39 PM.

Details

Summary

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

Diff Detail

Event Timeline

sammccall created this revision.Jan 20 2021, 1:39 PM
sammccall requested review of this revision.Jan 20 2021, 1:39 PM
kadircet accepted this revision.Jan 22 2021, 2:19 AM
kadircet added inline comments.
clang-tools-extra/clangd/ClangdServer.cpp
277

nit: maybe finish here with a return and unify the duplicated if (ClientDiags) ClientDags->push_back.. after the switch.

This revision is now accepted and ready to land.Jan 22 2021, 2:19 AM