[PATCH] D66738: [clangd] Added highlighting for structured bindings.
Johan Vikström via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 28 07:44:52 PDT 2019
jvikstrom updated this revision to Diff 217652.
jvikstrom marked 6 inline comments as done.
jvikstrom added a comment.
Abandoned trying to highlight the same as the bound decl.
Reasoning: If you have a reference to a parameter we are not trying to highlight the reference as a parameter, the reference is highlighted as a variable. Don't really think bindings should be different.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66738/new/
https://reviews.llvm.org/D66738
Files:
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -431,6 +431,21 @@
assert($Variable[[x]] != $Variable[[y]]);
assert($Variable[[x]] != $Function[[f]]());
}
+ )cpp",
+ R"cpp(
+ struct $Class[[S]] {
+ $Primitive[[float]] $Field[[Value]];
+ $Class[[S]] *$Field[[Next]];
+ };
+ $Class[[S]] $Variable[[Global]][2] = {$Class[[S]](), $Class[[S]]()};
+ $Primitive[[void]] $Function[[f]]($Class[[S]] $Parameter[[P]]) {
+ $Primitive[[int]] $Variable[[A]][2] = {1,2};
+ auto [$Variable[[B1]], $Variable[[B2]]] = $Variable[[A]];
+ auto [$Variable[[G1]], $Variable[[G2]]] = $Variable[[Global]];
+ $Class[[auto]] [$Variable[[P1]], $Variable[[P2]]] = $Parameter[[P]];
+ // Highlights references to BindingDecls.
+ $Variable[[B1]]++;
+ }
)cpp"};
for (const auto &TestCase : TestCases) {
checkHighlightings(TestCase);
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===================================================================
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -229,6 +229,10 @@
addToken(Loc, HighlightingKind::Variable);
return;
}
+ if (isa<BindingDecl>(D)) {
+ addToken(Loc, HighlightingKind::Variable);
+ return;
+ }
if (isa<FunctionDecl>(D)) {
addToken(Loc, HighlightingKind::Function);
return;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66738.217652.patch
Type: text/x-patch
Size: 1685 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190828/59a21202/attachment.bin>
More information about the cfe-commits
mailing list