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_UNITTESTS_CLANGD_SYNCAPI_H
16 #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_SYNCAPI_H
17 
18 #include "ClangdServer.h"
19 #include "index/Index.h"
20 
21 namespace clang {
22 namespace clangd {
23 
24 // Calls addDocument and then blockUntilIdleForTest.
25 void runAddDocument(ClangdServer &Server, PathRef File, StringRef Contents,
26                     WantDiagnostics WantDiags = WantDiagnostics::Auto);
27 
28 llvm::Expected<CodeCompleteResult>
29 runCodeComplete(ClangdServer &Server, PathRef File, Position Pos,
30                 clangd::CodeCompleteOptions Opts);
31 
32 llvm::Expected<SignatureHelp> runSignatureHelp(ClangdServer &Server,
33                                                PathRef File, Position Pos);
34 
35 llvm::Expected<std::vector<LocatedSymbol>>
36 runLocateSymbolAt(ClangdServer &Server, PathRef File, Position Pos);
37 
38 llvm::Expected<std::vector<DocumentHighlight>>
39 runFindDocumentHighlights(ClangdServer &Server, PathRef File, Position Pos);
40 
41 llvm::Expected<FileEdits> runRename(ClangdServer &Server, PathRef File,
42                                     Position Pos, StringRef NewName);
43 
44 std::string runDumpAST(ClangdServer &Server, PathRef File);
45 
46 llvm::Expected<std::vector<SymbolInformation>>
47 runWorkspaceSymbols(ClangdServer &Server, StringRef Query, int Limit);
48 
49 Expected<std::vector<DocumentSymbol>> runDocumentSymbols(ClangdServer &Server,
50                                                          PathRef File);
51 
52 SymbolSlab runFuzzyFind(const SymbolIndex &Index, StringRef Query);
53 SymbolSlab runFuzzyFind(const SymbolIndex &Index, const FuzzyFindRequest &Req);
54 RefSlab getRefs(const SymbolIndex &Index, SymbolID ID);
55 
56 llvm::Expected<std::vector<Range>>
57 runSemanticRanges(ClangdServer &Server, PathRef File, Position Pos);
58 
59 llvm::Expected<llvm::Optional<clangd::Path>>
60 runSwitchHeaderSource(ClangdServer &Server, PathRef File);
61 
62 } // namespace clangd
63 } // namespace clang
64 
65 #endif // LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_SYNCAPI_H
66