This revision was automatically updated to reflect the committed changes.
Closed by commit rL329725: [clangd] Use operator<< to prevent printers
issues in Gtest (authored by malaperle, committed by ).
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
https://reviews.llvm.org/D44764
Files:
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp
clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
Index: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
===================================================================
--- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp
@@ -24,15 +24,6 @@
namespace clangd {
using namespace llvm;
-void PrintTo(const DocumentHighlight &V, std::ostream *O) {
- llvm::raw_os_ostream OS(*O);
- OS << V.range;
- if (V.kind == DocumentHighlightKind::Read)
- OS << "(r)";
- if (V.kind == DocumentHighlightKind::Write)
- OS << "(w)";
-}
-
namespace {
using testing::ElementsAre;
using testing::Field;
Index: clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp
===================================================================
--- clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/JSONExprTests.cpp
@@ -15,9 +15,7 @@
namespace clang {
namespace clangd {
namespace json {
-void PrintTo(const Expr &E, std::ostream *OS) {
- llvm::raw_os_ostream(*OS) << llvm::formatv("{0:2}", E);
-}
+
namespace {
std::string s(const Expr &E) { return llvm::formatv("{0}", E).str(); }
Index: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
===================================================================
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
@@ -22,33 +22,6 @@
namespace clang {
namespace clangd {
-// Let GMock print completion items and signature help.
-void PrintTo(const CompletionItem &I, std::ostream *O) {
- llvm::raw_os_ostream OS(*O);
- OS << I.label << " - " << toJSON(I);
-}
-void PrintTo(const std::vector<CompletionItem> &V, std::ostream *O) {
- *O << "{\n";
- for (const auto &I : V) {
- *O << "\t";
- PrintTo(I, O);
- *O << "\n";
- }
- *O << "}";
-}
-void PrintTo(const SignatureInformation &I, std::ostream *O) {
- llvm::raw_os_ostream OS(*O);
- OS << I.label << " - " << toJSON(I);
-}
-void PrintTo(const std::vector<SignatureInformation> &V, std::ostream *O) {
- *O << "{\n";
- for (const auto &I : V) {
- *O << "\t";
- PrintTo(I, O);
- *O << "\n";
- }
- *O << "}";
-}
namespace {
using namespace llvm;
Index: clang-tools-extra/trunk/clangd/Protocol.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/Protocol.cpp
+++ clang-tools-extra/trunk/clangd/Protocol.cpp
@@ -446,6 +446,11 @@
return std::move(Result);
}
+llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const CompletionItem &I) {
+ O << I.label << " - " << toJSON(I);
+ return O;
+}
+
bool operator<(const CompletionItem &L, const CompletionItem &R) {
return (L.sortText.empty() ? L.label : L.sortText) <
(R.sortText.empty() ? R.label : R.sortText);
@@ -477,6 +482,12 @@
return std::move(Result);
}
+llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
+ const SignatureInformation &I) {
+ O << I.label << " - " << toJSON(I);
+ return O;
+}
+
json::Expr toJSON(const SignatureHelp &SH) {
assert(SH.activeSignature >= 0 &&
"Unexpected negative value for number of active signatures.");
@@ -502,6 +513,16 @@
};
}
+llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
+ const DocumentHighlight &V) {
+ O << V.range;
+ if (V.kind == DocumentHighlightKind::Read)
+ O << "(r)";
+ if (V.kind == DocumentHighlightKind::Write)
+ O << "(w)";
+ return O;
+}
+
bool fromJSON(const json::Expr &Params, DidChangeConfigurationParams &CCP) {
json::ObjectMapper O(Params);
return O && O.map("settings", CCP.settings);
Index: clang-tools-extra/trunk/clangd/Protocol.h
===================================================================
--- clang-tools-extra/trunk/clangd/Protocol.h
+++ clang-tools-extra/trunk/clangd/Protocol.h
@@ -670,6 +670,7 @@
// between a completion and a completion resolve request.
};
json::Expr toJSON(const CompletionItem &);
+llvm::raw_ostream &operator<<(llvm::raw_ostream &, const CompletionItem &);
bool operator<(const CompletionItem &, const CompletionItem &);
@@ -708,6 +709,8 @@
std::vector<ParameterInformation> parameters;
};
json::Expr toJSON(const SignatureInformation &);
+llvm::raw_ostream &operator<<(llvm::raw_ostream &,
+ const SignatureInformation &);
/// Represents the signature of a callable.
struct SignatureHelp {
@@ -761,6 +764,7 @@
}
};
json::Expr toJSON(const DocumentHighlight &DH);
+llvm::raw_ostream &operator<<(llvm::raw_ostream &, const DocumentHighlight &);
} // namespace clangd
} // namespace clang
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits