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>>);
187 CreateWorkDoneProgress;
189 BeginWorkDoneProgress;
191 ReportWorkDoneProgress;
200 std::optional<ClangdServer::DiagRef> getDiagRef(StringRef
File,
213 void maybeExportMemoryProfile();
218 void maybeCleanupMemory();
229 bool ShutdownRequestReceived =
false;
232 std::atomic<bool> IsBeingDestroyed = {
false};
238 std::mutex DiagRefMutex;
242 bool operator<(
const DiagKey &Other)
const {
243 return std::tie(Rng, Message) < std::tie(Other.Rng, Other.Message);
246 DiagKey toDiagKey(
const clangd::Diagnostic &LSPDiag) {
247 return {LSPDiag.range, LSPDiag.message};
250 typedef std::map<DiagKey, ClangdServer::DiagRef>
251 DiagnosticToDiagRefMap;
253 llvm::StringMap<DiagnosticToDiagRefMap>
257 std::mutex SemanticTokensMutex;
258 llvm::StringMap<SemanticTokens> LastSemanticTokens;
262 clangd::Transport &Transp;
263 class MessageHandler;
264 std::unique_ptr<MessageHandler> MsgHandler;
265 std::mutex TranspWriter;
267 void callMethod(StringRef
Method, llvm::json::Value Params,
268 Callback<llvm::json::Value> CB)
override;
269 void notify(StringRef
Method, llvm::json::Value Params)
override;
271 LSPBinder::RawHandlers Handlers;
273 const ThreadsafeFS &TFS;
275 ClangdDiagnosticOptions DiagOpts;
281 bool SupportsCompletionLabelDetails =
false;
283 bool SupportsCodeAction =
false;
285 bool SupportsHierarchicalDocumentSymbol =
false;
287 bool SupportFileStatus =
false;
289 bool SupportsReferenceContainer =
false;
293 bool SupportsOffsetsInSignatureHelp =
false;
295 bool SupportsDocumentChanges =
false;
297 bool SupportsChangeAnnotation =
false;
299 std::mutex BackgroundIndexProgressMutex;
300 enum class BackgroundIndexProgress {
311 } BackgroundIndexProgressState = BackgroundIndexProgress::Unsupported;
314 BackgroundQueue::Stats PendingBackgroundIndexProgress;
316 bool BackgroundIndexSkipCreate =
false;
320 std::unique_ptr<GlobalCompilationDatabase> BaseCDB;
322 std::optional<OverlayCDB> CDB;
324 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.