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