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

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 10 08:04:14 PDT 2019


hokein added inline comments.


================
Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:41
+    // namespace.
+    if (const auto UD = dyn_cast<UsingDirectiveDecl>(ND)) {
+      addToken(UD->getIdentLocation(), HighlightingKind::Namespace);
----------------
nit: const auto *


================
Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:42
+    if (const auto UD = dyn_cast<UsingDirectiveDecl>(ND)) {
+      addToken(UD->getIdentLocation(), HighlightingKind::Namespace);
+    }
----------------
nit: you miss a `return`


================
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.
----------------
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`).


================
Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:247
+  case HighlightingKind::Namespace:
+    return "entity.name.type.namespace.cpp";
   case HighlightingKind::NumKinds:
----------------
I think here should be `entity.name.namespace.cpp`, vscode uses this TX scope for namespace.


================
Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:114
+    R"cpp(
+      namespace $Namespace[[abc]] {
+        namespace $Namespace[[bcd]] {
----------------
could you add a testcase for anonymous namespace?

`namespace {}`


================
Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:119
+            struct $Class[[A]] {
+              static enum class $Enum[[B]] {
+                Hi,
----------------
nit: the `static` is not needed for a type.


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