Added highlightings for namespace specifiers.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 34740 Build 34739: arc lint + arc unit
Event Timeline
| clang-tools-extra/clangd/SemanticHighlighting.cpp | ||
|---|---|---|
| 47 | nit: const auto * | |
| 48 | nit: you miss a return | |
| 79–80 | 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). | |
| 253 | I think here should be entity.name.namespace.cpp, vscode uses this TX scope for namespace. | |
| clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp | ||
| 114 | could you add a testcase for anonymous namespace? namespace {} | |
| 119 | nit: the static is not needed for a type. | |
| clang-tools-extra/clangd/SemanticHighlighting.cpp | ||
|---|---|---|
| 79–80 | 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? | |
| 253 | Really? Because I see entity.name.type.namespace.cpp when I inspect the TM scopes for namespaces. | |
| clang-tools-extra/clangd/SemanticHighlighting.cpp | ||
|---|---|---|
| 79–80 | 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) | |
| 93 | if you're just doing something and then calling base, can you make this Visit instead of Traverse? | |
| 137 | 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? | |
| clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp | ||
| 86 | 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 | ||
|---|---|---|
| 93 | 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 | 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 | ||
|---|---|---|
| 79–80 | thanks for the explanation, fair enough. | |
| 253 | 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 | |
nit: const auto *