9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDLSPSERVER_H 10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDLSPSERVER_H 15 #include "Features.inc" 21 #include "clang/Tooling/Core/Replacement.h" 22 #include "llvm/ADT/Optional.h" 44 llvm::Optional<Path> CompileCommandsDir,
bool UseDirBasedCDB,
45 llvm::Optional<OffsetEncoding> ForcedOffsetEncoding,
58 void onDiagnosticsReady(
PathRef File, std::vector<Diag> Diagnostics)
override;
61 onHighlightingsReady(
PathRef File,
62 std::vector<HighlightingToken> Highlightings)
override;
93 Callback<llvm::Optional<URIForFile>>);
95 Callback<std::vector<DocumentHighlight>>);
99 Callback<std::vector<SymbolInformation>>);
106 Callback<llvm::Optional<TypeHierarchyItem>>);
108 Callback<llvm::Optional<TypeHierarchyItem>>);
111 Callback<std::vector<SymbolDetails>>);
113 Callback<std::vector<SelectionRange>>);
115 Callback<std::vector<DocumentLink>>);
128 void reparseOpenedFiles();
135 void publishDiagnostics(
const URIForFile &File,
136 std::vector<clangd::Diagnostic> Diagnostics);
146 bool ShutdownRequestReceived =
false;
149 std::atomic<bool> IsBeingDestroyed = {
false};
151 std::mutex FixItsMutex;
153 DiagnosticToReplacementMap;
155 llvm::StringMap<DiagnosticToReplacementMap> FixItsMap;
156 std::mutex HighlightingsMutex;
157 llvm::StringMap<std::vector<HighlightingToken>> FileToHighlightings;
163 std::unique_ptr<MessageHandler> MsgHandler;
164 std::mutex TranspWriter;
166 template <
typename Response>
171 llvm::Expected<llvm::json::Value> RawResponse)
mutable {
174 CB(RawResponse.takeError());
175 }
else if (
fromJSON(*RawResponse, Rsp)) {
178 elog(
"Failed to decode {0} response", *RawResponse);
179 CB(llvm::make_error<LSPError>(
"failed to decode reponse",
183 callRaw(Method, std::move(Params), std::move(HandleReply));
185 void callRaw(StringRef Method, llvm::json::Value Params,
187 void notify(StringRef Method, llvm::json::Value Params);
199 bool SupportsCodeAction =
false;
201 bool SupportsHierarchicalDocumentSymbol =
false;
203 bool SupportFileStatus =
false;
207 bool SupportsOffsetsInSignatureHelp =
false;
213 llvm::Optional<Path> CompileCommandsDir;
214 std::unique_ptr<GlobalCompilationDatabase> BaseCDB;
216 llvm::Optional<OverlayCDB> CDB;
218 llvm::Optional<OffsetEncoding> NegotiatedOffsetEncoding;
220 llvm::Optional<ClangdServer>
Server;
225 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDLSPSERVER_H
Exact commands are not specified in the protocol so we define the ones supported by Clangd here...
bool run()
Run LSP server loop, communicating with the Transport provided in the constructor.
llvm::StringRef PathRef
A typedef to represent a ref to file path.
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
std::bitset< CompletionItemKindMax+1 > CompletionItemKindBitset
void elog(const char *Fmt, Ts &&... Vals)
MockFSProvider FSProvider
Parameters for the semantic highlighting (server-side) push notification.
Clangd extension: parameters configurable at any time, via the workspace/didChangeConfiguration notif...
Context clone() const
Clone this context object.
static const Context & current()
Returns the context for the current thread, creating it if needed.
A context is an immutable container for per-request data that must be propagated through layers that ...
~ClangdLSPServer()
The destructor blocks on any outstanding background tasks.
bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request)
A LSP-specific comparator used to find diagnostic in a container like std:map.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::bitset< SymbolKindMax+1 > SymbolKindBitset
The type hierarchy params is an extension of the TextDocumentPositionsParams with optional properties...
A thread-safe container for files opened in a workspace, addressed by filenames.
The parameters of a Workspace Symbol Request.
Parameters for the typeHierarchy/resolve request.
Parameters for the document link request.
This class exposes ClangdServer's capabilities via Language Server Protocol.
ClangdLSPServer(Transport &Transp, const FileSystemProvider &FSProvider, const clangd::CodeCompleteOptions &CCOpts, llvm::Optional< Path > CompileCommandsDir, bool UseDirBasedCDB, llvm::Optional< OffsetEncoding > ForcedOffsetEncoding, const ClangdServer::Options &Opts)
If CompileCommandsDir has a value, compile_commands.json will be loaded only from CompileCommandsDir...