summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/ClangdServer.h
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd/ClangdServer.h')
-rw-r--r--clang-tools-extra/clangd/ClangdServer.h70
1 files changed, 35 insertions, 35 deletions
diff --git a/clang-tools-extra/clangd/ClangdServer.h b/clang-tools-extra/clangd/ClangdServer.h
index a443d66229a..5e10c243ed1 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -101,19 +101,36 @@ public:
/// definition.
class ClangdServer {
public:
+ struct Options {
+ /// To process requests asynchronously, ClangdServer spawns worker threads.
+ /// If 0, all requests are processed on the calling thread.
+ unsigned AsyncThreadsCount = getDefaultAsyncThreadsCount();
+
+ /// Cached preambles are potentially large. If false, store them on disk.
+ bool StorePreamblesInMemory = true;
+
+ /// If true, ClangdServer builds a dynamic in-memory index for symbols in
+ /// opened files and uses the index to augment code completion results.
+ bool BuildDynamicSymbolIndex = false;
+
+ /// If set, use this index to augment code completion results.
+ SymbolIndex *StaticIndex = nullptr;
+
+ /// The resource directory is used to find internal headers, overriding
+ /// defaults and -resource-dir compiler flag).
+ /// If None, ClangdServer calls CompilerInvocation::GetResourcePath() to
+ /// obtain the standard resource directory.
+ llvm::Optional<StringRef> ResourceDir = llvm::None;
+
+ /// Time to wait after a new file version before computing diagnostics.
+ std::chrono::steady_clock::duration UpdateDebounce =
+ std::chrono::milliseconds(500);
+ };
+ // Sensible default options for use in tests.
+ // Features like indexing must be enabled if desired.
+ static Options optsForTest();
+
/// Creates a new ClangdServer instance.
- /// To process parsing requests asynchronously, ClangdServer will spawn \p
- /// AsyncThreadsCount worker threads. However, if \p AsyncThreadsCount is 0,
- /// all requests will be processed on the calling thread.
- ///
- /// ClangdServer uses \p FSProvider to get an instance of vfs::FileSystem for
- /// each parsing request. Results of code completion and diagnostics also
- /// include a tag, that \p FSProvider returns along with the vfs::FileSystem.
- ///
- /// The value of \p ResourceDir will be used to search for internal headers
- /// (overriding defaults and -resource-dir compiler flag). If \p ResourceDir
- /// is None, ClangdServer will call CompilerInvocation::GetResourcePath() to
- /// obtain the standard resource directory.
///
/// ClangdServer uses \p CDB to obtain compilation arguments for parsing. Note
/// that ClangdServer only obtains compilation arguments once for each newly
@@ -121,33 +138,16 @@ public:
/// those arguments for subsequent reparses. However, ClangdServer will check
/// if compilation arguments changed on calls to forceReparse().
///
+ /// FSProvider provides a vfs::FileSystem for each parsing request. Results of
+ /// code completion and diagnostics also include a tag, that \p FSProvider
+ /// returns along with the vfs::FileSystem.
+ ///
/// After each parsing request finishes, ClangdServer reports diagnostics to
/// \p DiagConsumer. Note that a callback to \p DiagConsumer happens on a
/// worker thread. Therefore, instances of \p DiagConsumer must properly
/// synchronize access to shared state.
- /// UpdateDebounce determines how long to wait after a new version of the file
- /// before starting to compute diagnostics.
- ///
- /// \p StorePreamblesInMemory defines whether the Preambles generated by
- /// clangd are stored in-memory or on disk.
- ///
- /// If \p BuildDynamicSymbolIndex is true, ClangdServer builds a dynamic
- /// in-memory index for symbols in all opened files and uses the index to
- /// augment code completion results.
- ///
- /// If \p StaticIdx is set, ClangdServer uses the index for global code
- /// completion.
- /// FIXME(sammccall): pull out an options struct.
- ClangdServer(GlobalCompilationDatabase &CDB,
- DiagnosticsConsumer &DiagConsumer,
- FileSystemProvider &FSProvider, unsigned AsyncThreadsCount,
- bool StorePreamblesInMemory,
- bool BuildDynamicSymbolIndex = false,
- SymbolIndex *StaticIdx = nullptr,
- llvm::Optional<StringRef> ResourceDir = llvm::None,
- /* Tiny default debounce, so tests hit the debounce logic */
- std::chrono::steady_clock::duration UpdateDebounce =
- std::chrono::milliseconds(20));
+ ClangdServer(GlobalCompilationDatabase &CDB, FileSystemProvider &FSProvider,
+ DiagnosticsConsumer &DiagConsumer, const Options &Opts);
/// Set the root path of the workspace.
void setRootPath(PathRef RootPath);
OpenPOWER on IntegriCloud