clang-tools 10.0.0

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