feat(completion): mark deprecated symbols with strikethrough#414
feat(completion): mark deprecated symbols with strikethrough#41416bit-ykiko wants to merge 1 commit intomainfrom
Conversation
📝 WalkthroughWalkthroughThe changes extend the code completion system to recognize and tag deprecated declarations. The Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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 |
Check CXAvailability_Deprecated on CodeCompletionResult and set CompletionItemTag::Deprecated on the CompletionItem. Editors render this as a strikethrough on the completion label. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
558fe87 to
7c50364
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/feature/code_completion.cpp (1)
275-290:⚠️ Potential issue | 🟠 MajorPropagate deprecation when bundled overloads are merged
On Line 275, tags are set only when a new overload bucket is inserted. In the merge path (Lines 284-290), if a deprecated overload is encountered after a non-deprecated one, the bundled item can incorrectly miss
Deprecated.💡 Proposed fix
} else { auto& existing = overloads[it->second]; existing.count += 1; + if(is_deprecated) { + if(!existing.item.tags.has_value()) { + existing.item.tags = std::vector<protocol::CompletionItemTag>{}; + } + if(std::ranges::find(*existing.item.tags, + protocol::CompletionItemTag::Deprecated) == + existing.item.tags->end()) { + existing.item.tags->push_back(protocol::CompletionItemTag::Deprecated); + } + } if(*score > existing.score) { existing.score = *score; existing.item.sort_text = std::format("{}", *score); } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/feature/code_completion.cpp` around lines 275 - 290, When merging into an existing overload bucket (the branch that updates existing = overloads[it->second]), ensure deprecation is propagated: if the incoming overload's is_deprecated (or item.tags contains protocol::CompletionItemTag::Deprecated) is true then add protocol::CompletionItemTag::Deprecated to existing.item.tags (or set existing.item.tags = std::vector{...} if empty) so a later-deprecated overload won't lose the Deprecated tag; also keep the existing score/count/update logic (existing.count, existing.score, existing.item.sort_text) unchanged.
🧹 Nitpick comments (1)
tests/unit/feature/code_completion_tests.cpp (1)
195-220: Add a mixed-overload deprecation regression testThese tests cover single-candidate cases well, but they don’t validate bundled overload behavior when only one overload is deprecated. Add one case to ensure the bundled item still carries
Deprecated.🧪 Suggested test addition
+TEST_CASE(DeprecatedTagBundledOverloads) { + code_complete(R"cpp( +int foooo(int x); +[[deprecated]] int foooo(int x, int y); +int z = fo$(pos) +)cpp"); + + auto it = find_item("foooo"); + ASSERT_TRUE(it != items.end()); + ASSERT_TRUE(it->tags.has_value()); + ASSERT_TRUE(std::ranges::find(*it->tags, protocol::CompletionItemTag::Deprecated) != + it->tags->end()); +}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/unit/feature/code_completion_tests.cpp` around lines 195 - 220, Add a new TEST_CASE (e.g., MixedOverloadDeprecated) in the same file that calls code_complete with two overloaded declarations where one overload is marked [[deprecated]] and the other is not, then locate the completion item via find_item (same "foooo" name used in existing tests) and assert that the returned completion's tags (it->tags) include protocol::CompletionItemTag::Deprecated; use the existing pattern of checking items, it != items.end(), and checking it->tags.has_value() and that std::ranges::find(*it->tags, protocol::CompletionItemTag::Deprecated) != it->tags->end() so the bundled overload item is marked Deprecated when at least one overload is deprecated.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/feature/code_completion.cpp`:
- Around line 275-290: When merging into an existing overload bucket (the branch
that updates existing = overloads[it->second]), ensure deprecation is
propagated: if the incoming overload's is_deprecated (or item.tags contains
protocol::CompletionItemTag::Deprecated) is true then add
protocol::CompletionItemTag::Deprecated to existing.item.tags (or set
existing.item.tags = std::vector{...} if empty) so a later-deprecated overload
won't lose the Deprecated tag; also keep the existing score/count/update logic
(existing.count, existing.score, existing.item.sort_text) unchanged.
---
Nitpick comments:
In `@tests/unit/feature/code_completion_tests.cpp`:
- Around line 195-220: Add a new TEST_CASE (e.g., MixedOverloadDeprecated) in
the same file that calls code_complete with two overloaded declarations where
one overload is marked [[deprecated]] and the other is not, then locate the
completion item via find_item (same "foooo" name used in existing tests) and
assert that the returned completion's tags (it->tags) include
protocol::CompletionItemTag::Deprecated; use the existing pattern of checking
items, it != items.end(), and checking it->tags.has_value() and that
std::ranges::find(*it->tags, protocol::CompletionItemTag::Deprecated) !=
it->tags->end() so the bundled overload item is marked Deprecated when at least
one overload is deprecated.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 1bb99321-f820-4bbe-b3c9-3a2de986874b
📒 Files selected for processing (2)
src/feature/code_completion.cpptests/unit/feature/code_completion_tests.cpp
Summary
CXAvailability_DeprecatedonCodeCompletionResultand setCompletionItemTag::DeprecatedTest plan
DeprecatedTag—[[deprecated]]function gets the tagNotDeprecated— normal function has no Deprecated tagpixi run formatcleanStacked on #411.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests