clang-tools  11.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  StringRef Version = "null",
28  bool ForceRebuild = false);
29 
30 llvm::Expected<CodeCompleteResult>
31 runCodeComplete(ClangdServer &Server, PathRef File, Position Pos,
32  clangd::CodeCompleteOptions Opts);
33 
34 llvm::Expected<SignatureHelp> runSignatureHelp(ClangdServer &Server,
35  PathRef File, Position Pos);
36 
37 llvm::Expected<std::vector<LocatedSymbol>>
38 runLocateSymbolAt(ClangdServer &Server, PathRef File, Position Pos);
39 
40 llvm::Expected<std::vector<DocumentHighlight>>
41 runFindDocumentHighlights(ClangdServer &Server, PathRef File, Position Pos);
42 
43 llvm::Expected<FileEdits> runRename(ClangdServer &Server, PathRef File,
44  Position Pos, StringRef NewName,
45  const clangd::RenameOptions &RenameOpts);
46 
47 llvm::Expected<tooling::Replacements>
48 runFormatFile(ClangdServer &Server, PathRef File, StringRef Code);
49 
50 std::string runDumpAST(ClangdServer &Server, 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<SelectionRange>>
57 runSemanticRanges(ClangdServer &Server, PathRef File,
58  const std::vector<Position> &Pos);
59 
60 llvm::Expected<llvm::Optional<clangd::Path>>
61 runSwitchHeaderSource(ClangdServer &Server, PathRef File);
62 
63 } // namespace clangd
64 } // namespace clang
65 
66 #endif // LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_SYNCAPI_H
clang::clangd::runFormatFile
llvm::Expected< tooling::Replacements > runFormatFile(ClangdServer &Server, PathRef File, StringRef Code)
Definition: SyncAPI.cpp:109
WantDiags
WantDiagnostics WantDiags
Definition: TUScheduler.cpp:323
clang::clangd::runFuzzyFind
SymbolSlab runFuzzyFind(const SymbolIndex &Index, llvm::StringRef Query)
Definition: SyncAPI.cpp:121
clang::clangd::runCodeComplete
llvm::Expected< CodeCompleteResult > runCodeComplete(ClangdServer &Server, PathRef File, Position Pos, clangd::CodeCompleteOptions Opts)
Definition: SyncAPI.cpp:72
clang::clangd::WantDiagnostics::Auto
Diagnostics must not be generated for this snapshot.
Index.h
Contents
llvm::StringRef Contents
Definition: DraftStoreTests.cpp:22
clang::clangd::runAddDocument
void runAddDocument(ClangdServer &Server, PathRef File, llvm::StringRef Contents, llvm::StringRef Version, WantDiagnostics WantDiags, bool ForceRebuild)
Definition: SyncAPI.cpp:15
clang::clangd::WantDiagnostics
WantDiagnostics
Determines whether diagnostics should be generated for a file snapshot.
Definition: TUScheduler.h:48
clang::clangd::runSemanticRanges
llvm::Expected< std::vector< SelectionRange > > runSemanticRanges(ClangdServer &Server, PathRef File, const std::vector< Position > &Pos)
Definition: SyncAPI.cpp:143
clang::clangd::getRefs
RefSlab getRefs(const SymbolIndex &Index, SymbolID ID)
Definition: SyncAPI.cpp:134
Code
std::string Code
Definition: FindTargetTests.cpp:67
clang::clangd::runLocateSymbolAt
llvm::Expected< std::vector< LocatedSymbol > > runLocateSymbolAt(ClangdServer &Server, PathRef File, Position Pos)
Definition: SyncAPI.cpp:87
clang::clangd::runSwitchHeaderSource
llvm::Expected< llvm::Optional< clangd::Path > > runSwitchHeaderSource(ClangdServer &Server, PathRef File)
Definition: SyncAPI.cpp:151
clang::clangd::runFindDocumentHighlights
llvm::Expected< std::vector< DocumentHighlight > > runFindDocumentHighlights(ClangdServer &Server, PathRef File, Position Pos)
Definition: SyncAPI.cpp:94
clang::doc::SymbolID
std::array< uint8_t, 20 > SymbolID
Definition: Representation.h:30
Index
const SymbolIndex * Index
Definition: Dexp.cpp:95
clang::clangd::runDumpAST
std::string runDumpAST(ClangdServer &Server, PathRef File)
Definition: SyncAPI.cpp:115
clang::clangd::PathRef
llvm::StringRef PathRef
A typedef to represent a ref to file path.
Definition: Path.h:23
RenameOpts
RenameOptions RenameOpts
Definition: ClangdLSPServerTests.cpp:68
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
ClangdServer.h
clang::clangd::runSignatureHelp
llvm::Expected< SignatureHelp > runSignatureHelp(ClangdServer &Server, PathRef File, Position Pos)
Definition: SyncAPI.cpp:79
Pos
Position Pos
Definition: SourceCode.cpp:649
clang::clangd::runRename
llvm::Expected< FileEdits > runRename(ClangdServer &Server, PathRef File, Position Pos, llvm::StringRef NewName, const RenameOptions &RenameOpts)
Definition: SyncAPI.cpp:100