Added highlightings for namespace specifiers.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
clang-tools-extra/clangd/SemanticHighlighting.cpp | ||
---|---|---|
41 ↗ | (On Diff #208956) | nit: const auto * |
42 ↗ | (On Diff #208956) | nit: you miss a return |
73 ↗ | (On Diff #208956) | 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). |
247 ↗ | (On Diff #208956) | I think here should be entity.name.namespace.cpp, vscode uses this TX scope for namespace. |
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp | ||
114 ↗ | (On Diff #208956) | could you add a testcase for anonymous namespace? namespace {} |
119 ↗ | (On Diff #208956) | nit: the static is not needed for a type. |
clang-tools-extra/clangd/SemanticHighlighting.cpp | ||
---|---|---|
73 ↗ | (On Diff #208956) | 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? |
247 ↗ | (On Diff #208956) | Really? Because I see entity.name.type.namespace.cpp when I inspect the TM scopes for namespaces. |
clang-tools-extra/clangd/SemanticHighlighting.cpp | ||
---|---|---|
87 ↗ | (On Diff #208998) | if you're just doing something and then calling base, can you make this Visit instead of Traverse? |
131 ↗ | (On Diff #208998) | this doesn't fit with the contract of this addToken() function, which should only highlight the provided token. Instead, can you call this from VisitNamespaceAliasDecl? |
73 ↗ | (On Diff #208956) | TraverseNestedNameSpecifierLoc is the right way to deal with namespaces-as-prefixes, I think it's best to follow that consistently. (For namespaces not-as-prefixes, you've got namespacealiasdecl, namespacedecl, using-directives... I think that's everything) |
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp | ||
86 ↗ | (On Diff #208998) | can you add a case where we spell with leading colons e.g. ::abc::A |
Moved alias target namespace add token to another function and added testcase for global namespace specifier.
clang-tools-extra/clangd/SemanticHighlighting.cpp | ||
---|---|---|
87 ↗ | (On Diff #208998) | NestedNameSpecifierLoc does not have a visit method for some reason. It only has a traverse method and this seems to be the way people get nested namespaces from what I can tell. (Maybe a Visit method is something that should be added to the RecursiveASTVisitor, but I wouldn't do that in this patch). |
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp | ||
86 ↗ | (On Diff #208998) | Added it in the case that focuses on namespaces further down. |
looks good from my side, just a comment for the TM scope name.
clang-tools-extra/clangd/SemanticHighlighting.cpp | ||
---|---|---|
73 ↗ | (On Diff #208956) | thanks for the explanation, fair enough. |
247 ↗ | (On Diff #208956) | that's weird, TM inspector told me it was entity.name.namespace.cpp, I can also find it in https://github.com/microsoft/vscode/blob/master/extensions/cpp/syntaxes/cpp.tmLanguage.json#L1709 |