Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 1 | //===--- 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 Liu | b99d5e8 | 2017-12-14 21:22:03 +0000 | [diff] [blame] | 13 | #include "ClangdUnit.h" |
Eric Liu | b99d5e8 | 2017-12-14 21:22:03 +0000 | [diff] [blame] | 14 | #include "CodeComplete.h" |
Ilya Biryukov | 929697b | 2018-01-25 14:19:21 +0000 | [diff] [blame] | 15 | #include "CompileArgsCache.h" |
Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 16 | #include "DraftStore.h" |
Eric Liu | b99d5e8 | 2017-12-14 21:22:03 +0000 | [diff] [blame] | 17 | #include "Function.h" |
Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 18 | #include "GlobalCompilationDatabase.h" |
Eric Liu | b99d5e8 | 2017-12-14 21:22:03 +0000 | [diff] [blame] | 19 | #include "Protocol.h" |
Ilya Biryukov | 75f1dd9 | 2018-01-31 08:51:16 +0000 | [diff] [blame] | 20 | #include "TUScheduler.h" |
Eric Liu | bfac8f7 | 2017-12-19 18:00:37 +0000 | [diff] [blame] | 21 | #include "index/FileIndex.h" |
Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 22 | #include "clang/Tooling/CompilationDatabase.h" |
| 23 | #include "clang/Tooling/Core/Replacement.h" |
| 24 | #include "llvm/ADT/IntrusiveRefCntPtr.h" |
| 25 | #include "llvm/ADT/Optional.h" |
| 26 | #include "llvm/ADT/StringRef.h" |
Ilya Biryukov | f01af68 | 2017-05-23 13:42:59 +0000 | [diff] [blame] | 27 | #include <functional> |
Ilya Biryukov | 44ba9e0 | 2018-02-09 10:17:23 +0000 | [diff] [blame] | 28 | #include <future> |
Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 29 | #include <string> |
Ilya Biryukov | 2260299 | 2017-05-30 15:11:02 +0000 | [diff] [blame] | 30 | #include <type_traits> |
Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 31 | #include <utility> |
| 32 | |
| 33 | namespace clang { |
| 34 | class PCHContainerOperations; |
| 35 | |
| 36 | namespace clangd { |
| 37 | |
| 38 | class DiagnosticsConsumer { |
| 39 | public: |
| 40 | virtual ~DiagnosticsConsumer() = default; |
| 41 | |
| 42 | /// Called by ClangdServer when \p Diagnostics for \p File are ready. |
Ilya Biryukov | 71028b8 | 2018-03-12 15:28:22 +0000 | [diff] [blame] | 43 | virtual void onDiagnosticsReady(PathRef File, |
Sam McCall | a7bb0cc | 2018-03-12 23:22:35 +0000 | [diff] [blame] | 44 | std::vector<Diag> Diagnostics) = 0; |
Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
Ilya Biryukov | 0f62ed2 | 2017-05-26 12:26:51 +0000 | [diff] [blame] | 47 | class FileSystemProvider { |
| 48 | public: |
| 49 | virtual ~FileSystemProvider() = default; |
Ilya Biryukov | af0c04b | 2017-06-14 09:46:44 +0000 | [diff] [blame] | 50 | /// Called by ClangdServer to obtain a vfs::FileSystem to be used for parsing. |
Sam McCall | a7bb0cc | 2018-03-12 23:22:35 +0000 | [diff] [blame] | 51 | /// Context::current() will be the context passed to the clang entrypoint, |
| 52 | /// such as addDocument(), and will also be propagated to result callbacks. |
| 53 | /// Embedders may use this to isolate filesystem accesses. |
| 54 | virtual IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() = 0; |
Ilya Biryukov | 0f62ed2 | 2017-05-26 12:26:51 +0000 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | class RealFileSystemProvider : public FileSystemProvider { |
| 58 | public: |
Sam McCall | a7bb0cc | 2018-03-12 23:22:35 +0000 | [diff] [blame] | 59 | /// Returns getRealFileSystem(). |
| 60 | IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() override; |
Ilya Biryukov | 0f62ed2 | 2017-05-26 12:26:51 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 63 | /// Provides API to manage ASTs for a collection of C++ files and request |
Ilya Biryukov | 75337e8 | 2017-08-22 09:16:46 +0000 | [diff] [blame] | 64 | /// various language features. |
| 65 | /// Currently supports async diagnostics, code completion, formatting and goto |
| 66 | /// definition. |
Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 67 | class ClangdServer { |
| 68 | public: |
Sam McCall | 7363a2f | 2018-03-05 17:28:54 +0000 | [diff] [blame] | 69 | struct Options { |
| 70 | /// To process requests asynchronously, ClangdServer spawns worker threads. |
| 71 | /// If 0, all requests are processed on the calling thread. |
| 72 | unsigned AsyncThreadsCount = getDefaultAsyncThreadsCount(); |
| 73 | |
| 74 | /// Cached preambles are potentially large. If false, store them on disk. |
| 75 | bool StorePreamblesInMemory = true; |
| 76 | |
| 77 | /// If true, ClangdServer builds a dynamic in-memory index for symbols in |
| 78 | /// opened files and uses the index to augment code completion results. |
| 79 | bool BuildDynamicSymbolIndex = false; |
| 80 | |
| 81 | /// If set, use this index to augment code completion results. |
| 82 | SymbolIndex *StaticIndex = nullptr; |
| 83 | |
| 84 | /// The resource directory is used to find internal headers, overriding |
| 85 | /// defaults and -resource-dir compiler flag). |
| 86 | /// If None, ClangdServer calls CompilerInvocation::GetResourcePath() to |
| 87 | /// obtain the standard resource directory. |
| 88 | llvm::Optional<StringRef> ResourceDir = llvm::None; |
| 89 | |
| 90 | /// Time to wait after a new file version before computing diagnostics. |
| 91 | std::chrono::steady_clock::duration UpdateDebounce = |
| 92 | std::chrono::milliseconds(500); |
| 93 | }; |
| 94 | // Sensible default options for use in tests. |
| 95 | // Features like indexing must be enabled if desired. |
| 96 | static Options optsForTest(); |
| 97 | |
Ilya Biryukov | 75337e8 | 2017-08-22 09:16:46 +0000 | [diff] [blame] | 98 | /// Creates a new ClangdServer instance. |
Ilya Biryukov | 75337e8 | 2017-08-22 09:16:46 +0000 | [diff] [blame] | 99 | /// |
| 100 | /// ClangdServer uses \p CDB to obtain compilation arguments for parsing. Note |
| 101 | /// that ClangdServer only obtains compilation arguments once for each newly |
| 102 | /// added file (i.e., when processing a first call to addDocument) and reuses |
| 103 | /// those arguments for subsequent reparses. However, ClangdServer will check |
| 104 | /// if compilation arguments changed on calls to forceReparse(). |
| 105 | /// |
| 106 | /// After each parsing request finishes, ClangdServer reports diagnostics to |
| 107 | /// \p DiagConsumer. Note that a callback to \p DiagConsumer happens on a |
| 108 | /// worker thread. Therefore, instances of \p DiagConsumer must properly |
| 109 | /// synchronize access to shared state. |
Sam McCall | 7363a2f | 2018-03-05 17:28:54 +0000 | [diff] [blame] | 110 | ClangdServer(GlobalCompilationDatabase &CDB, FileSystemProvider &FSProvider, |
| 111 | DiagnosticsConsumer &DiagConsumer, const Options &Opts); |
Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 112 | |
Marc-Andre Laperle | 37de971 | 2017-09-27 15:31:17 +0000 | [diff] [blame] | 113 | /// Set the root path of the workspace. |
| 114 | void setRootPath(PathRef RootPath); |
| 115 | |
Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 116 | /// Add a \p File to the list of tracked C++ files or update the contents if |
| 117 | /// \p File is already tracked. Also schedules parsing of the AST for it on a |
| 118 | /// separate thread. When the parsing is complete, DiagConsumer passed in |
| 119 | /// constructor will receive onDiagnosticsReady callback. |
Ilya Biryukov | bec5df2 | 2018-03-14 17:08:41 +0000 | [diff] [blame] | 120 | /// When \p SkipCache is true, compile commands will always be requested from |
| 121 | /// compilation database even if they were cached in previous invocations. |
Sam McCall | 568e17f | 2018-02-22 13:11:12 +0000 | [diff] [blame] | 122 | void addDocument(PathRef File, StringRef Contents, |
Ilya Biryukov | bec5df2 | 2018-03-14 17:08:41 +0000 | [diff] [blame] | 123 | WantDiagnostics WD = WantDiagnostics::Auto, |
| 124 | bool SkipCache = false); |
Sam McCall | d1a7a37 | 2018-01-31 13:40:48 +0000 | [diff] [blame] | 125 | |
Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 126 | /// Remove \p File from list of tracked files, schedule a request to free |
| 127 | /// resources associated with it. |
Ilya Biryukov | 7e5ee26 | 2018-02-08 07:37:35 +0000 | [diff] [blame] | 128 | void removeDocument(PathRef File); |
Sam McCall | d1a7a37 | 2018-01-31 13:40:48 +0000 | [diff] [blame] | 129 | |
Simon Marchi | 5178f92 | 2018-02-22 14:00:39 +0000 | [diff] [blame] | 130 | /// Calls forceReparse() on all currently opened files. |
| 131 | /// As a result, this method may be very expensive. |
| 132 | /// This method is normally called when the compilation database is changed. |
Ilya Biryukov | bec5df2 | 2018-03-14 17:08:41 +0000 | [diff] [blame] | 133 | /// FIXME: this method must be moved to ClangdLSPServer along with DraftMgr. |
Simon Marchi | 5178f92 | 2018-02-22 14:00:39 +0000 | [diff] [blame] | 134 | void reparseOpenedFiles(); |
| 135 | |
Ilya Biryukov | dcd2169 | 2017-10-05 17:04:13 +0000 | [diff] [blame] | 136 | /// Run code completion for \p File at \p Pos. |
Sam McCall | d1a7a37 | 2018-01-31 13:40:48 +0000 | [diff] [blame] | 137 | /// Request is processed asynchronously. |
Ilya Biryukov | dcd2169 | 2017-10-05 17:04:13 +0000 | [diff] [blame] | 138 | /// |
Sam McCall | db3ea4c | 2018-02-27 17:15:50 +0000 | [diff] [blame] | 139 | /// The current draft for \p File will be used. If \p UsedFS is non-null, it |
Ilya Biryukov | dcd2169 | 2017-10-05 17:04:13 +0000 | [diff] [blame] | 140 | /// will be overwritten by vfs::FileSystem used for completion. |
| 141 | /// |
| 142 | /// This method should only be called for currently tracked files. However, it |
| 143 | /// is safe to call removeDocument for \p File after this method returns, even |
| 144 | /// while returned future is not yet ready. |
Ilya Biryukov | 90bbcfd | 2017-10-25 09:35:10 +0000 | [diff] [blame] | 145 | /// A version of `codeComplete` that runs \p Callback on the processing thread |
| 146 | /// when codeComplete results become available. |
Sam McCall | d1a7a37 | 2018-01-31 13:40:48 +0000 | [diff] [blame] | 147 | void codeComplete(PathRef File, Position Pos, |
| 148 | const clangd::CodeCompleteOptions &Opts, |
Sam McCall | a7bb0cc | 2018-03-12 23:22:35 +0000 | [diff] [blame] | 149 | Callback<CompletionList> CB); |
Sam McCall | d1a7a37 | 2018-01-31 13:40:48 +0000 | [diff] [blame] | 150 | |
Ilya Biryukov | d9bdfe0 | 2017-10-06 11:54:17 +0000 | [diff] [blame] | 151 | /// Provide signature help for \p File at \p Pos. If \p OverridenContents is |
| 152 | /// not None, they will used only for signature help, i.e. no diagnostics |
| 153 | /// update will be scheduled and a draft for \p File will not be updated. If |
Sam McCall | db3ea4c | 2018-02-27 17:15:50 +0000 | [diff] [blame] | 154 | /// If \p UsedFS is non-null, it will be overwritten by vfs::FileSystem used |
| 155 | /// for signature help. This method should only be called for tracked files. |
Sam McCall | a7bb0cc | 2018-03-12 23:22:35 +0000 | [diff] [blame] | 156 | void signatureHelp(PathRef File, Position Pos, Callback<SignatureHelp> CB); |
Ilya Biryukov | d9bdfe0 | 2017-10-06 11:54:17 +0000 | [diff] [blame] | 157 | |
Marc-Andre Laperle | 2cbf037 | 2017-06-28 16:12:10 +0000 | [diff] [blame] | 158 | /// Get definition of symbol at a specified \p Line and \p Column in \p File. |
Sam McCall | a7bb0cc | 2018-03-12 23:22:35 +0000 | [diff] [blame] | 159 | void findDefinitions(PathRef File, Position Pos, |
| 160 | Callback<std::vector<Location>> CB); |
Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 161 | |
Marc-Andre Laperle | 6571b3e | 2017-09-28 03:14:40 +0000 | [diff] [blame] | 162 | /// Helper function that returns a path to the corresponding source file when |
| 163 | /// given a header file and vice versa. |
| 164 | llvm::Optional<Path> switchSourceHeader(PathRef Path); |
| 165 | |
Ilya Biryukov | 0e6a51f | 2017-12-12 12:27:47 +0000 | [diff] [blame] | 166 | /// Get document highlights for a given position. |
Sam McCall | a7bb0cc | 2018-03-12 23:22:35 +0000 | [diff] [blame] | 167 | void findDocumentHighlights(PathRef File, Position Pos, |
| 168 | Callback<std::vector<DocumentHighlight>> CB); |
Ilya Biryukov | 0e6a51f | 2017-12-12 12:27:47 +0000 | [diff] [blame] | 169 | |
Marc-Andre Laperle | 3e618ed | 2018-02-16 21:38:15 +0000 | [diff] [blame] | 170 | /// Get code hover for a given position. |
Sam McCall | a7bb0cc | 2018-03-12 23:22:35 +0000 | [diff] [blame] | 171 | void findHover(PathRef File, Position Pos, Callback<Hover> CB); |
Marc-Andre Laperle | 3e618ed | 2018-02-16 21:38:15 +0000 | [diff] [blame] | 172 | |
Raoul Wols | 212bcf8 | 2017-12-12 20:25:06 +0000 | [diff] [blame] | 173 | /// Run formatting for \p Rng inside \p File with content \p Code. |
| 174 | llvm::Expected<tooling::Replacements> formatRange(StringRef Code, |
| 175 | PathRef File, Range Rng); |
| 176 | |
| 177 | /// Run formatting for the whole \p File with content \p Code. |
| 178 | llvm::Expected<tooling::Replacements> formatFile(StringRef Code, |
| 179 | PathRef File); |
| 180 | |
| 181 | /// Run formatting after a character was typed at \p Pos in \p File with |
| 182 | /// content \p Code. |
| 183 | llvm::Expected<tooling::Replacements> |
| 184 | formatOnType(StringRef Code, PathRef File, Position Pos); |
| 185 | |
Haojian Wu | 345099c | 2017-11-09 11:30:04 +0000 | [diff] [blame] | 186 | /// Rename all occurrences of the symbol at the \p Pos in \p File to |
| 187 | /// \p NewName. |
Ilya Biryukov | 2c5e8e8 | 2018-02-15 13:15:47 +0000 | [diff] [blame] | 188 | void rename(PathRef File, Position Pos, llvm::StringRef NewName, |
Sam McCall | a7bb0cc | 2018-03-12 23:22:35 +0000 | [diff] [blame] | 189 | Callback<std::vector<tooling::Replacement>> CB); |
Ilya Biryukov | afb5554 | 2017-05-16 14:40:30 +0000 | [diff] [blame] | 190 | |
Eric Liu | 6c8e858 | 2018-02-26 08:32:13 +0000 | [diff] [blame] | 191 | /// Inserts a new #include into \p File, if it's not present in \p Code. |
| 192 | /// |
| 193 | /// \p DeclaringHeader The original header corresponding to this insertion |
| 194 | /// e.g. the header that declared a symbol. This can be either a URI or a |
| 195 | /// literal string quoted with <> or "" that can be #included directly. |
| 196 | /// \p InsertedHeader The preferred header to be inserted. This may be |
| 197 | /// different from \p DeclaringHeader as a header file can have a different |
| 198 | /// canonical include. This can be either a URI or a literal string quoted |
| 199 | /// with <> or "" that can be #included directly. |
| 200 | /// |
| 201 | /// Both OriginalHeader and InsertedHeader will be considered to determine |
| 202 | /// whether an include needs to be added. |
Eric Liu | c5105f9 | 2018-02-16 14:15:55 +0000 | [diff] [blame] | 203 | Expected<tooling::Replacements> insertInclude(PathRef File, StringRef Code, |
Eric Liu | 6c8e858 | 2018-02-26 08:32:13 +0000 | [diff] [blame] | 204 | StringRef DeclaringHeader, |
| 205 | StringRef InsertedHeader); |
Eric Liu | c5105f9 | 2018-02-16 14:15:55 +0000 | [diff] [blame] | 206 | |
Ilya Biryukov | 261c72e | 2018-01-17 12:30:24 +0000 | [diff] [blame] | 207 | /// Gets current document contents for \p File. Returns None if \p File is not |
| 208 | /// currently tracked. |
Ilya Biryukov | afb5554 | 2017-05-16 14:40:30 +0000 | [diff] [blame] | 209 | /// FIXME(ibiryukov): This function is here to allow offset-to-Position |
| 210 | /// conversions in outside code, maybe there's a way to get rid of it. |
Ilya Biryukov | 261c72e | 2018-01-17 12:30:24 +0000 | [diff] [blame] | 211 | llvm::Optional<std::string> getDocument(PathRef File); |
Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 212 | |
Ilya Biryukov | f01af68 | 2017-05-23 13:42:59 +0000 | [diff] [blame] | 213 | /// Only for testing purposes. |
| 214 | /// Waits until all requests to worker thread are finished and dumps AST for |
| 215 | /// \p File. \p File must be in the list of added documents. |
Ilya Biryukov | 2c5e8e8 | 2018-02-15 13:15:47 +0000 | [diff] [blame] | 216 | void dumpAST(PathRef File, UniqueFunction<void(std::string)> Callback); |
Marc-Andre Laperle | bf11424 | 2017-10-02 18:00:37 +0000 | [diff] [blame] | 217 | /// Called when an event occurs for a watched file in the workspace. |
| 218 | void onFileEvent(const DidChangeWatchedFilesParams &Params); |
Ilya Biryukov | f01af68 | 2017-05-23 13:42:59 +0000 | [diff] [blame] | 219 | |
Ilya Biryukov | df84234 | 2018-01-25 14:32:21 +0000 | [diff] [blame] | 220 | /// Returns estimated memory usage for each of the currently open files. |
| 221 | /// The order of results is unspecified. |
| 222 | /// Overall memory usage of clangd may be significantly more than reported |
| 223 | /// here, as this metric does not account (at least) for: |
| 224 | /// - memory occupied by static and dynamic index, |
| 225 | /// - memory required for in-flight requests, |
| 226 | /// FIXME: those metrics might be useful too, we should add them. |
| 227 | std::vector<std::pair<Path, std::size_t>> getUsedBytesPerFile() const; |
| 228 | |
Sam McCall | 0bb24cd | 2018-02-13 08:59:23 +0000 | [diff] [blame] | 229 | // Blocks the main thread until the server is idle. Only for use in tests. |
| 230 | // Returns false if the timeout expires. |
| 231 | LLVM_NODISCARD bool |
| 232 | blockUntilIdleForTest(llvm::Optional<double> TimeoutSeconds = 10); |
| 233 | |
Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 234 | private: |
Raoul Wols | 212bcf8 | 2017-12-12 20:25:06 +0000 | [diff] [blame] | 235 | /// FIXME: This stats several files to find a .clang-format file. I/O can be |
| 236 | /// slow. Think of a way to cache this. |
| 237 | llvm::Expected<tooling::Replacements> |
| 238 | formatCode(llvm::StringRef Code, PathRef File, |
| 239 | ArrayRef<tooling::Range> Ranges); |
| 240 | |
Ilya Biryukov | bec5df2 | 2018-03-14 17:08:41 +0000 | [diff] [blame] | 241 | void consumeDiagnostics(PathRef File, DocVersion Version, |
| 242 | std::vector<Diag> Diags); |
Ilya Biryukov | c5ad35f | 2017-08-14 08:17:24 +0000 | [diff] [blame] | 243 | |
Ilya Biryukov | 929697b | 2018-01-25 14:19:21 +0000 | [diff] [blame] | 244 | CompileArgsCache CompileArgs; |
Ilya Biryukov | 103c951 | 2017-06-13 15:59:43 +0000 | [diff] [blame] | 245 | DiagnosticsConsumer &DiagConsumer; |
| 246 | FileSystemProvider &FSProvider; |
Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 247 | DraftStore DraftMgr; |
Sam McCall | 0faecf0 | 2018-01-15 12:33:00 +0000 | [diff] [blame] | 248 | // The index used to look up symbols. This could be: |
| 249 | // - null (all index functionality is optional) |
| 250 | // - the dynamic index owned by ClangdServer (FileIdx) |
| 251 | // - the static index passed to the constructor |
| 252 | // - a merged view of a static and dynamic index (MergedIndex) |
| 253 | SymbolIndex *Index; |
| 254 | // If present, an up-to-date of symbols in open files. Read via Index. |
Eric Liu | bfac8f7 | 2017-12-19 18:00:37 +0000 | [diff] [blame] | 255 | std::unique_ptr<FileIndex> FileIdx; |
Sam McCall | 0faecf0 | 2018-01-15 12:33:00 +0000 | [diff] [blame] | 256 | // If present, a merged view of FileIdx and an external index. Read via Index. |
| 257 | std::unique_ptr<SymbolIndex> MergedIndex; |
Marc-Andre Laperle | 37de971 | 2017-09-27 15:31:17 +0000 | [diff] [blame] | 258 | // If set, this represents the workspace path. |
| 259 | llvm::Optional<std::string> RootPath; |
Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 260 | std::shared_ptr<PCHContainerOperations> PCHs; |
Ilya Biryukov | 47f2202 | 2017-09-20 12:58:55 +0000 | [diff] [blame] | 261 | /// Used to serialize diagnostic callbacks. |
| 262 | /// FIXME(ibiryukov): get rid of an extra map and put all version counters |
| 263 | /// into CppFile. |
| 264 | std::mutex DiagnosticsMutex; |
| 265 | /// Maps from a filename to the latest version of reported diagnostics. |
| 266 | llvm::StringMap<DocVersion> ReportedDiagnosticVersions; |
Ilya Biryukov | f4e95d7 | 2017-09-20 19:32:06 +0000 | [diff] [blame] | 267 | // WorkScheduler has to be the last member, because its destructor has to be |
| 268 | // called before all other members to stop the worker thread that references |
Ilya Biryukov | 75f1dd9 | 2018-01-31 08:51:16 +0000 | [diff] [blame] | 269 | // ClangdServer. |
| 270 | TUScheduler WorkScheduler; |
Ilya Biryukov | 38d7977 | 2017-05-16 09:38:59 +0000 | [diff] [blame] | 271 | }; |
| 272 | |
| 273 | } // namespace clangd |
| 274 | } // namespace clang |
| 275 | |
| 276 | #endif |