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",
29 WantDiagnostics WantDiags = WantDiagnostics::Auto,
30 bool ForceRebuild = false);
31
32llvm::Expected<CodeCompleteResult>
33runCodeComplete(ClangdServer &Server, PathRef File, Position Pos,
34 clangd::CodeCompleteOptions Opts);
35
36llvm::Expected<SignatureHelp> runSignatureHelp(ClangdServer &Server,
37 PathRef File, Position Pos,
38 MarkupKind DocumentationFormat);
39
40llvm::Expected<std::vector<LocatedSymbol>>
41runLocateSymbolAt(ClangdServer &Server, PathRef File, Position Pos);
42
43llvm::Expected<std::vector<DocumentHighlight>>
44runFindDocumentHighlights(ClangdServer &Server, PathRef File, Position Pos);
45
46llvm::Expected<RenameResult> runRename(ClangdServer &Server, PathRef File,
47 Position Pos, StringRef NewName,
48 const clangd::RenameOptions &RenameOpts);
49
50llvm::Expected<RenameResult>
51runPrepareRename(ClangdServer &Server, PathRef File, Position Pos,
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);
60RefSlab getRefs(const SymbolIndex &Index, SymbolID ID);
61
62llvm::Expected<std::vector<SelectionRange>>
63runSemanticRanges(ClangdServer &Server, PathRef File,
64 const std::vector<Position> &Pos);
65
66llvm::Expected<std::optional<clangd::Path>>
67runSwitchHeaderSource(ClangdServer &Server, PathRef File);
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
76

source code of clang-tools-extra/clangd/unittests/SyncAPI.h