19 llvm_unreachable(
"not idle after addDocument");
27 template <
typename T>
struct CaptureProxy {
28 CaptureProxy(llvm::Optional<T> &Target) : Target(&Target) {
29 assert(!Target.hasValue());
32 CaptureProxy(
const CaptureProxy &) =
delete;
33 CaptureProxy &operator=(
const CaptureProxy &) =
delete;
35 CaptureProxy(CaptureProxy &&Other) : Target(Other.Target) {
36 Other.Target =
nullptr;
38 CaptureProxy &operator=(CaptureProxy &&) =
delete;
40 operator llvm::unique_function<void(T)>() && {
41 assert(!Future.valid() &&
"conversion to callback called multiple times");
42 Future = Promise.get_future();
44 [](std::promise<std::shared_ptr<T>> Promise, T
Value) {
45 Promise.set_value(std::make_shared<T>(std::move(Value)));
53 assert(Future.valid() &&
"conversion to callback was not called");
54 assert(!Target->hasValue());
55 Target->emplace(std::move(*Future.get()));
59 llvm::Optional<T> *Target;
63 std::promise<std::shared_ptr<T>> Promise;
64 std::future<std::shared_ptr<T>> Future;
67 template <
typename T> CaptureProxy<T> capture(llvm::Optional<T> &Target) {
68 return CaptureProxy<T>(Target);
72 llvm::Expected<CodeCompleteResult>
75 llvm::Optional<llvm::Expected<CodeCompleteResult>>
Result;
77 return std::move(*Result);
82 llvm::Optional<llvm::Expected<SignatureHelp>>
Result;
84 return std::move(*Result);
87 llvm::Expected<std::vector<LocatedSymbol>>
89 llvm::Optional<llvm::Expected<std::vector<LocatedSymbol>>>
Result;
91 return std::move(*Result);
94 llvm::Expected<std::vector<DocumentHighlight>>
96 llvm::Optional<llvm::Expected<std::vector<DocumentHighlight>>>
Result;
98 return std::move(*Result);
103 llvm::StringRef NewName) {
104 llvm::Optional<llvm::Expected<std::vector<TextEdit>>>
Result;
105 Server.
rename(File, Pos, NewName,
true, capture(Result));
106 return std::move(*Result);
110 llvm::Optional<std::string>
Result;
111 Server.
dumpAST(File, capture(Result));
112 return std::move(*Result);
115 llvm::Expected<std::vector<SymbolInformation>>
117 llvm::Optional<llvm::Expected<std::vector<SymbolInformation>>>
Result;
119 return std::move(*Result);
122 llvm::Expected<std::vector<DocumentSymbol>>
124 llvm::Optional<llvm::Expected<std::vector<DocumentSymbol>>>
Result;
126 return std::move(*Result);
139 return std::move(Builder).build();
147 return std::move(Slab).build();
WantDiagnostics
Determines whether diagnostics should be generated for a file snapshot.
void rename(PathRef File, Position Pos, llvm::StringRef NewName, bool WantFormat, Callback< std::vector< TextEdit >> CB)
Rename all occurrences of the symbol at the Pos in File to NewName.
An immutable symbol container that stores a set of symbols.
llvm::DenseSet< SymbolID > IDs
void addDocument(PathRef File, StringRef Contents, WantDiagnostics WD=WantDiagnostics::Auto)
Add a File to the list of tracked C++ files or update the contents if File is already tracked...
bool AnyScope
If set to true, allow symbols from any scope.
void codeComplete(PathRef File, Position Pos, const clangd::CodeCompleteOptions &Opts, Callback< CodeCompleteResult > CB)
Run code completion for File at Pos.
llvm::Expected< CodeCompleteResult > runCodeComplete(ClangdServer &Server, PathRef File, Position Pos, clangd::CodeCompleteOptions Opts)
std::string runDumpAST(ClangdServer &Server, PathRef File)
An efficient structure of storing large set of symbol references in memory.
llvm::Expected< SignatureHelp > runSignatureHelp(ClangdServer &Server, PathRef File, Position Pos)
llvm::Expected< std::vector< DocumentSymbol > > runDocumentSymbols(ClangdServer &Server, PathRef File)
llvm::Expected< std::vector< LocatedSymbol > > runLocateSymbolAt(ClangdServer &Server, PathRef File, Position Pos)
Interface for symbol indexes that can be used for searching or matching symbols among a set of symbol...
Represents a symbol occurrence in the source file.
virtual bool fuzzyFind(const FuzzyFindRequest &Req, llvm::function_ref< void(const Symbol &)> Callback) const =0
Matches symbols in the index fuzzily and applies Callback on each matched symbol before returning...
llvm::StringRef PathRef
A typedef to represent a ref to file path.
void insert(const Symbol &S)
Adds a symbol, overwriting any existing one with the same ID.
LLVM_NODISCARD bool blockUntilIdleForTest(llvm::Optional< double > TimeoutSeconds=10)
void findDocumentHighlights(PathRef File, Position Pos, Callback< std::vector< DocumentHighlight >> CB)
Get document highlights for a given position.
SymbolSlab::Builder is a mutable container that can 'freeze' to SymbolSlab.
ForwardBinder< Func, Args... > Bind(Func F, Args &&... As)
Creates an object that stores a callable (F) and first arguments to the callable (As) and allows to c...
SymbolSlab runFuzzyFind(const SymbolIndex &Index, llvm::StringRef Query)
std::string Query
A query string for the fuzzy find.
virtual void refs(const RefsRequest &Req, llvm::function_ref< void(const Ref &)> Callback) const =0
Finds all occurrences (e.g.
void dumpAST(PathRef File, llvm::unique_function< void(std::string)> Callback)
Only for testing purposes.
void documentSymbols(StringRef File, Callback< std::vector< DocumentSymbol >> CB)
Retrieve the symbols within the specified file.
RefSlab::Builder is a mutable container that can 'freeze' to RefSlab.
CodeCompletionBuilder Builder
The class presents a C++ symbol, e.g.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::Expected< std::vector< SymbolInformation > > runWorkspaceSymbols(ClangdServer &Server, llvm::StringRef Query, int Limit)
llvm::Expected< std::vector< DocumentHighlight > > runFindDocumentHighlights(ClangdServer &Server, PathRef File, Position Pos)
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
void insert(const SymbolID &ID, const Ref &S)
Adds a ref to the slab. Deep copy: Strings will be owned by the slab.
void locateSymbolAt(PathRef File, Position Pos, Callback< std::vector< LocatedSymbol >> CB)
Find declaration/definition locations of symbol at a specified position.
Manages a collection of source files and derived data (ASTs, indexes), and provides language-aware fe...
llvm::Expected< std::vector< TextEdit > > runRename(ClangdServer &Server, PathRef File, Position Pos, llvm::StringRef NewName)
void workspaceSymbols(StringRef Query, int Limit, Callback< std::vector< SymbolInformation >> CB)
Retrieve the top symbols from the workspace matching a query.
void signatureHelp(PathRef File, Position Pos, Callback< SignatureHelp > CB)
Provide signature help for File at Pos.
RefSlab getRefs(const SymbolIndex &Index, SymbolID ID)
void runAddDocument(ClangdServer &Server, PathRef File, llvm::StringRef Contents, WantDiagnostics WantDiags)
const SymbolIndex * Index