9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDLSPSERVER_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDLSPSERVER_H
14 #include "Features.inc"
21 #include "clang/Tooling/Core/Replacement.h"
22 #include "llvm/ADT/Optional.h"
23 #include "llvm/ADT/StringSet.h"
24 #include "llvm/Support/JSON.h"
47 llvm::Optional<Path> CompileCommandsDir,
bool UseDirBasedCDB,
48 llvm::Optional<OffsetEncoding> ForcedOffsetEncoding,
61 void onDiagnosticsReady(
PathRef File, llvm::StringRef Version,
62 std::vector<Diag> Diagnostics)
override;
65 onHighlightingsReady(
PathRef File, llvm::StringRef Version,
66 std::vector<HighlightingToken> Highlightings)
override;
91 Callback<std::vector<FoldingRange>>);
102 Callback<llvm::Optional<URIForFile>>);
104 Callback<std::vector<DocumentHighlight>>);
108 Callback<std::vector<SymbolInformation>>);
115 Callback<llvm::Optional<TypeHierarchyItem>>);
117 Callback<llvm::Optional<TypeHierarchyItem>>);
120 Callback<std::vector<SymbolDetails>>);
122 Callback<std::vector<SelectionRange>>);
124 Callback<std::vector<DocumentLink>>);
141 void reparseOpenFilesIfNeeded(
142 llvm::function_ref<
bool(llvm::StringRef
File)> Filter);
160 bool ShutdownRequestReceived =
false;
163 std::atomic<bool> IsBeingDestroyed = {
false};
165 std::mutex FixItsMutex;
167 DiagnosticToReplacementMap;
169 llvm::StringMap<DiagnosticToReplacementMap> FixItsMap;
170 std::mutex HighlightingsMutex;
171 llvm::StringMap<std::vector<HighlightingToken>> FileToHighlightings;
173 std::mutex SemanticTokensMutex;
174 llvm::StringMap<SemanticTokens> LastSemanticTokens;
180 std::unique_ptr<MessageHandler> MsgHandler;
181 std::mutex TranspWriter;
183 template <
typename Response>
188 llvm::Expected<llvm::json::Value> RawResponse)
mutable {
191 CB(RawResponse.takeError());
192 }
else if (
fromJSON(*RawResponse, Rsp)) {
195 elog(
"Failed to decode {0} response", *RawResponse);
196 CB(llvm::make_error<LSPError>(
"failed to decode response",
200 callRaw(
Method, std::move(Params), std::move(HandleReply));
202 void callRaw(StringRef
Method, llvm::json::Value Params,
204 void notify(StringRef
Method, llvm::json::Value Params);
205 template <
typename T>
void progress(
const llvm::json::Value &Token, T
Value) {
207 Params.
token = Token;
209 notify(
"$/progress", Params);
224 bool SupportsCodeAction =
false;
226 bool SupportsHierarchicalDocumentSymbol =
false;
228 bool SupportFileStatus =
false;
232 bool SupportsOffsetsInSignatureHelp =
false;
233 std::mutex BackgroundIndexProgressMutex;
234 enum class BackgroundIndexProgress {
245 } BackgroundIndexProgressState = BackgroundIndexProgress::Unsupported;
250 bool BackgroundIndexSkipCreate =
false;
256 llvm::Optional<Path> CompileCommandsDir;
257 std::unique_ptr<GlobalCompilationDatabase> BaseCDB;
259 llvm::Optional<OverlayCDB> CDB;
261 llvm::Optional<OffsetEncoding> NegotiatedOffsetEncoding;
263 llvm::Optional<ClangdServer> Server;
268 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDLSPSERVER_H