[PATCH] D96244: [clangd][RFC] Introudce Plugins

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 8 02:54:29 PST 2021


kadircet added inline comments.


================
Comment at: clang-tools-extra/clangd/Plugin.h:26
+  virtual llvm::Optional<CodeAction>
+  actOnDiagnostic(DiagnosticsEngine::Level L, const clang::Diagnostic &Diag) {
+    return llvm::None;
----------------
i think it would be better to have these as separate modules. for example a
```
class DiagnosticsModule {
public:
virtual llvm::Optional<CodeAction>
  actOnDiagnostic(DiagnosticsEngine::Level L, const clang::Diagnostic &Diag) = 0;
};
class HoverModule {
public:
virtual llvm::Optional<HoverInfo> generateHover(ParsedAST, Selection, SymbolIndex) = 0;
};
class LSPModule {
public:
virtual void registerHandler(EndPoint, Functor);
virtual json::Object dispatch(EndPoint, Params, ClangdServer&); // as some of these might need to mutate ClangdServer or access other modules.
};
// and so on.
```
and have multiple registries for each of these modules.

Then have a `PluginManager` in `ClangdServer` that provides a unified API for accessing these modules. (e.g. to implement each of our features in terms of these modules as discussed offline).

but I am not sure if it'll be worth the complexity with only diagnostics making use of that mechanism in the foreseeable future. So I am leaning towards keeping it simple in this version, but open for suggestions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96244/new/

https://reviews.llvm.org/D96244



More information about the cfe-commits mailing list