[clangd] Add debug printers for basic protocol types. NFC
llvm-svn: 321161
diff --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp
index 2b9bd8e..f6fc9af 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -59,6 +59,10 @@
json::Expr toJSON(const URI &U) { return U.uri; }
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const URI &U) {
+ return OS << U.uri;
+}
+
bool fromJSON(const json::Expr &Params, TextDocumentIdentifier &R) {
json::ObjectMapper O(Params);
return O && O.map("uri", R.uri);
@@ -76,6 +80,10 @@
};
}
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Position &P) {
+ return OS << P.line << ':' << P.character;
+}
+
bool fromJSON(const json::Expr &Params, Range &R) {
json::ObjectMapper O(Params);
return O && O.map("start", R.start) && O.map("end", R.end);
@@ -88,6 +96,10 @@
};
}
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Range &R) {
+ return OS << R.start << '-' << R.end;
+}
+
json::Expr toJSON(const Location &P) {
return json::obj{
{"uri", P.uri},
@@ -95,6 +107,10 @@
};
}
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Location &L) {
+ return OS << L.range << '@' << L.uri;
+}
+
bool fromJSON(const json::Expr &Params, TextDocumentItem &R) {
json::ObjectMapper O(Params);
return O && O.map("uri", R.uri) && O.map("languageId", R.languageId) &&