This is an archive of the discontinued LLVM Phabricator instance.

[clangd] [WIP] [Not ready for review] Semantic highlighting
AbandonedPublic

Authored by nridge on May 12 2019, 8:53 PM.

Details

Reviewers
None
Summary

Done:

  • Basic plumbing
  • Encoding of semantic highlighting tokens into the protocol format
  • Computation of (most) semantic highlightings given an AST
  • Unit test suite (for implemented highlightings)

Remains to be done:

  • Highlightings for macro definitions and macro invocations
  • Some special highlightings like overloaded operators
  • End-to-end test to exercise the protocol bits

Event Timeline

nridge created this revision.May 12 2019, 8:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2019, 8:53 PM
nridge planned changes to this revision.May 12 2019, 8:53 PM
nridge updated this revision to Diff 199202.May 12 2019, 8:54 PM

Add [clangd] to title

nridge planned changes to this revision.May 12 2019, 8:54 PM
nridge retitled this revision from [WIP] [Not ready for review] Semantic highlighting to [clangd] [WIP] [Not ready for review] Semantic highlighting.May 12 2019, 8:55 PM
nik added a subscriber: nik.Jun 21 2019, 12:25 AM
nik added a comment.Jun 21 2019, 1:50 AM

Some general notes regarding the current state of this patch as I was testing it with a language client:

  • It still applies for current trunk, except for a *Tests* file.
  • Note that a VersionedTextDocumentIdentifier has to be used, e.g. a "version" must be included in the response. This helped to get it working for now (not a proper fix):
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -79,11 +79,11 @@ llvm::json::Value toJSON(const URIForFile &U) { return U.uri(); }
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const URIForFile &U) {
   return OS << U.uri();
 }
 
 llvm::json::Value toJSON(const TextDocumentIdentifier &R) {
-  return llvm::json::Object{{"uri", R.uri}};
+  return llvm::json::Object{{"uri", R.uri}, {"version", nullptr}};
 }
 
 bool fromJSON(const llvm::json::Value &Params, TextDocumentIdentifier &R) {
   llvm::json::ObjectMapper O(Params);
   return O && O.map("uri", R.uri);
nridge abandoned this revision.Dec 5 2019, 12:27 PM

Abandoning as all of the functionality in this prototype is now present in mainline (except for the ability to color declarations differently from references, which is blocked on a spec change as discussed in D66990).