clang-tools  10.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_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,
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
int Limit
WantDiagnostics
Determines whether diagnostics should be generated for a file snapshot.
Definition: TUScheduler.h:47
llvm::Expected< std::vector< Range > > runSemanticRanges(ClangdServer &Server, PathRef File, Position Pos)
Definition: SyncAPI.cpp:148
llvm::StringRef Contents
llvm::Expected< CodeCompleteResult > runCodeComplete(ClangdServer &Server, PathRef File, Position Pos, clangd::CodeCompleteOptions Opts)
Definition: SyncAPI.cpp:71
std::string runDumpAST(ClangdServer &Server, PathRef File)
Definition: SyncAPI.cpp:106
llvm::Expected< SignatureHelp > runSignatureHelp(ClangdServer &Server, PathRef File, Position Pos)
Definition: SyncAPI.cpp:78
llvm::Expected< std::vector< DocumentSymbol > > runDocumentSymbols(ClangdServer &Server, PathRef File)
Definition: SyncAPI.cpp:120
llvm::Expected< std::vector< LocatedSymbol > > runLocateSymbolAt(ClangdServer &Server, PathRef File, Position Pos)
Definition: SyncAPI.cpp:86
llvm::StringRef PathRef
A typedef to represent a ref to file path.
Definition: Path.h:23
llvm::Expected< llvm::Optional< clangd::Path > > runSwitchHeaderSource(ClangdServer &Server, PathRef File)
Definition: SyncAPI.cpp:155
SymbolSlab runFuzzyFind(const SymbolIndex &Index, llvm::StringRef Query)
Definition: SyncAPI.cpp:126
Position Pos
Definition: SourceCode.cpp:772
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::Expected< std::vector< SymbolInformation > > runWorkspaceSymbols(ClangdServer &Server, llvm::StringRef Query, int Limit)
Definition: SyncAPI.cpp:113
ClangdServer Server
llvm::Expected< std::vector< DocumentHighlight > > runFindDocumentHighlights(ClangdServer &Server, PathRef File, Position Pos)
Definition: SyncAPI.cpp:93
llvm::Expected< FileEdits > runRename(ClangdServer &Server, PathRef File, Position Pos, llvm::StringRef NewName)
Definition: SyncAPI.cpp:99
std::array< uint8_t, 20 > SymbolID
Diagnostics must not be generated for this snapshot.
RefSlab getRefs(const SymbolIndex &Index, SymbolID ID)
Definition: SyncAPI.cpp:139
void runAddDocument(ClangdServer &Server, PathRef File, llvm::StringRef Contents, WantDiagnostics WantDiags)
Definition: SyncAPI.cpp:15
const SymbolIndex * Index
Definition: Dexp.cpp:84