9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDSERVER_H 10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDSERVER_H 12 #include "../clang-tidy/ClangTidyOptions.h" 27 #include "clang/Tooling/CompilationDatabase.h" 28 #include "clang/Tooling/Core/Replacement.h" 29 #include "llvm/ADT/FunctionExtras.h" 30 #include "llvm/ADT/IntrusiveRefCntPtr.h" 31 #include "llvm/ADT/Optional.h" 32 #include "llvm/ADT/StringRef.h" 36 #include <type_traits> 49 std::vector<Diag> Diagnostics) = 0;
56 std::vector<HighlightingToken> Highlightings) {}
63 llvm::vfs::FileSystem &, llvm::StringRef )>;
90 bool StorePreamblesInMemory =
true;
94 bool BuildDynamicSymbolIndex =
false;
96 bool HeavyweightDynamicSymbolIndex =
true;
123 std::chrono::steady_clock::duration UpdateDebounce =
124 std::chrono::milliseconds(500);
126 bool SuggestMissingIncludes =
false;
133 bool SemanticHighlighting =
false;
136 std::function<bool(const Tweak &)> TweakFilter = [](
const Tweak &T) {
168 llvm::StringRef getDocument(
PathRef File)
const;
173 void removeDocument(
PathRef File);
193 Callback<std::vector<LocatedSymbol>> CB);
198 Callback<llvm::Optional<clangd::Path>> CB);
202 Callback<std::vector<DocumentHighlight>> CB);
206 Callback<llvm::Optional<HoverInfo>> CB);
211 Callback<llvm::Optional<TypeHierarchyItem>> CB);
216 Callback<llvm::Optional<TypeHierarchyItem>> CB);
219 void workspaceSymbols(StringRef Query,
int Limit,
220 Callback<std::vector<SymbolInformation>> CB);
223 void documentSymbols(StringRef File,
224 Callback<std::vector<DocumentSymbol>> CB);
228 Callback<std::vector<Location>> CB);
231 llvm::Expected<tooling::Replacements> formatRange(StringRef
Code,
235 llvm::Expected<tooling::Replacements> formatFile(StringRef Code,
240 llvm::Expected<std::vector<TextEdit>> formatOnType(StringRef Code,
242 StringRef TriggerText);
246 Callback<llvm::Optional<Range>> CB);
254 bool WantFormat,
Callback<std::vector<TextEdit>> CB);
263 Callback<std::vector<TweakRef>> CB);
279 Callback<std::vector<SymbolDetails>> CB);
292 std::vector<std::pair<Path, std::size_t>> getUsedBytesPerFile()
const;
297 blockUntilIdleForTest(llvm::Optional<double> TimeoutSeconds = 10);
302 llvm::Expected<tooling::Replacements>
303 formatCode(llvm::StringRef Code,
PathRef File,
304 ArrayRef<tooling::Range> Ranges);
316 std::unique_ptr<FileIndex> DynamicIdx;
318 std::unique_ptr<BackgroundIndex> BackgroundIdx;
320 std::vector<std::unique_ptr<SymbolIndex>> MergedIdx;
327 bool SuggestMissingIncludes =
false;
329 std::function<bool(const Tweak &)> TweakFilter;
332 llvm::StringMap<llvm::Optional<FuzzyFindRequest>>
333 CachedCompletionFuzzyFindRequestByFile;
334 mutable std::mutex CachedCompletionFuzzyFindRequestMutex;
336 llvm::Optional<std::string> WorkspaceRoot;
WantDiagnostics
Determines whether diagnostics should be generated for a file snapshot.
void dumpAST(ParsedAST &AST, llvm::raw_ostream &OS)
For testing/debugging purposes.
void resolveTypeHierarchy(TypeHierarchyItem &Item, int ResolveLevels, TypeHierarchyDirection Direction, const SymbolIndex *Index)
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>.
Contains options for clang-tidy.
Tweak::Intent Intent
A single-line message to show in the UI.
Documents should not be synced at all.
ASTRetentionPolicy RetentionPolicy
AST caching policy. The default is to keep up to 3 ASTs in memory.
MockFSProvider FSProvider
Configuration of the AST retention policy.
std::string Title
ID to pass for applyTweak.
SignatureHelp signatureHelp(PathRef FileName, const tooling::CompileCommand &Command, const PreambleData *Preamble, llvm::StringRef Contents, Position Pos, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS, const SymbolIndex *Index)
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::function< tidy::ClangTidyOptions(llvm::vfs::FileSystem &, llvm::StringRef)> ClangTidyOptionsBuilder
When set, used by ClangdServer to get clang-tidy options for each particular file.
std::vector< DocumentHighlight > findDocumentHighlights(ParsedAST &AST, Position Pos)
Returns highlights for all usages of a symbol at Pos.
llvm::Optional< std::string > WorkspaceRoot
Clangd's workspace root.
CodeCompleteResult codeComplete(PathRef FileName, const tooling::CompileCommand &Command, const PreambleData *Preamble, llvm::StringRef Contents, Position Pos, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS, CodeCompleteOptions Opts, SpeculativeFuzzyFind *SpecFuzzyFind)
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::vector< std::string > QueryDriverGlobs
Clangd will execute compiler drivers matching one of these globs to fetch system include path...
An interface base for small context-sensitive refactoring actions.
IgnoreDiagnostics DiagConsumer
Manages a collection of source files and derived data (ASTs, indexes), and provides language-aware fe...
std::vector< LocatedSymbol > locateSymbolAt(ParsedAST &AST, Position Pos, const SymbolIndex *Index)
Get definition of symbol at a specified Pos.
ClangTidyOptionsBuilder GetClangTidyOptions
If set, enable clang-tidy in clangd and use to it get clang-tidy configurations for a particular file...
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 onHighlightingsReady(PathRef File, std::vector< HighlightingToken > Highlightings)
Called by ClangdServer when some Highlightings for File are ready.
virtual void onFileUpdated(PathRef File, const TUStatus &Status)
Called whenever the file status is updated.
const SymbolIndex * Index