9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDLSPSERVER_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDLSPSERVER_H
22#include "llvm/ADT/ArrayRef.h"
23#include "llvm/Support/JSON.h"
84 void onDiagnosticsReady(
PathRef File, llvm::StringRef Version,
88 void onSemanticsMaybeChanged(
PathRef File)
override;
90 std::vector<Range> InactiveRegions)
override;
115 Callback<std::vector<FoldingRange>>);
130 Callback<std::optional<URIForFile>>);
132 Callback<std::vector<DocumentHighlight>>);
135 Callback<std::vector<SymbolInformation>>);
142 Callback<std::vector<TypeHierarchyItem>>);
144 Callback<std::optional<std::vector<TypeHierarchyItem>>>);
146 Callback<std::vector<TypeHierarchyItem>>);
152 Callback<std::vector<CallHierarchyItem>>);
153 void onCallHierarchyIncomingCalls(
155 Callback<std::vector<CallHierarchyIncomingCall>>);
161 Callback<std::vector<SymbolDetails>>);
163 Callback<std::vector<SelectionRange>>);
165 Callback<std::vector<DocumentLink>>);
188 CreateWorkDoneProgress;
190 BeginWorkDoneProgress;
192 ReportWorkDoneProgress;
201 std::optional<ClangdServer::DiagRef> getDiagRef(StringRef
File,
214 void maybeExportMemoryProfile();
219 void maybeCleanupMemory();
230 bool ShutdownRequestReceived =
false;
233 std::atomic<bool> IsBeingDestroyed = {
false};
239 std::mutex DiagRefMutex;
243 bool operator<(
const DiagKey &Other)
const {
244 return std::tie(Rng, Message) < std::tie(Other.Rng, Other.Message);
247 DiagKey toDiagKey(
const clangd::Diagnostic &LSPDiag) {
248 return {LSPDiag.range, LSPDiag.message};
251 typedef std::map<DiagKey, ClangdServer::DiagRef>
252 DiagnosticToDiagRefMap;
254 llvm::StringMap<DiagnosticToDiagRefMap>
258 std::mutex SemanticTokensMutex;
259 llvm::StringMap<SemanticTokens> LastSemanticTokens;
263 clangd::Transport &Transp;
264 class MessageHandler;
265 std::unique_ptr<MessageHandler> MsgHandler;
266 std::mutex TranspWriter;
268 void callMethod(StringRef
Method, llvm::json::Value Params,
269 Callback<llvm::json::Value> CB)
override;
270 void notify(StringRef
Method, llvm::json::Value Params)
override;
272 LSPBinder::RawHandlers Handlers;
274 const ThreadsafeFS &TFS;
276 ClangdDiagnosticOptions DiagOpts;
282 bool SupportsCompletionLabelDetails =
false;
284 bool SupportsCodeAction =
false;
286 bool SupportsHierarchicalDocumentSymbol =
false;
288 bool SupportFileStatus =
false;
290 bool SupportsReferenceContainer =
false;
294 bool SupportsOffsetsInSignatureHelp =
false;
296 bool SupportsDocumentChanges =
false;
298 bool SupportsChangeAnnotation =
false;
300 std::mutex BackgroundIndexProgressMutex;
301 enum class BackgroundIndexProgress {
312 } BackgroundIndexProgressState = BackgroundIndexProgress::Unsupported;
315 BackgroundQueue::Stats PendingBackgroundIndexProgress;
317 bool BackgroundIndexSkipCreate =
false;
321 std::unique_ptr<GlobalCompilationDatabase> BaseCDB;
323 std::optional<OverlayCDB> CDB;
325 std::optional<ClangdServer> Server;
WantDiagnostics Diagnostics
This class exposes ClangdServer's capabilities via Language Server Protocol.
~ClangdLSPServer()
The destructor blocks on any outstanding background tasks.
void profile(MemoryTree &MT) const
Profiles resource-usage.
bool run()
Run LSP server loop, communicating with the Transport provided in the constructor.
Interface with hooks for users of ClangdServer to be notified of events.
A context is an immutable container for per-request data that must be propagated through layers that ...
LSPBinder collects a table of functions that handle LSP calls.
llvm::unique_function< void(const P &)> OutgoingNotification
llvm::unique_function< void(const P &, Callback< R >)> OutgoingMethod
Used to guard an operation that should run at most every N seconds.
Wrapper for vfs::FileSystem for use in multithreaded programs like clangd.
An interface base for small context-sensitive refactoring actions.
A source of configuration fragments.
std::bitset< SymbolKindMax+1 > SymbolKindBitset
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
bool operator<(const Ref &L, const Ref &R)
std::bitset< CompletionItemKindMax+1 > CompletionItemKindBitset
llvm::StringRef PathRef
A typedef to represent a ref to file path.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Payload for textDocument/ast request.
The parameter of a callHierarchy/incomingCalls request.
The parameter of a textDocument/prepareCallHierarchy request.
size_t ReferencesLimit
Limit the number of references returned (0 means no limit).
bool UseDirBasedCDB
Look for compilation databases, rather than using compile commands set via LSP (extensions) only.
clangd::RenameOptions Rename
std::function< void()> MemoryCleanup
If set, periodically called to release memory.
config::Provider * ConfigProvider
Supplies configuration (overrides ClangdServer::ContextProvider).
clangd::CodeCompleteOptions CodeComplete
Per-feature options.
std::function< bool(const Tweak &)> TweakFilter
Returns true if the tweak should be enabled.
MarkupKind SignatureHelpDocumentationFormat
std::optional< OffsetEncoding > Encoding
The offset-encoding to use, or std::nullopt to negotiate it over LSP.
Clangd extension: parameters configurable at any time, via the workspace/didChangeConfiguration notif...
Parameters for the document link request.
A parameter literal used in inlay hint requests.
A tree that can be used to represent memory usage of nested components while preserving the hierarchy...
Parameters for the typeHierarchy/resolve request.
Body of textDocument/semanticTokens/full/delta request.
Body of textDocument/semanticTokens/full request.
Arguments for the 'applyTweak' command.
The type hierarchy params is an extension of the TextDocumentPositionsParams with optional properties...
The edit should either provide changes or documentChanges.
The parameters of a Workspace Symbol Request.