blob: 92fa2f7e15ce325134d0e9a8123200f7b8b02950 [file] [log] [blame]
Ilya Biryukov38d79772017-05-16 09:38:59 +00001//===--- ClangdServer.h - Main clangd server code ----------------*- C++-*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDSERVER_H
11#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDSERVER_H
12
Eric Liub99d5e82017-12-14 21:22:03 +000013#include "ClangdUnit.h"
Ilya Biryukov38d79772017-05-16 09:38:59 +000014#include "ClangdUnitStore.h"
Eric Liub99d5e82017-12-14 21:22:03 +000015#include "CodeComplete.h"
Ilya Biryukov38d79772017-05-16 09:38:59 +000016#include "DraftStore.h"
Eric Liub99d5e82017-12-14 21:22:03 +000017#include "Function.h"
Ilya Biryukov38d79772017-05-16 09:38:59 +000018#include "GlobalCompilationDatabase.h"
Eric Liub99d5e82017-12-14 21:22:03 +000019#include "Protocol.h"
Eric Liubfac8f72017-12-19 18:00:37 +000020#include "index/FileIndex.h"
Ilya Biryukov38d79772017-05-16 09:38:59 +000021#include "clang/Tooling/CompilationDatabase.h"
22#include "clang/Tooling/Core/Replacement.h"
23#include "llvm/ADT/IntrusiveRefCntPtr.h"
24#include "llvm/ADT/Optional.h"
25#include "llvm/ADT/StringRef.h"
Ilya Biryukov38d79772017-05-16 09:38:59 +000026#include <condition_variable>
Ilya Biryukovf01af682017-05-23 13:42:59 +000027#include <functional>
Ilya Biryukov38d79772017-05-16 09:38:59 +000028#include <mutex>
29#include <string>
30#include <thread>
Ilya Biryukov22602992017-05-30 15:11:02 +000031#include <type_traits>
Ilya Biryukov38d79772017-05-16 09:38:59 +000032#include <utility>
33
34namespace clang {
35class PCHContainerOperations;
36
37namespace clangd {
38
Ilya Biryukov22602992017-05-30 15:11:02 +000039/// A tag supplied by the FileSytemProvider.
Ilya Biryukove36035b2017-06-13 08:24:48 +000040typedef std::string VFSTag;
Ilya Biryukov22602992017-05-30 15:11:02 +000041
42/// A value of an arbitrary type and VFSTag that was supplied by the
43/// FileSystemProvider when this value was computed.
44template <class T> class Tagged {
45public:
Ilya Biryukove81b7622017-10-05 22:15:15 +000046 // MSVC requires future<> arguments to be default-constructible.
47 Tagged() = default;
48
Ilya Biryukov22602992017-05-30 15:11:02 +000049 template <class U>
Ilya Biryukove36035b2017-06-13 08:24:48 +000050 Tagged(U &&Value, VFSTag Tag)
51 : Value(std::forward<U>(Value)), Tag(std::move(Tag)) {}
Ilya Biryukov22602992017-05-30 15:11:02 +000052
53 template <class U>
54 Tagged(const Tagged<U> &Other) : Value(Other.Value), Tag(Other.Tag) {}
55
56 template <class U>
Ilya Biryukove36035b2017-06-13 08:24:48 +000057 Tagged(Tagged<U> &&Other)
58 : Value(std::move(Other.Value)), Tag(std::move(Other.Tag)) {}
Ilya Biryukov22602992017-05-30 15:11:02 +000059
Ilya Biryukove81b7622017-10-05 22:15:15 +000060 T Value = T();
61 VFSTag Tag = VFSTag();
Ilya Biryukov22602992017-05-30 15:11:02 +000062};
63
64template <class T>
65Tagged<typename std::decay<T>::type> make_tagged(T &&Value, VFSTag Tag) {
Ilya Biryukovc22824a2017-08-09 12:55:13 +000066 return Tagged<typename std::decay<T>::type>(std::forward<T>(Value), Tag);
Ilya Biryukov22602992017-05-30 15:11:02 +000067}
68
Ilya Biryukov38d79772017-05-16 09:38:59 +000069class DiagnosticsConsumer {
70public:
71 virtual ~DiagnosticsConsumer() = default;
72
73 /// Called by ClangdServer when \p Diagnostics for \p File are ready.
Ilya Biryukov22602992017-05-30 15:11:02 +000074 virtual void
Ilya Biryukov95558392018-01-10 17:59:27 +000075 onDiagnosticsReady(const Context &Ctx, PathRef File,
Ilya Biryukov22602992017-05-30 15:11:02 +000076 Tagged<std::vector<DiagWithFixIts>> Diagnostics) = 0;
Ilya Biryukov38d79772017-05-16 09:38:59 +000077};
78
Ilya Biryukov0f62ed22017-05-26 12:26:51 +000079class FileSystemProvider {
80public:
81 virtual ~FileSystemProvider() = default;
Ilya Biryukovaf0c04b2017-06-14 09:46:44 +000082 /// Called by ClangdServer to obtain a vfs::FileSystem to be used for parsing.
83 /// Name of the file that will be parsed is passed in \p File.
84 ///
Ilya Biryukov22602992017-05-30 15:11:02 +000085 /// \return A filesystem that will be used for all file accesses in clangd.
86 /// A Tag returned by this method will be propagated to all results of clangd
87 /// that will use this filesystem.
Ilya Biryukovaf0c04b2017-06-14 09:46:44 +000088 virtual Tagged<IntrusiveRefCntPtr<vfs::FileSystem>>
89 getTaggedFileSystem(PathRef File) = 0;
Ilya Biryukov0f62ed22017-05-26 12:26:51 +000090};
91
92class RealFileSystemProvider : public FileSystemProvider {
93public:
Ilya Biryukov22602992017-05-30 15:11:02 +000094 /// \return getRealFileSystem() tagged with default tag, i.e. VFSTag()
Ilya Biryukovaf0c04b2017-06-14 09:46:44 +000095 Tagged<IntrusiveRefCntPtr<vfs::FileSystem>>
96 getTaggedFileSystem(PathRef File) override;
Ilya Biryukov0f62ed22017-05-26 12:26:51 +000097};
98
Ilya Biryukov38d79772017-05-16 09:38:59 +000099class ClangdServer;
100
Ilya Biryukovdb8b2d72017-08-14 08:45:47 +0000101/// Returns a number of a default async threads to use for ClangdScheduler.
102/// Returned value is always >= 1 (i.e. will not cause requests to be processed
103/// synchronously).
104unsigned getDefaultAsyncThreadsCount();
105
106/// Handles running WorkerRequests of ClangdServer on a number of worker
107/// threads.
Ilya Biryukov38d79772017-05-16 09:38:59 +0000108class ClangdScheduler {
109public:
Ilya Biryukovdb8b2d72017-08-14 08:45:47 +0000110 /// If \p AsyncThreadsCount is 0, requests added using addToFront and addToEnd
111 /// will be processed synchronously on the calling thread.
112 // Otherwise, \p AsyncThreadsCount threads will be created to schedule the
113 // requests.
114 ClangdScheduler(unsigned AsyncThreadsCount);
Ilya Biryukov38d79772017-05-16 09:38:59 +0000115 ~ClangdScheduler();
116
Ilya Biryukov02d58702017-08-01 15:51:38 +0000117 /// Add a new request to run function \p F with args \p As to the start of the
118 /// queue. The request will be run on a separate thread.
119 template <class Func, class... Args>
120 void addToFront(Func &&F, Args &&... As) {
121 if (RunSynchronously) {
122 std::forward<Func>(F)(std::forward<Args>(As)...);
123 return;
124 }
125
126 {
127 std::lock_guard<std::mutex> Lock(Mutex);
Ilya Biryukov08e6ccb2017-10-09 16:26:26 +0000128 RequestQueue.push_front(
129 BindWithForward(std::forward<Func>(F), std::forward<Args>(As)...));
Ilya Biryukov02d58702017-08-01 15:51:38 +0000130 }
131 RequestCV.notify_one();
132 }
133
134 /// Add a new request to run function \p F with args \p As to the end of the
135 /// queue. The request will be run on a separate thread.
136 template <class Func, class... Args> void addToEnd(Func &&F, Args &&... As) {
137 if (RunSynchronously) {
138 std::forward<Func>(F)(std::forward<Args>(As)...);
139 return;
140 }
141
142 {
143 std::lock_guard<std::mutex> Lock(Mutex);
Ilya Biryukov08e6ccb2017-10-09 16:26:26 +0000144 RequestQueue.push_back(
145 BindWithForward(std::forward<Func>(F), std::forward<Args>(As)...));
Ilya Biryukov02d58702017-08-01 15:51:38 +0000146 }
147 RequestCV.notify_one();
148 }
Ilya Biryukov38d79772017-05-16 09:38:59 +0000149
150private:
151 bool RunSynchronously;
152 std::mutex Mutex;
Ilya Biryukovdb8b2d72017-08-14 08:45:47 +0000153 /// We run some tasks on separate threads(parsing, CppFile cleanup).
154 /// These threads looks into RequestQueue to find requests to handle and
155 /// terminate when Done is set to true.
156 std::vector<std::thread> Workers;
157 /// Setting Done to true will make the worker threads terminate.
Ilya Biryukov38d79772017-05-16 09:38:59 +0000158 bool Done = false;
Ilya Biryukovdb8b2d72017-08-14 08:45:47 +0000159 /// A queue of requests. Elements of this vector are async computations (i.e.
160 /// results of calling std::async(std::launch::deferred, ...)).
Ilya Biryukov08e6ccb2017-10-09 16:26:26 +0000161 std::deque<UniqueFunction<void()>> RequestQueue;
Ilya Biryukovdb8b2d72017-08-14 08:45:47 +0000162 /// Condition variable to wake up worker threads.
Ilya Biryukov38d79772017-05-16 09:38:59 +0000163 std::condition_variable RequestCV;
164};
165
166/// Provides API to manage ASTs for a collection of C++ files and request
Ilya Biryukov75337e82017-08-22 09:16:46 +0000167/// various language features.
168/// Currently supports async diagnostics, code completion, formatting and goto
169/// definition.
Ilya Biryukov38d79772017-05-16 09:38:59 +0000170class ClangdServer {
171public:
Ilya Biryukov75337e82017-08-22 09:16:46 +0000172 /// Creates a new ClangdServer instance.
173 /// To process parsing requests asynchronously, ClangdServer will spawn \p
174 /// AsyncThreadsCount worker threads. However, if \p AsyncThreadsCount is 0,
175 /// all requests will be processed on the calling thread.
176 ///
177 /// ClangdServer uses \p FSProvider to get an instance of vfs::FileSystem for
178 /// each parsing request. Results of code completion and diagnostics also
179 /// include a tag, that \p FSProvider returns along with the vfs::FileSystem.
180 ///
181 /// The value of \p ResourceDir will be used to search for internal headers
182 /// (overriding defaults and -resource-dir compiler flag). If \p ResourceDir
183 /// is None, ClangdServer will call CompilerInvocation::GetResourcePath() to
184 /// obtain the standard resource directory.
185 ///
186 /// ClangdServer uses \p CDB to obtain compilation arguments for parsing. Note
187 /// that ClangdServer only obtains compilation arguments once for each newly
188 /// added file (i.e., when processing a first call to addDocument) and reuses
189 /// those arguments for subsequent reparses. However, ClangdServer will check
190 /// if compilation arguments changed on calls to forceReparse().
191 ///
192 /// After each parsing request finishes, ClangdServer reports diagnostics to
193 /// \p DiagConsumer. Note that a callback to \p DiagConsumer happens on a
194 /// worker thread. Therefore, instances of \p DiagConsumer must properly
195 /// synchronize access to shared state.
Ilya Biryukove5128f72017-09-20 07:24:15 +0000196 ///
Ilya Biryukove9eb7f02017-11-16 16:25:18 +0000197 /// \p StorePreamblesInMemory defines whether the Preambles generated by
198 /// clangd are stored in-memory or on disk.
Eric Liubfac8f72017-12-19 18:00:37 +0000199 ///
200 /// If \p BuildDynamicSymbolIndex is true, ClangdServer builds a dynamic
201 /// in-memory index for symbols in all opened files and uses the index to
202 /// augment code completion results.
Haojian Wuba28e9a2018-01-10 14:44:34 +0000203 ///
204 /// If \p StaticIdx is set, ClangdServer uses the index for global code
205 /// completion.
Ilya Biryukov103c9512017-06-13 15:59:43 +0000206 ClangdServer(GlobalCompilationDatabase &CDB,
207 DiagnosticsConsumer &DiagConsumer,
Ilya Biryukovdb8b2d72017-08-14 08:45:47 +0000208 FileSystemProvider &FSProvider, unsigned AsyncThreadsCount,
Ilya Biryukov940901e2017-12-13 12:51:22 +0000209 bool StorePreamblesInMemory,
Eric Liubfac8f72017-12-19 18:00:37 +0000210 bool BuildDynamicSymbolIndex = false,
Haojian Wuba28e9a2018-01-10 14:44:34 +0000211 SymbolIndex *StaticIdx = nullptr,
Ilya Biryukova46f7a92017-06-28 10:34:50 +0000212 llvm::Optional<StringRef> ResourceDir = llvm::None);
Ilya Biryukov38d79772017-05-16 09:38:59 +0000213
Marc-Andre Laperle37de9712017-09-27 15:31:17 +0000214 /// Set the root path of the workspace.
215 void setRootPath(PathRef RootPath);
216
Ilya Biryukov38d79772017-05-16 09:38:59 +0000217 /// Add a \p File to the list of tracked C++ files or update the contents if
218 /// \p File is already tracked. Also schedules parsing of the AST for it on a
219 /// separate thread. When the parsing is complete, DiagConsumer passed in
220 /// constructor will receive onDiagnosticsReady callback.
Ilya Biryukov02d58702017-08-01 15:51:38 +0000221 /// \return A future that will become ready when the rebuild (including
222 /// diagnostics) is finished.
Ilya Biryukov940901e2017-12-13 12:51:22 +0000223 std::future<Context> addDocument(Context Ctx, PathRef File,
224 StringRef Contents);
Ilya Biryukov38d79772017-05-16 09:38:59 +0000225 /// Remove \p File from list of tracked files, schedule a request to free
226 /// resources associated with it.
Ilya Biryukov91dbf5b2017-08-14 08:37:32 +0000227 /// \return A future that will become ready when the file is removed and all
228 /// associated resources are freed.
Ilya Biryukov940901e2017-12-13 12:51:22 +0000229 std::future<Context> removeDocument(Context Ctx, PathRef File);
Ilya Biryukov0f62ed22017-05-26 12:26:51 +0000230 /// Force \p File to be reparsed using the latest contents.
Ilya Biryukov91dbf5b2017-08-14 08:37:32 +0000231 /// Will also check if CompileCommand, provided by GlobalCompilationDatabase
232 /// for \p File has changed. If it has, will remove currently stored Preamble
233 /// and AST and rebuild them from scratch.
Ilya Biryukov940901e2017-12-13 12:51:22 +0000234 std::future<Context> forceReparse(Context Ctx, PathRef File);
Ilya Biryukov38d79772017-05-16 09:38:59 +0000235
Ilya Biryukov90bbcfd2017-10-25 09:35:10 +0000236 /// DEPRECATED. Please use a callback-based version, this API is deprecated
237 /// and will soon be removed.
238 ///
Ilya Biryukovdcd21692017-10-05 17:04:13 +0000239 /// Run code completion for \p File at \p Pos.
240 ///
241 /// Request is processed asynchronously. You can use the returned future to
242 /// wait for the results of the async request.
243 ///
244 /// If \p OverridenContents is not None, they will used only for code
245 /// completion, i.e. no diagnostics update will be scheduled and a draft for
246 /// \p File will not be updated. If \p OverridenContents is None, contents of
247 /// the current draft for \p File will be used. If \p UsedFS is non-null, it
248 /// will be overwritten by vfs::FileSystem used for completion.
249 ///
250 /// This method should only be called for currently tracked files. However, it
251 /// is safe to call removeDocument for \p File after this method returns, even
252 /// while returned future is not yet ready.
Ilya Biryukov940901e2017-12-13 12:51:22 +0000253 std::future<std::pair<Context, Tagged<CompletionList>>>
254 codeComplete(Context Ctx, PathRef File, Position Pos,
Ilya Biryukovd3b04e32017-12-05 10:42:57 +0000255 const clangd::CodeCompleteOptions &Opts,
Ilya Biryukoved99e4c2017-07-31 17:09:29 +0000256 llvm::Optional<StringRef> OverridenContents = llvm::None,
257 IntrusiveRefCntPtr<vfs::FileSystem> *UsedFS = nullptr);
Ilya Biryukovdcd21692017-10-05 17:04:13 +0000258
Ilya Biryukov90bbcfd2017-10-25 09:35:10 +0000259 /// A version of `codeComplete` that runs \p Callback on the processing thread
260 /// when codeComplete results become available.
Ilya Biryukov940901e2017-12-13 12:51:22 +0000261 void
262 codeComplete(Context Ctx, PathRef File, Position Pos,
263 const clangd::CodeCompleteOptions &Opts,
264 UniqueFunction<void(Context, Tagged<CompletionList>)> Callback,
265 llvm::Optional<StringRef> OverridenContents = llvm::None,
266 IntrusiveRefCntPtr<vfs::FileSystem> *UsedFS = nullptr);
Ilya Biryukov90bbcfd2017-10-25 09:35:10 +0000267
Ilya Biryukovd9bdfe02017-10-06 11:54:17 +0000268 /// Provide signature help for \p File at \p Pos. If \p OverridenContents is
269 /// not None, they will used only for signature help, i.e. no diagnostics
270 /// update will be scheduled and a draft for \p File will not be updated. If
271 /// \p OverridenContents is None, contents of the current draft for \p File
272 /// will be used. If \p UsedFS is non-null, it will be overwritten by
273 /// vfs::FileSystem used for signature help. This method should only be called
274 /// for currently tracked files.
Benjamin Krameree19f162017-10-26 12:28:13 +0000275 llvm::Expected<Tagged<SignatureHelp>>
Ilya Biryukov940901e2017-12-13 12:51:22 +0000276 signatureHelp(const Context &Ctx, PathRef File, Position Pos,
Ilya Biryukovd9bdfe02017-10-06 11:54:17 +0000277 llvm::Optional<StringRef> OverridenContents = llvm::None,
278 IntrusiveRefCntPtr<vfs::FileSystem> *UsedFS = nullptr);
279
Marc-Andre Laperle2cbf0372017-06-28 16:12:10 +0000280 /// Get definition of symbol at a specified \p Line and \p Column in \p File.
Ilya Biryukov940901e2017-12-13 12:51:22 +0000281 llvm::Expected<Tagged<std::vector<Location>>>
282 findDefinitions(const Context &Ctx, PathRef File, Position Pos);
Ilya Biryukov38d79772017-05-16 09:38:59 +0000283
Marc-Andre Laperle6571b3e2017-09-28 03:14:40 +0000284 /// Helper function that returns a path to the corresponding source file when
285 /// given a header file and vice versa.
286 llvm::Optional<Path> switchSourceHeader(PathRef Path);
287
Ilya Biryukov0e6a51f2017-12-12 12:27:47 +0000288 /// Get document highlights for a given position.
289 llvm::Expected<Tagged<std::vector<DocumentHighlight>>>
Ilya Biryukov940901e2017-12-13 12:51:22 +0000290 findDocumentHighlights(const Context &Ctx, PathRef File, Position Pos);
Ilya Biryukov0e6a51f2017-12-12 12:27:47 +0000291
Raoul Wols212bcf82017-12-12 20:25:06 +0000292 /// Run formatting for \p Rng inside \p File with content \p Code.
293 llvm::Expected<tooling::Replacements> formatRange(StringRef Code,
294 PathRef File, Range Rng);
295
296 /// Run formatting for the whole \p File with content \p Code.
297 llvm::Expected<tooling::Replacements> formatFile(StringRef Code,
298 PathRef File);
299
300 /// Run formatting after a character was typed at \p Pos in \p File with
301 /// content \p Code.
302 llvm::Expected<tooling::Replacements>
303 formatOnType(StringRef Code, PathRef File, Position Pos);
304
Haojian Wu345099c2017-11-09 11:30:04 +0000305 /// Rename all occurrences of the symbol at the \p Pos in \p File to
306 /// \p NewName.
Ilya Biryukov940901e2017-12-13 12:51:22 +0000307 Expected<std::vector<tooling::Replacement>> rename(const Context &Ctx,
308 PathRef File, Position Pos,
Haojian Wu345099c2017-11-09 11:30:04 +0000309 llvm::StringRef NewName);
Ilya Biryukovafb55542017-05-16 14:40:30 +0000310
Ilya Biryukov38d79772017-05-16 09:38:59 +0000311 /// Gets current document contents for \p File. \p File must point to a
312 /// currently tracked file.
Ilya Biryukovafb55542017-05-16 14:40:30 +0000313 /// FIXME(ibiryukov): This function is here to allow offset-to-Position
314 /// conversions in outside code, maybe there's a way to get rid of it.
Ilya Biryukov38d79772017-05-16 09:38:59 +0000315 std::string getDocument(PathRef File);
316
Ilya Biryukovf01af682017-05-23 13:42:59 +0000317 /// Only for testing purposes.
318 /// Waits until all requests to worker thread are finished and dumps AST for
319 /// \p File. \p File must be in the list of added documents.
320 std::string dumpAST(PathRef File);
Marc-Andre Laperlebf114242017-10-02 18:00:37 +0000321 /// Called when an event occurs for a watched file in the workspace.
322 void onFileEvent(const DidChangeWatchedFilesParams &Params);
Ilya Biryukovf01af682017-05-23 13:42:59 +0000323
Ilya Biryukov38d79772017-05-16 09:38:59 +0000324private:
Raoul Wols212bcf82017-12-12 20:25:06 +0000325 /// FIXME: This stats several files to find a .clang-format file. I/O can be
326 /// slow. Think of a way to cache this.
327 llvm::Expected<tooling::Replacements>
328 formatCode(llvm::StringRef Code, PathRef File,
329 ArrayRef<tooling::Range> Ranges);
330
Ilya Biryukov940901e2017-12-13 12:51:22 +0000331 std::future<Context>
332 scheduleReparseAndDiags(Context Ctx, PathRef File, VersionedDraft Contents,
Ilya Biryukovc5ad35f2017-08-14 08:17:24 +0000333 std::shared_ptr<CppFile> Resources,
334 Tagged<IntrusiveRefCntPtr<vfs::FileSystem>> TaggedFS);
335
Ilya Biryukov940901e2017-12-13 12:51:22 +0000336 std::future<Context>
337 scheduleCancelRebuild(Context Ctx, std::shared_ptr<CppFile> Resources);
Ilya Biryukovc5ad35f2017-08-14 08:17:24 +0000338
Ilya Biryukov103c9512017-06-13 15:59:43 +0000339 GlobalCompilationDatabase &CDB;
340 DiagnosticsConsumer &DiagConsumer;
341 FileSystemProvider &FSProvider;
Ilya Biryukov38d79772017-05-16 09:38:59 +0000342 DraftStore DraftMgr;
Sam McCall0faecf02018-01-15 12:33:00 +0000343 // The index used to look up symbols. This could be:
344 // - null (all index functionality is optional)
345 // - the dynamic index owned by ClangdServer (FileIdx)
346 // - the static index passed to the constructor
347 // - a merged view of a static and dynamic index (MergedIndex)
348 SymbolIndex *Index;
349 // If present, an up-to-date of symbols in open files. Read via Index.
Eric Liubfac8f72017-12-19 18:00:37 +0000350 std::unique_ptr<FileIndex> FileIdx;
Sam McCall0faecf02018-01-15 12:33:00 +0000351 // If present, a merged view of FileIdx and an external index. Read via Index.
352 std::unique_ptr<SymbolIndex> MergedIndex;
Ilya Biryukov02d58702017-08-01 15:51:38 +0000353 CppFileCollection Units;
Ilya Biryukova46f7a92017-06-28 10:34:50 +0000354 std::string ResourceDir;
Marc-Andre Laperle37de9712017-09-27 15:31:17 +0000355 // If set, this represents the workspace path.
356 llvm::Optional<std::string> RootPath;
Ilya Biryukov38d79772017-05-16 09:38:59 +0000357 std::shared_ptr<PCHContainerOperations> PCHs;
Ilya Biryukove9eb7f02017-11-16 16:25:18 +0000358 bool StorePreamblesInMemory;
Ilya Biryukov47f22022017-09-20 12:58:55 +0000359 /// Used to serialize diagnostic callbacks.
360 /// FIXME(ibiryukov): get rid of an extra map and put all version counters
361 /// into CppFile.
362 std::mutex DiagnosticsMutex;
363 /// Maps from a filename to the latest version of reported diagnostics.
364 llvm::StringMap<DocVersion> ReportedDiagnosticVersions;
Ilya Biryukovf4e95d72017-09-20 19:32:06 +0000365 // WorkScheduler has to be the last member, because its destructor has to be
366 // called before all other members to stop the worker thread that references
367 // ClangdServer
368 ClangdScheduler WorkScheduler;
Ilya Biryukov38d79772017-05-16 09:38:59 +0000369};
370
371} // namespace clangd
372} // namespace clang
373
374#endif