10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDSERVER_H 11 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDSERVER_H 21 #include "clang/Tooling/CompilationDatabase.h" 22 #include "clang/Tooling/Core/Replacement.h" 23 #include "llvm/ADT/IntrusiveRefCntPtr.h" 24 #include "llvm/ADT/Optional.h" 25 #include "llvm/ADT/StringRef.h" 29 #include <type_traits> 33 class PCHContainerOperations;
43 std::vector<Diag> Diagnostics) = 0;
61 bool StorePreamblesInMemory =
true;
65 bool BuildDynamicSymbolIndex =
false;
81 std::chrono::steady_clock::duration UpdateDebounce =
82 std::chrono::milliseconds(500);
104 void setRootPath(
PathRef RootPath);
135 Callback<std::vector<Location>> CB);
139 llvm::Optional<Path> switchSourceHeader(
PathRef Path);
143 Callback<std::vector<DocumentHighlight>> CB);
147 Callback<llvm::Optional<Hover>> CB);
150 void workspaceSymbols(StringRef Query,
int Limit,
151 Callback<std::vector<SymbolInformation>> CB);
154 void documentSymbols(StringRef
File,
155 Callback<std::vector<SymbolInformation>> CB);
158 llvm::Expected<tooling::Replacements> formatRange(StringRef Code,
162 llvm::Expected<tooling::Replacements> formatFile(StringRef Code,
167 llvm::Expected<tooling::Replacements>
173 Callback<std::vector<tooling::Replacement>> CB);
189 std::vector<std::pair<Path, std::size_t>> getUsedBytesPerFile()
const;
194 blockUntilIdleForTest(llvm::Optional<double> TimeoutSeconds = 10);
199 llvm::Expected<tooling::Replacements>
200 formatCode(llvm::StringRef Code,
PathRef File,
201 ArrayRef<tooling::Range> Ranges);
203 typedef uint64_t DocVersion;
205 void consumeDiagnostics(
PathRef File, DocVersion Version,
206 std::vector<Diag> Diags);
208 tooling::CompileCommand getCompileCommand(
PathRef File);
215 llvm::StringMap<DocVersion> InternalVersion;
225 std::unique_ptr<FileIndex> FileIdx;
227 std::unique_ptr<SymbolIndex> MergedIndex;
229 llvm::Optional<std::string> RootPath;
230 std::shared_ptr<PCHContainerOperations>
PCHs;
234 std::mutex DiagnosticsMutex;
236 llvm::StringMap<DocVersion> ReportedDiagnosticVersions;
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, PrecompiledPreamble const *Preamble, const IncludeStructure &PreambleInclusions, StringRef Contents, Position Pos, IntrusiveRefCntPtr< vfs::FileSystem > VFS, std::shared_ptr< PCHContainerOperations > PCHs, CodeCompleteOptions Opts)
Get code completions at a specified Pos in FileName.
SignatureHelp signatureHelp(PathRef FileName, const tooling::CompileCommand &Command, PrecompiledPreamble const *Preamble, StringRef Contents, Position Pos, IntrusiveRefCntPtr< vfs::FileSystem > VFS, std::shared_ptr< PCHContainerOperations > PCHs)
Get signature help at a specified Pos in FileName.
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.
static llvm::cl::opt< Path > ResourceDir("resource-dir", llvm::cl::desc("Directory for system clang headers"), llvm::cl::init(""), llvm::cl::Hidden)
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.
unsigned getDefaultAsyncThreadsCount()
Returns a number of a default async threads to use for TUScheduler.
std::vector< std::string > URISchemes
URI schemes to use when building the dynamic index.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
std::shared_ptr< PCHContainerOperations > PCHs
Provides API to manage ASTs for a collection of C++ files and request various language features...
Handles running tasks for ClangdServer and managing the resources (e.g., preambles and ASTs) for open...
Diagnostics must not be generated for this snapshot.