10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TUSCHEDULER_H 11 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TUSCHEDULER_H 16 #include "llvm/ADT/StringMap.h" 52 unsigned MaxRetainedASTs = 3;
76 bool BuildFailed =
false;
78 bool ReuseAST =
false;
95 std::shared_ptr<clang::Preprocessor> PP) {}
124 TUScheduler(
unsigned AsyncThreadsCount,
bool StorePreamblesInMemory,
125 std::unique_ptr<ParsingCallbacks> ASTCallbacks,
126 std::chrono::steady_clock::duration UpdateDebounce,
132 std::vector<std::pair<Path, std::size_t>> getUsedBytesPerFile()
const;
137 std::vector<Path> getFilesWithCachedAST()
const;
152 void run(llvm::StringRef
Name, llvm::unique_function<
void()>
Action);
162 void runWithAST(llvm::StringRef Name,
PathRef File,
187 void runWithPreamble(llvm::StringRef Name,
PathRef File,
209 static llvm::Optional<llvm::StringRef> getFileBeingProcessedInContext();
212 const bool StorePreamblesInMemory;
213 const std::shared_ptr<PCHContainerOperations> PCHOps;
214 std::unique_ptr<ParsingCallbacks> Callbacks;
216 llvm::StringMap<std::unique_ptr<FileData>> Files;
217 std::unique_ptr<ASTCache> IdleASTs;
220 llvm::Optional<AsyncTaskRunner> PreambleTasks;
221 llvm::Optional<AsyncTaskRunner> WorkerThreads;
222 std::chrono::steady_clock::duration UpdateDebounce;
227 template <
typename T>
PreambleConsistency
Controls whether preamble reads wait for the preamble to be up-to-date.
WantDiagnostics
Determines whether diagnostics should be generated for a file snapshot.
The preamble may be generated from an older version of the file.
Diagnostics must be generated for this snapshot.
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>.
virtual void onMainAST(PathRef Path, ParsedAST &AST)
Called on the AST built for the file itself.
Limits the number of threads that can acquire the lock at the same time.
virtual void onFileUpdated(PathRef File, const TUStatus &Status)
Called whenever the TU status is updated.
Configuration of the AST retention policy.
std::future< T > runAsync(llvm::unique_function< T()> Action)
Runs Action asynchronously with a new std::thread.
Context clone() const
Clone this context object.
llvm::unique_function< void()> Action
virtual void onPreambleAST(PathRef Path, ASTContext &Ctx, std::shared_ptr< clang::Preprocessor > PP)
Called on the AST that was built for emitting the preamble.
std::string Path
A typedef to represent a file path.
static const Context & current()
Returns the context for the current thread, creating it if needed.
static constexpr llvm::StringLiteral Name
virtual void onDiagnostics(PathRef File, std::vector< Diag > Diags)
Called whenever the diagnostics for File are produced.
A context is an immutable container for per-request data that must be propagated through layers that ...
Stores and provides access to parsed AST.
unsigned getDefaultAsyncThreadsCount()
Returns a number of a default async threads to use for TUScheduler.
WithContext replaces Context::current() with a provided scope.
TUAction(State S, llvm::StringRef Name)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::string Name
The name of the action currently running, e.g.
A point in time we can wait for.
Clangd extension: indicates the current state of the file in clangd, sent from server via the textDoc...
Handles running tasks for ClangdServer and managing the resources (e.g., preambles and ASTs) for open...
An LRU cache of idle ASTs.
Diagnostics must not be generated for this snapshot.
The preamble is generated from the current version of the file.