9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TUSCHEDULER_H 10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TUSCHEDULER_H 17 #include "llvm/ADT/Optional.h" 18 #include "llvm/ADT/StringMap.h" 19 #include "llvm/ADT/StringRef.h" 56 unsigned MaxRetainedASTs = 3;
80 bool BuildFailed =
false;
82 bool ReuseAST =
false;
99 std::shared_ptr<clang::Preprocessor> PP,
130 bool StorePreamblesInMemory,
131 std::unique_ptr<ParsingCallbacks> ASTCallbacks,
132 std::chrono::steady_clock::duration UpdateDebounce,
138 std::vector<std::pair<Path, std::size_t>> getUsedBytesPerFile()
const;
143 std::vector<Path> getFilesWithCachedAST()
const;
161 llvm::StringRef getContents(
PathRef File)
const;
164 void run(llvm::StringRef
Name, llvm::unique_function<
void()>
Action);
174 void runWithAST(llvm::StringRef Name,
PathRef File,
203 void runWithPreamble(llvm::StringRef Name,
PathRef File,
225 static llvm::Optional<llvm::StringRef> getFileBeingProcessedInContext();
229 const bool StorePreamblesInMemory;
230 std::unique_ptr<ParsingCallbacks> Callbacks;
232 llvm::StringMap<std::unique_ptr<FileData>>
Files;
233 std::unique_ptr<ASTCache> IdleASTs;
236 llvm::Optional<AsyncTaskRunner> PreambleTasks;
237 llvm::Optional<AsyncTaskRunner> WorkerThreads;
238 std::chrono::steady_clock::duration UpdateDebounce;
243 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.
Besides accepting stale preamble, this also allow preamble to be absent (not ready or failed to build...
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.
Provides compilation arguments used for parsing C and C++ files.
Maps a definition location onto an #include file, based on a set of filename rules.
Context clone() const
Clone this context object.
llvm::unique_function< void()> Action
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 ...
virtual void onPreambleAST(PathRef Path, ASTContext &Ctx, std::shared_ptr< clang::Preprocessor > PP, const CanonicalIncludes &)
Called on the AST that was built for emitting the preamble.
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.
llvm::StringMap< std::string > Files
The preamble is generated from the current version of the file.