9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TUSCHEDULER_H 10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TUSCHEDULER_H 19 #include "llvm/ADT/Optional.h" 20 #include "llvm/ADT/STLExtras.h" 21 #include "llvm/ADT/StringMap.h" 22 #include "llvm/ADT/StringRef.h" 60 unsigned MaxRetainedASTs = 3;
84 bool BuildFailed =
false;
86 bool ReuseAST =
false;
103 std::shared_ptr<clang::Preprocessor>
PP,
108 using PublishFn = llvm::function_ref<void(llvm::function_ref<void()>)>;
150 bool StorePreamblesInMemory,
151 std::unique_ptr<ParsingCallbacks> ASTCallbacks,
152 std::chrono::steady_clock::duration UpdateDebounce,
158 std::vector<std::pair<Path, std::size_t>> getUsedBytesPerFile()
const;
163 std::vector<Path> getFilesWithCachedAST()
const;
181 llvm::StringRef getContents(
PathRef File)
const;
184 llvm::StringMap<std::string> getAllFileContents()
const;
187 void run(llvm::StringRef
Name, llvm::unique_function<
void()>
Action);
197 void runWithAST(llvm::StringRef Name,
PathRef File,
226 void runWithPreamble(llvm::StringRef Name,
PathRef File,
232 bool blockUntilIdle(
Deadline D)
const;
248 static llvm::Optional<llvm::StringRef> getFileBeingProcessedInContext();
252 const bool StorePreamblesInMemory;
253 std::unique_ptr<ParsingCallbacks> Callbacks;
255 llvm::StringMap<std::unique_ptr<FileData>>
Files;
256 std::unique_ptr<ASTCache> IdleASTs;
259 llvm::Optional<AsyncTaskRunner> PreambleTasks;
260 llvm::Optional<AsyncTaskRunner> WorkerThreads;
261 std::chrono::steady_clock::duration UpdateDebounce;
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.
virtual void onMainAST(PathRef Path, ParsedAST &AST, PublishFn Publish)
Called on the AST built for the file itself.
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>.
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.
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.
virtual void onFailedAST(PathRef Path, std::vector< Diag > Diags, PublishFn Publish)
Called whenever the AST fails to build.
llvm::unique_function< void()> Action
std::string Path
A typedef to represent a file path.
static constexpr llvm::StringLiteral Name
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.
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.
The parsed preamble and associated data.
Diagnostics must not be generated for this snapshot.
llvm::StringMap< std::string > Files
The preamble is generated from the current version of the file.
llvm::function_ref< void(llvm::function_ref< void()>)> PublishFn
The argument function is run under the critical section guarding against races when closing the files...