clang-tools 19.0.0git
SyncAPI.h
Go to the documentation of this file.
1//===--- SyncAPI.h - Sync version of ClangdServer's API ----------*- C++-*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains synchronous versions of ClangdServer's async API. We
10// deliberately don't expose the sync API outside tests to encourage using the
11// async versions in clangd code.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_SYNCAPI_H
16#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_SYNCAPI_H
17
18#include "ClangdServer.h"
19#include "Protocol.h"
20#include "index/Index.h"
21#include <optional>
22
23namespace clang {
24namespace clangd {
25
26// Calls addDocument and then blockUntilIdleForTest.
27void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents,
28 StringRef Version = "null",
30 bool ForceRebuild = false);
31
32llvm::Expected<CodeCompleteResult>
35
36llvm::Expected<SignatureHelp> runSignatureHelp(ClangdServer &Server,
38 MarkupKind DocumentationFormat);
39
40llvm::Expected<std::vector<LocatedSymbol>>
42
43llvm::Expected<std::vector<DocumentHighlight>>
45
46llvm::Expected<RenameResult> runRename(ClangdServer &Server, PathRef File,
47 Position Pos, StringRef NewName,
48 const clangd::RenameOptions &RenameOpts);
49
50llvm::Expected<RenameResult>
52 std::optional<std::string> NewName,
53 const clangd::RenameOptions &RenameOpts);
54
55llvm::Expected<tooling::Replacements>
56runFormatFile(ClangdServer &Server, PathRef File, std::optional<Range>);
57
58SymbolSlab runFuzzyFind(const SymbolIndex &Index, StringRef Query);
59SymbolSlab runFuzzyFind(const SymbolIndex &Index, const FuzzyFindRequest &Req);
61
62llvm::Expected<std::vector<SelectionRange>>
64 const std::vector<Position> &Pos);
65
66llvm::Expected<std::optional<clangd::Path>>
68
69llvm::Error runCustomAction(ClangdServer &Server, PathRef File,
70 llvm::function_ref<void(InputsAndAST)>);
71
72} // namespace clangd
73} // namespace clang
74
75#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_SYNCAPI_H
size_t Pos
WantDiagnostics WantDiags
Manages a collection of source files and derived data (ASTs, indexes), and provides language-aware fe...
Definition: ClangdServer.h:58
An efficient structure of storing large set of symbol references in memory.
Definition: Ref.h:108
Interface for symbol indexes that can be used for searching or matching symbols among a set of symbol...
Definition: Index.h:113
An immutable symbol container that stores a set of symbols.
Definition: Symbol.h:199
llvm::Expected< std::optional< clangd::Path > > runSwitchHeaderSource(ClangdServer &Server, PathRef File)
Definition: SyncAPI.cpp:155
llvm::Expected< tooling::Replacements > runFormatFile(ClangdServer &Server, PathRef File, std::optional< Range > Rng)
Definition: SyncAPI.cpp:119
llvm::Expected< RenameResult > runRename(ClangdServer &Server, PathRef File, Position Pos, llvm::StringRef NewName, const RenameOptions &RenameOpts)
Definition: SyncAPI.cpp:101
llvm::Expected< std::vector< SelectionRange > > runSemanticRanges(ClangdServer &Server, PathRef File, const std::vector< Position > &Pos)
Definition: SyncAPI.cpp:147
llvm::Expected< CodeCompleteResult > runCodeComplete(ClangdServer &Server, PathRef File, Position Pos, clangd::CodeCompleteOptions Opts)
Definition: SyncAPI.cpp:72
llvm::Expected< SignatureHelp > runSignatureHelp(ClangdServer &Server, PathRef File, Position Pos, MarkupKind DocumentationFormat)
Definition: SyncAPI.cpp:79
RefSlab getRefs(const SymbolIndex &Index, SymbolID ID)
Definition: SyncAPI.cpp:138
void runAddDocument(ClangdServer &Server, PathRef File, llvm::StringRef Contents, llvm::StringRef Version, WantDiagnostics WantDiags, bool ForceRebuild)
Definition: SyncAPI.cpp:17
llvm::Expected< std::vector< LocatedSymbol > > runLocateSymbolAt(ClangdServer &Server, PathRef File, Position Pos)
Definition: SyncAPI.cpp:88
WantDiagnostics
Determines whether diagnostics should be generated for a file snapshot.
Definition: TUScheduler.h:53
@ Auto
Diagnostics must not be generated for this snapshot.
llvm::Error runCustomAction(ClangdServer &Server, PathRef File, llvm::function_ref< void(InputsAndAST)> Action)
Definition: SyncAPI.cpp:161
llvm::StringRef PathRef
A typedef to represent a ref to file path.
Definition: Path.h:29
llvm::Expected< std::vector< DocumentHighlight > > runFindDocumentHighlights(ClangdServer &Server, PathRef File, Position Pos)
Definition: SyncAPI.cpp:95
SymbolSlab runFuzzyFind(const SymbolIndex &Index, llvm::StringRef Query)
Definition: SyncAPI.cpp:125
llvm::Expected< RenameResult > runPrepareRename(ClangdServer &Server, PathRef File, Position Pos, std::optional< std::string > NewName, const RenameOptions &RenameOpts)
Definition: SyncAPI.cpp:110
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//