10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDSERVER_H 11 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDSERVER_H 24 #include "clang/Tooling/CompilationDatabase.h" 25 #include "clang/Tooling/Core/Replacement.h" 26 #include "llvm/ADT/IntrusiveRefCntPtr.h" 27 #include "llvm/ADT/Optional.h" 28 #include "llvm/ADT/StringRef.h" 32 #include <type_traits> 36 class PCHContainerOperations;
47 std::vector<Diag> Diagnostics) = 0;
77 bool StorePreamblesInMemory =
true;
81 bool BuildDynamicSymbolIndex =
false;
84 bool HeavyweightDynamicSymbolIndex =
false;
91 size_t BackgroundIndexRebuildPeriodMs = 0;
108 std::chrono::steady_clock::duration UpdateDebounce =
109 std::chrono::milliseconds(500);
161 Callback<std::vector<Location>> CB);
165 llvm::Optional<Path> switchSourceHeader(
PathRef Path);
169 Callback<std::vector<DocumentHighlight>> CB);
173 Callback<llvm::Optional<Hover>> CB);
176 void workspaceSymbols(StringRef Query,
int Limit,
177 Callback<std::vector<SymbolInformation>> CB);
180 void documentSymbols(StringRef
File,
181 Callback<std::vector<DocumentSymbol>> CB);
185 Callback<std::vector<Location>> CB);
188 llvm::Expected<tooling::Replacements> formatRange(StringRef Code,
192 llvm::Expected<tooling::Replacements> formatFile(StringRef Code,
197 llvm::Expected<tooling::Replacements>
203 Callback<std::vector<tooling::Replacement>> CB);
215 Callback<std::vector<SymbolDetails>> CB);
224 std::vector<std::pair<Path, std::size_t>> getUsedBytesPerFile()
const;
233 blockUntilIdleForTest(llvm::Optional<double> TimeoutSeconds = 10);
238 llvm::Expected<tooling::Replacements>
239 formatCode(llvm::StringRef Code,
PathRef File,
240 ArrayRef<tooling::Range> Ranges);
242 tooling::CompileCommand getCompileCommand(
PathRef File);
255 std::unique_ptr<FileIndex> DynamicIdx;
257 std::unique_ptr<BackgroundIndex> BackgroundIdx;
259 std::vector<std::unique_ptr<SymbolIndex>> MergedIdx;
262 llvm::StringMap<llvm::Optional<FuzzyFindRequest>>
263 CachedCompletionFuzzyFindRequestByFile;
264 mutable std::mutex CachedCompletionFuzzyFindRequestMutex;
266 llvm::Optional<std::string> WorkspaceRoot;
267 std::shared_ptr<PCHContainerOperations>
PCHs;
SignatureHelp signatureHelp(PathRef FileName, const tooling::CompileCommand &Command, const PreambleData *Preamble, llvm::StringRef Contents, Position Pos, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS, std::shared_ptr< PCHContainerOperations > PCHs, const SymbolIndex *Index)
WantDiagnostics
Determines whether diagnostics should be generated for a file snapshot.
std::vector< Location > findDefinitions(ParsedAST &AST, Position Pos, const SymbolIndex *Index)
Get definition of symbol at a specified Pos.
CodeCompleteResult codeComplete(PathRef FileName, const tooling::CompileCommand &Command, const PreambleData *Preamble, llvm::StringRef Contents, Position Pos, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS, std::shared_ptr< PCHContainerOperations > PCHs, CodeCompleteOptions Opts, SpeculativeFuzzyFind *SpecFuzzyFind)
const SymbolIndex * dynamicIndex() const
Returns the active dynamic index if one was built.
void dumpAST(ParsedAST &AST, llvm::raw_ostream &OS)
For testing/debugging purposes.
Interface for symbol indexes that can be used for searching or matching symbols among a set of symbol...
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>.
Documents should not be synced at all.
ASTRetentionPolicy RetentionPolicy
AST caching policy. The default is to keep up to 3 ASTs in memory.
Configuration of the AST retention policy.
Provides compilation arguments used for parsing C and C++ files.
std::string Path
A typedef to represent a file path.
virtual void onDiagnosticsReady(PathRef File, std::vector< Diag > Diagnostics)=0
Called by ClangdServer when Diagnostics for File are ready.
virtual ~DiagnosticsConsumer()=default
std::vector< DocumentHighlight > findDocumentHighlights(ParsedAST &AST, Position Pos)
Returns highlights for all usages of a symbol at Pos.
static llvm::cl::opt< Path > ResourceDir("resource-dir", llvm::cl::desc("Directory for system clang headers"), llvm::cl::init(""), llvm::cl::Hidden)
llvm::Optional< std::string > WorkspaceRoot
Clangd's workspace root.
unsigned getDefaultAsyncThreadsCount()
Returns a number of a default async threads to use for TUScheduler.
std::vector< Location > findReferences(ParsedAST &AST, Position Pos, uint32_t Limit, const SymbolIndex *Index)
Returns reference locations of the symbol at a specified Pos.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::shared_ptr< PCHContainerOperations > PCHs
Manages a collection of source files and derived data (ASTs, indexes), and provides language-aware fe...
Handles running tasks for ClangdServer and managing the resources (e.g., preambles and ASTs) for open...
Diagnostics must not be generated for this snapshot.
virtual void onFileUpdated(PathRef File, const TUStatus &Status)
Called whenever the file status is updated.
const SymbolIndex * Index