| 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 |
| 17 | |
| 18 | #include "ClangdServer.h" |
| 19 | #include "Protocol.h" |
| 20 | #include "index/Index.h" |
| 21 | #include <optional> |
| 22 | |
| 23 | namespace clang { |
| 24 | namespace clangd { |
| 25 | |
| 26 | // Calls addDocument and then blockUntilIdleForTest. |
| 27 | void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents, |
| 28 | StringRef Version = "null" , |
| 29 | WantDiagnostics WantDiags = WantDiagnostics::Auto, |
| 30 | bool ForceRebuild = false); |
| 31 | |
| 32 | llvm::Expected<CodeCompleteResult> |
| 33 | runCodeComplete(ClangdServer &Server, PathRef File, Position Pos, |
| 34 | clangd::CodeCompleteOptions Opts); |
| 35 | |
| 36 | llvm::Expected<SignatureHelp> runSignatureHelp(ClangdServer &Server, |
| 37 | PathRef File, Position Pos, |
| 38 | MarkupKind DocumentationFormat); |
| 39 | |
| 40 | llvm::Expected<std::vector<LocatedSymbol>> |
| 41 | runLocateSymbolAt(ClangdServer &Server, PathRef File, Position Pos); |
| 42 | |
| 43 | llvm::Expected<std::vector<DocumentHighlight>> |
| 44 | runFindDocumentHighlights(ClangdServer &Server, PathRef File, Position Pos); |
| 45 | |
| 46 | llvm::Expected<RenameResult> runRename(ClangdServer &Server, PathRef File, |
| 47 | Position Pos, StringRef NewName, |
| 48 | const clangd::RenameOptions &RenameOpts); |
| 49 | |
| 50 | llvm::Expected<RenameResult> |
| 51 | runPrepareRename(ClangdServer &Server, PathRef File, Position Pos, |
| 52 | std::optional<std::string> NewName, |
| 53 | const clangd::RenameOptions &RenameOpts); |
| 54 | |
| 55 | llvm::Expected<tooling::Replacements> |
| 56 | runFormatFile(ClangdServer &Server, PathRef File, const std::vector<Range> &); |
| 57 | |
| 58 | SymbolSlab runFuzzyFind(const SymbolIndex &Index, StringRef Query); |
| 59 | SymbolSlab runFuzzyFind(const SymbolIndex &Index, const FuzzyFindRequest &Req); |
| 60 | RefSlab getRefs(const SymbolIndex &Index, SymbolID ID); |
| 61 | |
| 62 | llvm::Expected<std::vector<SelectionRange>> |
| 63 | runSemanticRanges(ClangdServer &Server, PathRef File, |
| 64 | const std::vector<Position> &Pos); |
| 65 | |
| 66 | llvm::Expected<std::optional<clangd::Path>> |
| 67 | (ClangdServer &Server, PathRef File); |
| 68 | |
| 69 | llvm::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 | |