summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/Protocol.cpp
diff options
context:
space:
mode:
authorJohan Vikstrom <jvikstrom@google.com>2019-07-04 07:53:12 +0000
committerJohan Vikstrom <jvikstrom@google.com>2019-07-04 07:53:12 +0000
commita848dab7a31d818da3d454e7a52c811d4a10fd21 (patch)
tree5d8b9a64bb8d141d432d6657a6dc3c359ae49d28 /clang-tools-extra/clangd/Protocol.cpp
parent63e62006cff71d3a00c3243067225259e7c2ea6a (diff)
downloadbcm5719-llvm-a848dab7a31d818da3d454e7a52c811d4a10fd21.tar.gz
bcm5719-llvm-a848dab7a31d818da3d454e7a52c811d4a10fd21.zip
[clangd] Emit publishSemanticHighlighting in LSP if enabled
Summary: Emit publishSemanticHighlighting in LSP if enabled Reviewers: hokein, kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63919 llvm-svn: 365111
Diffstat (limited to 'clang-tools-extra/clangd/Protocol.cpp')
-rw-r--r--clang-tools-extra/clangd/Protocol.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp
index f8becaaa361..e91271275ef 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -273,6 +273,12 @@ bool fromJSON(const llvm::json::Value &Params, ClientCapabilities &R) {
if (!O)
return false;
if (auto *TextDocument = O->getObject("textDocument")) {
+ if (auto *SemanticHighlighting =
+ TextDocument->getObject("semanticHighlightingCapabilities")) {
+ if (auto SemanticHighlightingSupport =
+ SemanticHighlighting->getBoolean("semanticHighlighting"))
+ R.SemanticHighlighting = *SemanticHighlightingSupport;
+ }
if (auto *Diagnostics = TextDocument->getObject("publishDiagnostics")) {
if (auto CategorySupport = Diagnostics->getBoolean("categorySupport"))
R.DiagnosticCategory = *CategorySupport;
@@ -1027,5 +1033,22 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, OffsetEncoding Enc) {
return OS << toString(Enc);
}
+bool operator==(const SemanticHighlightingInformation &Lhs,
+ const SemanticHighlightingInformation &Rhs) {
+ return Lhs.Line == Rhs.Line && Lhs.Tokens == Rhs.Tokens;
+}
+
+llvm::json::Value toJSON(const SemanticHighlightingInformation &Highlighting) {
+ return llvm::json::Object{{"line", Highlighting.Line},
+ {"tokens", Highlighting.Tokens}};
+}
+
+llvm::json::Value toJSON(const SemanticHighlightingParams &Highlighting) {
+ return llvm::json::Object{
+ {"textDocument", Highlighting.TextDocument},
+ {"lines", std::move(Highlighting.Lines)},
+ };
+}
+
} // namespace clangd
} // namespace clang
OpenPOWER on IntegriCloud