summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/Protocol.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd/Protocol.cpp')
-rw-r--r--clang-tools-extra/clangd/Protocol.cpp309
1 files changed, 159 insertions, 150 deletions
diff --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp
index fd94ca7d4bc..cf3c6fd367a 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -24,14 +24,14 @@
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
-using namespace llvm;
namespace clang {
namespace clangd {
char LSPError::ID;
-URIForFile URIForFile::canonicalize(StringRef AbsPath, StringRef TUPath) {
- assert(sys::path::is_absolute(AbsPath) && "the path is relative");
+URIForFile URIForFile::canonicalize(llvm::StringRef AbsPath,
+ llvm::StringRef TUPath) {
+ assert(llvm::sys::path::is_absolute(AbsPath) && "the path is relative");
auto Resolved = URI::resolvePath(AbsPath, TUPath);
if (!Resolved) {
elog("URIForFile: failed to resolve path {0} with TU path {1}: "
@@ -42,14 +42,15 @@ URIForFile URIForFile::canonicalize(StringRef AbsPath, StringRef TUPath) {
return URIForFile(std::move(*Resolved));
}
-Expected<URIForFile> URIForFile::fromURI(const URI &U, StringRef HintPath) {
+llvm::Expected<URIForFile> URIForFile::fromURI(const URI &U,
+ llvm::StringRef HintPath) {
auto Resolved = URI::resolve(U, HintPath);
if (!Resolved)
return Resolved.takeError();
return URIForFile(std::move(*Resolved));
}
-bool fromJSON(const json::Value &E, URIForFile &R) {
+bool fromJSON(const llvm::json::Value &E, URIForFile &R) {
if (auto S = E.getAsString()) {
auto Parsed = URI::parse(*S);
if (!Parsed) {
@@ -73,89 +74,89 @@ bool fromJSON(const json::Value &E, URIForFile &R) {
return false;
}
-json::Value toJSON(const URIForFile &U) { return U.uri(); }
+llvm::json::Value toJSON(const URIForFile &U) { return U.uri(); }
-raw_ostream &operator<<(raw_ostream &OS, const URIForFile &U) {
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const URIForFile &U) {
return OS << U.uri();
}
-json::Value toJSON(const TextDocumentIdentifier &R) {
- return json::Object{{"uri", R.uri}};
+llvm::json::Value toJSON(const TextDocumentIdentifier &R) {
+ return llvm::json::Object{{"uri", R.uri}};
}
-bool fromJSON(const json::Value &Params, TextDocumentIdentifier &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, TextDocumentIdentifier &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("uri", R.uri);
}
-bool fromJSON(const json::Value &Params, Position &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, Position &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("line", R.line) && O.map("character", R.character);
}
-json::Value toJSON(const Position &P) {
- return json::Object{
+llvm::json::Value toJSON(const Position &P) {
+ return llvm::json::Object{
{"line", P.line},
{"character", P.character},
};
}
-raw_ostream &operator<<(raw_ostream &OS, const Position &P) {
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Position &P) {
return OS << P.line << ':' << P.character;
}
-bool fromJSON(const json::Value &Params, Range &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, Range &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("start", R.start) && O.map("end", R.end);
}
-json::Value toJSON(const Range &P) {
- return json::Object{
+llvm::json::Value toJSON(const Range &P) {
+ return llvm::json::Object{
{"start", P.start},
{"end", P.end},
};
}
-raw_ostream &operator<<(raw_ostream &OS, const Range &R) {
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Range &R) {
return OS << R.start << '-' << R.end;
}
-json::Value toJSON(const Location &P) {
- return json::Object{
+llvm::json::Value toJSON(const Location &P) {
+ return llvm::json::Object{
{"uri", P.uri},
{"range", P.range},
};
}
-raw_ostream &operator<<(raw_ostream &OS, const Location &L) {
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Location &L) {
return OS << L.range << '@' << L.uri;
}
-bool fromJSON(const json::Value &Params, TextDocumentItem &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, TextDocumentItem &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("uri", R.uri) && O.map("languageId", R.languageId) &&
O.map("version", R.version) && O.map("text", R.text);
}
-bool fromJSON(const json::Value &Params, TextEdit &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, TextEdit &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("range", R.range) && O.map("newText", R.newText);
}
-json::Value toJSON(const TextEdit &P) {
- return json::Object{
+llvm::json::Value toJSON(const TextEdit &P) {
+ return llvm::json::Object{
{"range", P.range},
{"newText", P.newText},
};
}
-raw_ostream &operator<<(raw_ostream &OS, const TextEdit &TE) {
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const TextEdit &TE) {
OS << TE.range << " => \"";
- printEscapedString(TE.newText, OS);
+ llvm::printEscapedString(TE.newText, OS);
return OS << '"';
}
-bool fromJSON(const json::Value &E, TraceLevel &Out) {
+bool fromJSON(const llvm::json::Value &E, TraceLevel &Out) {
if (auto S = E.getAsString()) {
if (*S == "off") {
Out = TraceLevel::Off;
@@ -171,7 +172,7 @@ bool fromJSON(const json::Value &E, TraceLevel &Out) {
return false;
}
-bool fromJSON(const json::Value &E, SymbolKind &Out) {
+bool fromJSON(const llvm::json::Value &E, SymbolKind &Out) {
if (auto T = E.getAsInteger()) {
if (*T < static_cast<int>(SymbolKind::File) ||
*T > static_cast<int>(SymbolKind::TypeParameter))
@@ -182,7 +183,7 @@ bool fromJSON(const json::Value &E, SymbolKind &Out) {
return false;
}
-bool fromJSON(const json::Value &E, SymbolKindBitset &Out) {
+bool fromJSON(const llvm::json::Value &E, SymbolKindBitset &Out) {
if (auto *A = E.getAsArray()) {
for (size_t I = 0; I < A->size(); ++I) {
SymbolKind KindOut;
@@ -212,8 +213,8 @@ SymbolKind adjustKindToCapability(SymbolKind Kind,
}
}
-bool fromJSON(const json::Value &Params, ClientCapabilities &R) {
- const json::Object *O = Params.getAsObject();
+bool fromJSON(const llvm::json::Value &Params, ClientCapabilities &R) {
+ const llvm::json::Object *O = Params.getAsObject();
if (!O)
return false;
if (auto *TextDocument = O->getObject("textDocument")) {
@@ -260,8 +261,8 @@ bool fromJSON(const json::Value &Params, ClientCapabilities &R) {
return true;
}
-bool fromJSON(const json::Value &Params, InitializeParams &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, InitializeParams &R) {
+ llvm::json::ObjectMapper O(Params);
if (!O)
return false;
// We deliberately don't fail if we can't parse individual fields.
@@ -275,24 +276,24 @@ bool fromJSON(const json::Value &Params, InitializeParams &R) {
return true;
}
-bool fromJSON(const json::Value &Params, DidOpenTextDocumentParams &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, DidOpenTextDocumentParams &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("textDocument", R.textDocument);
}
-bool fromJSON(const json::Value &Params, DidCloseTextDocumentParams &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, DidCloseTextDocumentParams &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("textDocument", R.textDocument);
}
-bool fromJSON(const json::Value &Params, DidChangeTextDocumentParams &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, DidChangeTextDocumentParams &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("textDocument", R.textDocument) &&
O.map("contentChanges", R.contentChanges) &&
O.map("wantDiagnostics", R.wantDiagnostics);
}
-bool fromJSON(const json::Value &E, FileChangeType &Out) {
+bool fromJSON(const llvm::json::Value &E, FileChangeType &Out) {
if (auto T = E.getAsInteger()) {
if (*T < static_cast<int>(FileChangeType::Created) ||
*T > static_cast<int>(FileChangeType::Deleted))
@@ -303,61 +304,64 @@ bool fromJSON(const json::Value &E, FileChangeType &Out) {
return false;
}
-bool fromJSON(const json::Value &Params, FileEvent &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, FileEvent &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("uri", R.uri) && O.map("type", R.type);
}
-bool fromJSON(const json::Value &Params, DidChangeWatchedFilesParams &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, DidChangeWatchedFilesParams &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("changes", R.changes);
}
-bool fromJSON(const json::Value &Params, TextDocumentContentChangeEvent &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params,
+ TextDocumentContentChangeEvent &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("range", R.range) && O.map("rangeLength", R.rangeLength) &&
O.map("text", R.text);
}
-bool fromJSON(const json::Value &Params, FormattingOptions &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, FormattingOptions &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("tabSize", R.tabSize) &&
O.map("insertSpaces", R.insertSpaces);
}
-json::Value toJSON(const FormattingOptions &P) {
- return json::Object{
+llvm::json::Value toJSON(const FormattingOptions &P) {
+ return llvm::json::Object{
{"tabSize", P.tabSize},
{"insertSpaces", P.insertSpaces},
};
}
-bool fromJSON(const json::Value &Params, DocumentRangeFormattingParams &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params,
+ DocumentRangeFormattingParams &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("textDocument", R.textDocument) &&
O.map("range", R.range) && O.map("options", R.options);
}
-bool fromJSON(const json::Value &Params, DocumentOnTypeFormattingParams &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params,
+ DocumentOnTypeFormattingParams &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("textDocument", R.textDocument) &&
O.map("position", R.position) && O.map("ch", R.ch) &&
O.map("options", R.options);
}
-bool fromJSON(const json::Value &Params, DocumentFormattingParams &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, DocumentFormattingParams &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("textDocument", R.textDocument) &&
O.map("options", R.options);
}
-bool fromJSON(const json::Value &Params, DocumentSymbolParams &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, DocumentSymbolParams &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("textDocument", R.textDocument);
}
-json::Value toJSON(const Diagnostic &D) {
- json::Object Diag{
+llvm::json::Value toJSON(const Diagnostic &D) {
+ llvm::json::Object Diag{
{"range", D.range},
{"severity", D.severity},
{"message", D.message},
@@ -369,8 +373,8 @@ json::Value toJSON(const Diagnostic &D) {
return std::move(Diag);
}
-bool fromJSON(const json::Value &Params, Diagnostic &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, Diagnostic &R) {
+ llvm::json::ObjectMapper O(Params);
if (!O || !O.map("range", R.range) || !O.map("message", R.message))
return false;
O.map("severity", R.severity);
@@ -378,12 +382,12 @@ bool fromJSON(const json::Value &Params, Diagnostic &R) {
return true;
}
-bool fromJSON(const json::Value &Params, CodeActionContext &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, CodeActionContext &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("diagnostics", R.diagnostics);
}
-raw_ostream &operator<<(raw_ostream &OS, const Diagnostic &D) {
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Diagnostic &D) {
OS << D.range << " [";
switch (D.severity) {
case 1:
@@ -405,21 +409,21 @@ raw_ostream &operator<<(raw_ostream &OS, const Diagnostic &D) {
return OS << '(' << D.severity << "): " << D.message << "]";
}
-bool fromJSON(const json::Value &Params, CodeActionParams &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, CodeActionParams &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("textDocument", R.textDocument) &&
O.map("range", R.range) && O.map("context", R.context);
}
-bool fromJSON(const json::Value &Params, WorkspaceEdit &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, WorkspaceEdit &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("changes", R.changes);
}
-const StringLiteral ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND =
+const llvm::StringLiteral ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND =
"clangd.applyFix";
-bool fromJSON(const json::Value &Params, ExecuteCommandParams &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, ExecuteCommandParams &R) {
+ llvm::json::ObjectMapper O(Params);
if (!O || !O.map("command", R.command))
return false;
@@ -431,8 +435,8 @@ bool fromJSON(const json::Value &Params, ExecuteCommandParams &R) {
return false; // Unrecognized command.
}
-json::Value toJSON(const SymbolInformation &P) {
- return json::Object{
+llvm::json::Value toJSON(const SymbolInformation &P) {
+ return llvm::json::Object{
{"name", P.name},
{"kind", static_cast<int>(P.kind)},
{"location", P.location},
@@ -440,7 +444,8 @@ json::Value toJSON(const SymbolInformation &P) {
};
}
-raw_ostream &operator<<(raw_ostream &O, const SymbolInformation &SI) {
+llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
+ const SymbolInformation &SI) {
O << SI.containerName << "::" << SI.name << " - " << toJSON(SI);
return O;
}
@@ -451,10 +456,10 @@ bool operator==(const SymbolDetails &LHS, const SymbolDetails &RHS) {
}
llvm::json::Value toJSON(const SymbolDetails &P) {
- json::Object result{{"name", llvm::json::Value(nullptr)},
- {"containerName", llvm::json::Value(nullptr)},
- {"usr", llvm::json::Value(nullptr)},
- {"id", llvm::json::Value(nullptr)}};
+ llvm::json::Object result{{"name", llvm::json::Value(nullptr)},
+ {"containerName", llvm::json::Value(nullptr)},
+ {"usr", llvm::json::Value(nullptr)},
+ {"id", llvm::json::Value(nullptr)}};
if (!P.name.empty())
result["name"] = P.name;
@@ -469,13 +474,13 @@ llvm::json::Value toJSON(const SymbolDetails &P) {
result["id"] = P.ID.getValue().str();
// Older clang cannot compile 'return Result', even though it is legal.
- return json::Value(std::move(result));
+ return llvm::json::Value(std::move(result));
}
llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const SymbolDetails &S) {
if (!S.containerName.empty()) {
O << S.containerName;
- StringRef ContNameRef;
+ llvm::StringRef ContNameRef;
if (!ContNameRef.endswith("::")) {
O << " ";
}
@@ -484,26 +489,26 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const SymbolDetails &S) {
return O;
}
-bool fromJSON(const json::Value &Params, WorkspaceSymbolParams &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, WorkspaceSymbolParams &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("query", R.query);
}
-json::Value toJSON(const Command &C) {
- auto Cmd = json::Object{{"title", C.title}, {"command", C.command}};
+llvm::json::Value toJSON(const Command &C) {
+ auto Cmd = llvm::json::Object{{"title", C.title}, {"command", C.command}};
if (C.workspaceEdit)
Cmd["arguments"] = {*C.workspaceEdit};
return std::move(Cmd);
}
-const StringLiteral CodeAction::QUICKFIX_KIND = "quickfix";
+const llvm::StringLiteral CodeAction::QUICKFIX_KIND = "quickfix";
-json::Value toJSON(const CodeAction &CA) {
- auto CodeAction = json::Object{{"title", CA.title}};
+llvm::json::Value toJSON(const CodeAction &CA) {
+ auto CodeAction = llvm::json::Object{{"title", CA.title}};
if (CA.kind)
CodeAction["kind"] = *CA.kind;
if (CA.diagnostics)
- CodeAction["diagnostics"] = json::Array(*CA.diagnostics);
+ CodeAction["diagnostics"] = llvm::json::Array(*CA.diagnostics);
if (CA.edit)
CodeAction["edit"] = *CA.edit;
if (CA.command)
@@ -511,15 +516,15 @@ json::Value toJSON(const CodeAction &CA) {
return std::move(CodeAction);
}
-raw_ostream &operator<<(raw_ostream &O, const DocumentSymbol &S) {
+llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const DocumentSymbol &S) {
return O << S.name << " - " << toJSON(S);
}
-json::Value toJSON(const DocumentSymbol &S) {
- json::Object Result{{"name", S.name},
- {"kind", static_cast<int>(S.kind)},
- {"range", S.range},
- {"selectionRange", S.selectionRange}};
+llvm::json::Value toJSON(const DocumentSymbol &S) {
+ llvm::json::Object Result{{"name", S.name},
+ {"kind", static_cast<int>(S.kind)},
+ {"range", S.range},
+ {"selectionRange", S.selectionRange}};
if (!S.detail.empty())
Result["detail"] = S.detail;
@@ -528,30 +533,30 @@ json::Value toJSON(const DocumentSymbol &S) {
if (S.deprecated)
Result["deprecated"] = true;
// Older gcc cannot compile 'return Result', even though it is legal.
- return json::Value(std::move(Result));
+ return llvm::json::Value(std::move(Result));
}
-json::Value toJSON(const WorkspaceEdit &WE) {
+llvm::json::Value toJSON(const WorkspaceEdit &WE) {
if (!WE.changes)
- return json::Object{};
- json::Object FileChanges;
+ return llvm::json::Object{};
+ llvm::json::Object FileChanges;
for (auto &Change : *WE.changes)
- FileChanges[Change.first] = json::Array(Change.second);
- return json::Object{{"changes", std::move(FileChanges)}};
+ FileChanges[Change.first] = llvm::json::Array(Change.second);
+ return llvm::json::Object{{"changes", std::move(FileChanges)}};
}
-json::Value toJSON(const ApplyWorkspaceEditParams &Params) {
- return json::Object{{"edit", Params.edit}};
+llvm::json::Value toJSON(const ApplyWorkspaceEditParams &Params) {
+ return llvm::json::Object{{"edit", Params.edit}};
}
-bool fromJSON(const json::Value &Params, TextDocumentPositionParams &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, TextDocumentPositionParams &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("textDocument", R.textDocument) &&
O.map("position", R.position);
}
bool fromJSON(const llvm::json::Value &Params, CompletionContext &R) {
- json::ObjectMapper O(Params);
+ llvm::json::ObjectMapper O(Params);
if (!O)
return false;
@@ -573,7 +578,7 @@ bool fromJSON(const llvm::json::Value &Params, CompletionParams &R) {
return true;
}
-static StringRef toTextKind(MarkupKind Kind) {
+static llvm::StringRef toTextKind(MarkupKind Kind) {
switch (Kind) {
case MarkupKind::PlainText:
return "plaintext";
@@ -583,18 +588,18 @@ static StringRef toTextKind(MarkupKind Kind) {
llvm_unreachable("Invalid MarkupKind");
}
-json::Value toJSON(const MarkupContent &MC) {
+llvm::json::Value toJSON(const MarkupContent &MC) {
if (MC.value.empty())
return nullptr;
- return json::Object{
+ return llvm::json::Object{
{"kind", toTextKind(MC.kind)},
{"value", MC.value},
};
}
-json::Value toJSON(const Hover &H) {
- json::Object Result{{"contents", toJSON(H.contents)}};
+llvm::json::Value toJSON(const Hover &H) {
+ llvm::json::Object Result{{"contents", toJSON(H.contents)}};
if (H.range.hasValue())
Result["range"] = toJSON(*H.range);
@@ -602,7 +607,7 @@ json::Value toJSON(const Hover &H) {
return std::move(Result);
}
-bool fromJSON(const json::Value &E, CompletionItemKind &Out) {
+bool fromJSON(const llvm::json::Value &E, CompletionItemKind &Out) {
if (auto T = E.getAsInteger()) {
if (*T < static_cast<int>(CompletionItemKind::Text) ||
*T > static_cast<int>(CompletionItemKind::TypeParameter))
@@ -635,7 +640,7 @@ adjustKindToCapability(CompletionItemKind Kind,
}
}
-bool fromJSON(const json::Value &E, CompletionItemKindBitset &Out) {
+bool fromJSON(const llvm::json::Value &E, CompletionItemKindBitset &Out) {
if (auto *A = E.getAsArray()) {
for (size_t I = 0; I < A->size(); ++I) {
CompletionItemKind KindOut;
@@ -647,9 +652,9 @@ bool fromJSON(const json::Value &E, CompletionItemKindBitset &Out) {
return false;
}
-json::Value toJSON(const CompletionItem &CI) {
+llvm::json::Value toJSON(const CompletionItem &CI) {
assert(!CI.label.empty() && "completion item label is required");
- json::Object Result{{"label", CI.label}};
+ llvm::json::Object Result{{"label", CI.label}};
if (CI.kind != CompletionItemKind::Missing)
Result["kind"] = static_cast<int>(CI.kind);
if (!CI.detail.empty())
@@ -667,13 +672,13 @@ json::Value toJSON(const CompletionItem &CI) {
if (CI.textEdit)
Result["textEdit"] = *CI.textEdit;
if (!CI.additionalTextEdits.empty())
- Result["additionalTextEdits"] = json::Array(CI.additionalTextEdits);
+ Result["additionalTextEdits"] = llvm::json::Array(CI.additionalTextEdits);
if (CI.deprecated)
Result["deprecated"] = CI.deprecated;
return std::move(Result);
}
-raw_ostream &operator<<(raw_ostream &O, const CompletionItem &I) {
+llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const CompletionItem &I) {
O << I.label << " - " << toJSON(I);
return O;
}
@@ -683,70 +688,72 @@ bool operator<(const CompletionItem &L, const CompletionItem &R) {
(R.sortText.empty() ? R.label : R.sortText);
}
-json::Value toJSON(const CompletionList &L) {
- return json::Object{
+llvm::json::Value toJSON(const CompletionList &L) {
+ return llvm::json::Object{
{"isIncomplete", L.isIncomplete},
- {"items", json::Array(L.items)},
+ {"items", llvm::json::Array(L.items)},
};
}
-json::Value toJSON(const ParameterInformation &PI) {
+llvm::json::Value toJSON(const ParameterInformation &PI) {
assert(!PI.label.empty() && "parameter information label is required");
- json::Object Result{{"label", PI.label}};
+ llvm::json::Object Result{{"label", PI.label}};
if (!PI.documentation.empty())
Result["documentation"] = PI.documentation;
return std::move(Result);
}
-json::Value toJSON(const SignatureInformation &SI) {
+llvm::json::Value toJSON(const SignatureInformation &SI) {
assert(!SI.label.empty() && "signature information label is required");
- json::Object Result{
+ llvm::json::Object Result{
{"label", SI.label},
- {"parameters", json::Array(SI.parameters)},
+ {"parameters", llvm::json::Array(SI.parameters)},
};
if (!SI.documentation.empty())
Result["documentation"] = SI.documentation;
return std::move(Result);
}
-raw_ostream &operator<<(raw_ostream &O, const SignatureInformation &I) {
+llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
+ const SignatureInformation &I) {
O << I.label << " - " << toJSON(I);
return O;
}
-json::Value toJSON(const SignatureHelp &SH) {
+llvm::json::Value toJSON(const SignatureHelp &SH) {
assert(SH.activeSignature >= 0 &&
"Unexpected negative value for number of active signatures.");
assert(SH.activeParameter >= 0 &&
"Unexpected negative value for active parameter index");
- return json::Object{
+ return llvm::json::Object{
{"activeSignature", SH.activeSignature},
{"activeParameter", SH.activeParameter},
- {"signatures", json::Array(SH.signatures)},
+ {"signatures", llvm::json::Array(SH.signatures)},
};
}
-bool fromJSON(const json::Value &Params, RenameParams &R) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, RenameParams &R) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("textDocument", R.textDocument) &&
O.map("position", R.position) && O.map("newName", R.newName);
}
-json::Value toJSON(const DocumentHighlight &DH) {
- return json::Object{
+llvm::json::Value toJSON(const DocumentHighlight &DH) {
+ return llvm::json::Object{
{"range", toJSON(DH.range)},
{"kind", static_cast<int>(DH.kind)},
};
}
llvm::json::Value toJSON(const FileStatus &FStatus) {
- return json::Object{
+ return llvm::json::Object{
{"uri", FStatus.uri},
{"state", FStatus.state},
};
}
-raw_ostream &operator<<(raw_ostream &O, const DocumentHighlight &V) {
+llvm::raw_ostream &operator<<(llvm::raw_ostream &O,
+ const DocumentHighlight &V) {
O << V.range;
if (V.kind == DocumentHighlightKind::Read)
O << "(r)";
@@ -755,27 +762,29 @@ raw_ostream &operator<<(raw_ostream &O, const DocumentHighlight &V) {
return O;
}
-bool fromJSON(const json::Value &Params, DidChangeConfigurationParams &CCP) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params,
+ DidChangeConfigurationParams &CCP) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("settings", CCP.settings);
}
-bool fromJSON(const json::Value &Params, ClangdCompileCommand &CDbUpdate) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params,
+ ClangdCompileCommand &CDbUpdate) {
+ llvm::json::ObjectMapper O(Params);
return O && O.map("workingDirectory", CDbUpdate.workingDirectory) &&
O.map("compilationCommand", CDbUpdate.compilationCommand);
}
-bool fromJSON(const json::Value &Params, ConfigurationSettings &S) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, ConfigurationSettings &S) {
+ llvm::json::ObjectMapper O(Params);
if (!O)
return true; // 'any' type in LSP.
O.map("compilationDatabaseChanges", S.compilationDatabaseChanges);
return true;
}
-bool fromJSON(const json::Value &Params, InitializationOptions &Opts) {
- json::ObjectMapper O(Params);
+bool fromJSON(const llvm::json::Value &Params, InitializationOptions &Opts) {
+ llvm::json::ObjectMapper O(Params);
if (!O)
return true; // 'any' type in LSP.
@@ -786,7 +795,7 @@ bool fromJSON(const json::Value &Params, InitializationOptions &Opts) {
return true;
}
-bool fromJSON(const json::Value &Params, ReferenceParams &R) {
+bool fromJSON(const llvm::json::Value &Params, ReferenceParams &R) {
TextDocumentPositionParams &Base = R;
return fromJSON(Params, Base);
}
OpenPOWER on IntegriCloud