Repository navigation
fix(semantic-tokens): filter ineligible highlight references - #434
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR refines semantic token emission by filtering out declaration references with ineligible names. A new helper determines which declaration name kinds warrant syntax highlighting by kind, and the reference-handling path now early-returns before computing modifiers and emitting tokens for those ineligible occurrences. ChangesSemantic Token Filtering
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/unit/feature/semantic_tokens_tests.cpp (1)
285-307: Add a constructor reference case to exercise the new guard.Line 303 and Line 305 assert constructor declaration/definition tokens, but the new filter only runs for references. If
CXXConstructorNamewere accidentally removed fromcan_highlight_name, these constructor assertions would still pass. Add a constructor-call/reference assertion alongside the destructor reference.Suggested coverage addition
void use(S* value) { + (void)@ctor_ref[S](); value->@dtor_ref[~]S(); } )cpp"); @@ EXPECT_TOKEN("ctor_decl", SymbolKind::Method, declaration | special_member); EXPECT_TOKEN("dtor_decl", SymbolKind::Method, declaration | special_member); EXPECT_TOKEN("ctor_def", SymbolKind::Method, definition | special_member); + EXPECT_TOKEN("ctor_ref", SymbolKind::Method, special_member); EXPECT_TOKEN("dtor_ref", SymbolKind::Method, special_member); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/unit/feature/semantic_tokens_tests.cpp` around lines 285 - 307, Add a constructor-reference case in the ConstructorAndDestructorNamesRemainHighlighted test by inserting a constructor call annotated like new `@ctor_ref`[S](); (or equivalent call site) inside the run_utf8 sample, and then add an assertion EXPECT_TOKEN("ctor_ref", SymbolKind::Method, special_member) alongside the existing dtor_ref assertion; this ensures the new guard that runs only for references (can_highlight_name) is exercised for constructors as well. Ensure you use the same modifier_mask special_member and the unique token name "ctor_ref" so the test locates the annotation and validates the constructor reference highlighting.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/unit/feature/semantic_tokens_tests.cpp`:
- Around line 285-307: Add a constructor-reference case in the
ConstructorAndDestructorNamesRemainHighlighted test by inserting a constructor
call annotated like new `@ctor_ref`[S](); (or equivalent call site) inside the
run_utf8 sample, and then add an assertion EXPECT_TOKEN("ctor_ref",
SymbolKind::Method, special_member) alongside the existing dtor_ref assertion;
this ensures the new guard that runs only for references (can_highlight_name) is
exercised for constructors as well. Ensure you use the same modifier_mask
special_member and the unique token name "ctor_ref" so the test locates the
annotation and validates the constructor reference highlighting.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 58aa4fe0-cee0-48a2-ab29-e854b9931069
📒 Files selected for processing (5)
.gitignoresrc/feature/semantic_tokens.cppsrc/semantic/ast_utility.cppsrc/semantic/ast_utility.htests/unit/feature/semantic_tokens_tests.cpp
Add a reusable declaration-name eligibility helper that mirrors clangd's
canHighlightName, use it to suppress unsupported reference tokens in the semantic-token collector, and cover the change with focused semantic-token regression tests plus a constructor/destructor positive case.Summary by CodeRabbit
Bug Fixes
Tests