[PATCH] D64492: [clangd] Added highlightings for namespace specifiers.

Johan Vikström via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 10 10:01:37 PDT 2019


jvikstrom added inline comments.


================
Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:73
     // This check is for not getting two entries when there are anonymous
     // structs. It also makes us not highlight namespace qualifiers. For
     // elaborated types the actual type is highlighted as an inner TypeLoc.
----------------
hokein wrote:
> this comment is stale with this patch, now we are highlighting namespace, it seems more natural to do it here, we can get a NestedNameSpecifierLoc from an `ElaboratedTypeLoc ` (so that we don't need the `TraverseNestedNameSpecifierLoc`).
Doing it in VisitTypeLoc means that we fail on this testcase:

```
      namespace $Namespace[[aa]] {
        namespace $Namespace[[bb]] {
          struct $Class[[A]] {};
        }
      }
      $Namespace[[aa]]::$Namespace[[bb]]::$Class[[A]] $Variable[[a]];
```

It can't detect the `bb` namespace qualifier in `aa::bb::A a;`.

Maybe there is some way of solving this without `TraverseNestedNameSpecifierLoc` that I am not aware of?
Also don't know how I'd get a `NestedNameSpecifierLoc` from an `ElaboratedTypeLoc`.


================
Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:247
+  case HighlightingKind::Namespace:
+    return "entity.name.type.namespace.cpp";
   case HighlightingKind::NumKinds:
----------------
hokein wrote:
> I think here should be `entity.name.namespace.cpp`, vscode uses this TX scope for namespace.
Really? Because I see `entity.name.type.namespace.cpp` when I inspect the TM scopes for namespaces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64492





More information about the cfe-commits mailing list