summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/ClangdLSPServer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd/ClangdLSPServer.cpp')
-rw-r--r--clang-tools-extra/clangd/ClangdLSPServer.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index a65aab0a082..df2e3c5da69 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -11,6 +11,7 @@
#include "FormattedString.h"
#include "GlobalCompilationDatabase.h"
#include "Protocol.h"
+#include "SemanticHighlighting.h"
#include "SourceCode.h"
#include "Trace.h"
#include "URI.h"
@@ -328,6 +329,8 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
WithOffsetEncoding.emplace(kCurrentOffsetEncoding,
*NegotiatedOffsetEncoding);
+ ClangdServerOpts.SemanticHighlighting =
+ Params.capabilities.SemanticHighlighting;
if (Params.rootUri && *Params.rootUri)
ClangdServerOpts.WorkspaceRoot = Params.rootUri->file();
else if (Params.rootPath && !Params.rootPath->empty())
@@ -407,6 +410,11 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
}}}};
if (NegotiatedOffsetEncoding)
Result["offsetEncoding"] = *NegotiatedOffsetEncoding;
+ if (Params.capabilities.SemanticHighlighting)
+ Result.getObject("capabilities")
+ ->insert(
+ {"semanticHighlighting",
+ llvm::json::Object{{"scopes", getTextMateScopeLookupTable()}}});
Reply(std::move(Result));
}
@@ -927,6 +935,11 @@ void ClangdLSPServer::applyConfiguration(
reparseOpenedFiles();
}
+void ClangdLSPServer::publishSemanticHighlighting(
+ SemanticHighlightingParams Params) {
+ notify("textDocument/semanticHighlighting", Params);
+}
+
void ClangdLSPServer::publishDiagnostics(
const URIForFile &File, std::vector<clangd::Diagnostic> Diagnostics) {
// Publish diagnostics.
@@ -1063,6 +1076,13 @@ bool ClangdLSPServer::shouldRunCompletion(
return true;
}
+void ClangdLSPServer::onHighlightingsReady(
+ PathRef File, std::vector<HighlightingToken> Highlightings) {
+ publishSemanticHighlighting(
+ {{URIForFile::canonicalize(File, /*TUPath=*/File)},
+ toSemanticHighlightingInformation(Highlightings)});
+}
+
void ClangdLSPServer::onDiagnosticsReady(PathRef File,
std::vector<Diag> Diagnostics) {
auto URI = URIForFile::canonicalize(File, /*TUPath=*/File);
OpenPOWER on IntegriCloud