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"
90 void onDiagnosticsReady(
PathRef File, llvm::StringRef Version,
94 void onSemanticsMaybeChanged(
PathRef File)
override;
96 std::vector<Range> InactiveRegions)
override;
121 Callback<std::vector<FoldingRange>>);
136 Callback<std::optional<URIForFile>>);
138 Callback<std::vector<DocumentHighlight>>);
141 Callback<std::vector<SymbolInformation>>);
148 Callback<std::vector<TypeHierarchyItem>>);
150 Callback<std::optional<std::vector<TypeHierarchyItem>>>);
152 Callback<std::vector<TypeHierarchyItem>>);
158 Callback<std::vector<CallHierarchyItem>>);
159 void onCallHierarchyIncomingCalls(
161 Callback<std::vector<CallHierarchyIncomingCall>>);
162 void onCallHierarchyOutgoingCalls(
164 Callback<std::vector<CallHierarchyOutgoingCall>>);
170 Callback<std::vector<SymbolDetails>>);
172 Callback<std::vector<SelectionRange>>);
174 Callback<std::vector<DocumentLink>>);
197 CreateWorkDoneProgress;
199 BeginWorkDoneProgress;
201 ReportWorkDoneProgress;
210 std::optional<ClangdServer::DiagRef> getDiagRef(StringRef
File,
223 void maybeExportMemoryProfile();
228 void maybeCleanupMemory();
239 bool ShutdownRequestReceived =
false;
242 std::atomic<bool> IsBeingDestroyed = {
false};
248 std::mutex DiagRefMutex;
252 bool operator<(
const DiagKey &Other)
const {
253 return std::tie(Rng, Message) < std::tie(Other.Rng, Other.Message);
256 DiagKey toDiagKey(
const clangd::Diagnostic &LSPDiag) {
257 return {LSPDiag.range, LSPDiag.message};
260 typedef std::map<DiagKey, ClangdServer::DiagRef>
261 DiagnosticToDiagRefMap;
263 llvm::StringMap<DiagnosticToDiagRefMap>
267 std::mutex SemanticTokensMutex;
268 llvm::StringMap<SemanticTokens> LastSemanticTokens;
272 clangd::Transport &Transp;
273 class MessageHandler;
274 std::unique_ptr<MessageHandler> MsgHandler;
275 std::mutex TranspWriter;
277 void callMethod(StringRef
Method, llvm::json::Value Params,
278 Callback<llvm::json::Value> CB)
override;
279 void notify(StringRef
Method, llvm::json::Value Params)
override;
281 LSPBinder::RawHandlers Handlers;
283 const ThreadsafeFS &TFS;
285 ClangdDiagnosticOptions DiagOpts;
291 bool SupportsCompletionLabelDetails =
false;
293 bool SupportsCodeAction =
false;
295 bool SupportsHierarchicalDocumentSymbol =
false;
297 bool SupportFileStatus =
false;
299 bool SupportsReferenceContainer =
false;
303 bool SupportsOffsetsInSignatureHelp =
false;
305 bool SupportsDocumentChanges =
false;
307 bool SupportsChangeAnnotation =
false;
309 std::mutex BackgroundIndexProgressMutex;
310 enum class BackgroundIndexProgress {
321 } BackgroundIndexProgressState = BackgroundIndexProgress::Unsupported;
324 BackgroundQueue::Stats PendingBackgroundIndexProgress;
326 bool BackgroundIndexSkipCreate =
false;
330 std::unique_ptr<GlobalCompilationDatabase> BaseCDB;
332 std::optional<OverlayCDB> CDB;
334 std::optional<ClangdServer> Server;
336 std::optional<ModulesBuilder> ModulesManager;
WantDiagnostics Diagnostics
This class exposes ClangdServer's capabilities via Language Server Protocol.
ClangdLSPServer & operator=(const ClangdLSPServer &other)=delete
~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.
ClangdLSPServer(const ClangdLSPServer &other)=delete
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 callHierarchy/outgoingCalls 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.