Mercurial > hg > CbC > CbC_llvm
comparison clang-tools-extra/clangd/unittests/SyncAPI.cpp @ 221:79ff65ed7e25
LLVM12 Original
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 15 Jun 2021 19:15:29 +0900 |
parents | 0572611fdcc8 |
children | c4bab56944e8 |
comparison
equal
deleted
inserted
replaced
220:42394fc6a535 | 221:79ff65ed7e25 |
---|---|
95 llvm::Optional<llvm::Expected<std::vector<DocumentHighlight>>> Result; | 95 llvm::Optional<llvm::Expected<std::vector<DocumentHighlight>>> Result; |
96 Server.findDocumentHighlights(File, Pos, capture(Result)); | 96 Server.findDocumentHighlights(File, Pos, capture(Result)); |
97 return std::move(*Result); | 97 return std::move(*Result); |
98 } | 98 } |
99 | 99 |
100 llvm::Expected<FileEdits> runRename(ClangdServer &Server, PathRef File, | 100 llvm::Expected<RenameResult> runRename(ClangdServer &Server, PathRef File, |
101 Position Pos, llvm::StringRef NewName, | 101 Position Pos, llvm::StringRef NewName, |
102 const RenameOptions &RenameOpts) { | 102 const RenameOptions &RenameOpts) { |
103 llvm::Optional<llvm::Expected<FileEdits>> Result; | 103 llvm::Optional<llvm::Expected<RenameResult>> Result; |
104 Server.rename(File, Pos, NewName, RenameOpts, capture(Result)); | 104 Server.rename(File, Pos, NewName, RenameOpts, capture(Result)); |
105 return std::move(*Result); | 105 return std::move(*Result); |
106 } | 106 } |
107 | 107 |
108 std::string runDumpAST(ClangdServer &Server, PathRef File) { | 108 llvm::Expected<RenameResult> |
109 llvm::Optional<std::string> Result; | 109 runPrepareRename(ClangdServer &Server, PathRef File, Position Pos, |
110 Server.dumpAST(File, capture(Result)); | 110 llvm::Optional<std::string> NewName, |
111 const RenameOptions &RenameOpts) { | |
112 llvm::Optional<llvm::Expected<RenameResult>> Result; | |
113 Server.prepareRename(File, Pos, NewName, RenameOpts, capture(Result)); | |
111 return std::move(*Result); | 114 return std::move(*Result); |
112 } | 115 } |
113 | 116 |
114 llvm::Expected<std::vector<SymbolInformation>> | 117 llvm::Expected<tooling::Replacements> |
115 runWorkspaceSymbols(ClangdServer &Server, llvm::StringRef Query, int Limit) { | 118 runFormatFile(ClangdServer &Server, PathRef File, llvm::Optional<Range> Rng) { |
116 llvm::Optional<llvm::Expected<std::vector<SymbolInformation>>> Result; | 119 llvm::Optional<llvm::Expected<tooling::Replacements>> Result; |
117 Server.workspaceSymbols(Query, Limit, capture(Result)); | 120 Server.formatFile(File, Rng, capture(Result)); |
118 return std::move(*Result); | |
119 } | |
120 | |
121 llvm::Expected<std::vector<DocumentSymbol>> | |
122 runDocumentSymbols(ClangdServer &Server, PathRef File) { | |
123 llvm::Optional<llvm::Expected<std::vector<DocumentSymbol>>> Result; | |
124 Server.documentSymbols(File, capture(Result)); | |
125 return std::move(*Result); | 121 return std::move(*Result); |
126 } | 122 } |
127 | 123 |
128 SymbolSlab runFuzzyFind(const SymbolIndex &Index, llvm::StringRef Query) { | 124 SymbolSlab runFuzzyFind(const SymbolIndex &Index, llvm::StringRef Query) { |
129 FuzzyFindRequest Req; | 125 FuzzyFindRequest Req; |
159 llvm::Optional<llvm::Expected<llvm::Optional<clangd::Path>>> Result; | 155 llvm::Optional<llvm::Expected<llvm::Optional<clangd::Path>>> Result; |
160 Server.switchSourceHeader(File, capture(Result)); | 156 Server.switchSourceHeader(File, capture(Result)); |
161 return std::move(*Result); | 157 return std::move(*Result); |
162 } | 158 } |
163 | 159 |
160 llvm::Error runCustomAction(ClangdServer &Server, PathRef File, | |
161 llvm::function_ref<void(InputsAndAST)> Action) { | |
162 llvm::Error Result = llvm::Error::success(); | |
163 Notification Done; | |
164 Server.customAction(File, "Custom", [&](llvm::Expected<InputsAndAST> AST) { | |
165 if (!AST) | |
166 Result = AST.takeError(); | |
167 else | |
168 Action(*AST); | |
169 Done.notify(); | |
170 }); | |
171 Done.wait(); | |
172 return Result; | |
173 } | |
174 | |
164 } // namespace clangd | 175 } // namespace clangd |
165 } // namespace clang | 176 } // namespace clang |