[PATCH] D64137: [clangd] Add a hidden tweak to annotate all highlighting tokens of the file.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 4 00:58:53 PDT 2019


sammccall added inline comments.


================
Comment at: clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp:15
+
+llvm::StringRef highlightingKindToString(HighlightingKind Kind) {
+  switch (Kind) {
----------------
it would be nice to use the textmate class name rather than an arbitrary string here, it saves a level of indirection when verifying/debugging behavior


================
Comment at: clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp:48
+Expected<Tweak::Effect> AnnotateHighlightings::apply(const Selection &Inputs) {
+  auto HighlightingTokens = getSemanticHighlightings(Inputs.AST);
+  auto &SM = Inputs.AST.getSourceManager();
----------------
These operations are contextual, it would be nice to root at the selected node.

You should be able to do (approximately) this by walking up to the next decl and using it as the traversal scope - don't forget to reset it afterwards!

(This is a bit hacky and invalidates the parent map, but it's a debug tweak so it should be OK)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64137/new/

https://reviews.llvm.org/D64137





More information about the cfe-commits mailing list