diff options
Diffstat (limited to 'clang-tools-extra/clangd/Protocol.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/Protocol.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp index d8369f3dcc1..bf32a969088 100644 --- a/clang-tools-extra/clangd/Protocol.cpp +++ b/clang-tools-extra/clangd/Protocol.cpp @@ -18,6 +18,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/Support/Format.h" #include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/JSON.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" @@ -222,6 +223,11 @@ bool fromJSON(const json::Value &Params, ClientCapabilities &R) { if (CodeAction->getObject("codeActionLiteralSupport")) R.CodeActionStructure = true; } + if (auto *DocumentSymbol = TextDocument->getObject("documentSymbol")) { + if (auto HierarchicalSupport = + DocumentSymbol->getBoolean("hierarchicalDocumentSymbolSupport")) + R.HierarchicalDocumentSymbol = *HierarchicalSupport; + } } if (auto *Workspace = O->getObject("workspace")) { if (auto *Symbol = Workspace->getObject("symbol")) { @@ -449,6 +455,25 @@ json::Value toJSON(const CodeAction &CA) { return std::move(CodeAction); } +llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const DocumentSymbol &S) { + return O << S.name << " - " << toJSON(S); +} + +llvm::json::Value toJSON(const DocumentSymbol &S) { + 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; + if (!S.children.empty()) + Result["children"] = S.children; + if (S.deprecated) + Result["deprecated"] = true; + return Result; +} + json::Value toJSON(const WorkspaceEdit &WE) { if (!WE.changes) return json::Object{}; |

