Added highlightings for namespace specifiers.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 34694 Build 34693: arc lint + arc unit
Event Timeline
clang-tools-extra/clangd/SemanticHighlighting.cpp | ||
---|---|---|
41 | nit: const auto * | |
42 | nit: you miss a return | |
73 | 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 | 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 | ||
---|---|---|
73 | 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 | Really? Because I see entity.name.type.namespace.cpp when I inspect the TM scopes for namespaces. |
clang-tools-extra/clangd/SemanticHighlighting.cpp | ||
---|---|---|
73 | 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) | |
85 | if you're just doing something and then calling base, can you make this Visit instead of Traverse? | |
129 | 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 | ||
---|---|---|
85 | 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 | ||
---|---|---|
73 | thanks for the explanation, fair enough. | |
247 | 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 *