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"
87 void onDiagnosticsReady(
PathRef File, llvm::StringRef Version,
91 void onSemanticsMaybeChanged(
PathRef File)
override;
93 std::vector<Range> InactiveRegions)
override;
118 Callback<std::vector<FoldingRange>>);
133 Callback<std::optional<URIForFile>>);
135 Callback<std::vector<DocumentHighlight>>);
138 Callback<std::vector<SymbolInformation>>);
145 Callback<std::vector<TypeHierarchyItem>>);
147 Callback<std::optional<std::vector<TypeHierarchyItem>>>);
149 Callback<std::vector<TypeHierarchyItem>>);
155 Callback<std::vector<CallHierarchyItem>>);
156 void onCallHierarchyIncomingCalls(
158 Callback<std::vector<CallHierarchyIncomingCall>>);
164 Callback<std::vector<SymbolDetails>>);
166 Callback<std::vector<SelectionRange>>);
168 Callback<std::vector<DocumentLink>>);
191 CreateWorkDoneProgress;
193 BeginWorkDoneProgress;
195 ReportWorkDoneProgress;
204 std::optional<ClangdServer::DiagRef> getDiagRef(StringRef
File,
217 void maybeExportMemoryProfile();
222 void maybeCleanupMemory();
233 bool ShutdownRequestReceived =
false;
236 std::atomic<bool> IsBeingDestroyed = {
false};
242 std::mutex DiagRefMutex;
246 bool operator<(
const DiagKey &Other)
const {
247 return std::tie(Rng, Message) < std::tie(Other.Rng, Other.Message);
250 DiagKey toDiagKey(
const clangd::Diagnostic &LSPDiag) {
251 return {LSPDiag.range, LSPDiag.message};
254 typedef std::map<DiagKey, ClangdServer::DiagRef>
255 DiagnosticToDiagRefMap;
257 llvm::StringMap<DiagnosticToDiagRefMap>
261 std::mutex SemanticTokensMutex;
262 llvm::StringMap<SemanticTokens> LastSemanticTokens;
266 clangd::Transport &Transp;
267 class MessageHandler;
268 std::unique_ptr<MessageHandler> MsgHandler;
269 std::mutex TranspWriter;
271 void callMethod(StringRef
Method, llvm::json::Value Params,
272 Callback<llvm::json::Value> CB)
override;
273 void notify(StringRef
Method, llvm::json::Value Params)
override;
275 LSPBinder::RawHandlers Handlers;
277 const ThreadsafeFS &TFS;
279 ClangdDiagnosticOptions DiagOpts;
285 bool SupportsCompletionLabelDetails =
false;
287 bool SupportsCodeAction =
false;
289 bool SupportsHierarchicalDocumentSymbol =
false;
291 bool SupportFileStatus =
false;
293 bool SupportsReferenceContainer =
false;
297 bool SupportsOffsetsInSignatureHelp =
false;
299 bool SupportsDocumentChanges =
false;
301 bool SupportsChangeAnnotation =
false;
303 std::mutex BackgroundIndexProgressMutex;
304 enum class BackgroundIndexProgress {
315 } BackgroundIndexProgressState = BackgroundIndexProgress::Unsupported;
318 BackgroundQueue::Stats PendingBackgroundIndexProgress;
320 bool BackgroundIndexSkipCreate =
false;
324 std::unique_ptr<GlobalCompilationDatabase> BaseCDB;
326 std::optional<OverlayCDB> CDB;
328 std::optional<ClangdServer> Server;
330 std::optional<ModulesBuilder> ModulesManager;
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.
bool EnableExperimentalModulesSupport
Flag to hint the experimental modules support is enabled.
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.