Skip to content

feat(completion): mark deprecated symbols with strikethrough#414

Open
16bit-ykiko wants to merge 1 commit intomainfrom
feat/completion-deprecated
Open

feat(completion): mark deprecated symbols with strikethrough#414
16bit-ykiko wants to merge 1 commit intomainfrom
feat/completion-deprecated

Conversation

@16bit-ykiko
Copy link
Copy Markdown
Member

@16bit-ykiko 16bit-ykiko commented Apr 9, 2026

Summary

  • Check CXAvailability_Deprecated on CodeCompletionResult and set CompletionItemTag::Deprecated
  • Editors render deprecated completions with a strikethrough on the label

Test plan

  • DeprecatedTag[[deprecated]] function gets the tag
  • NotDeprecated — normal function has no Deprecated tag
  • All 491 unit tests pass
  • pixi run format clean

Stacked on #411.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Code completion now indicates when declarations are deprecated with appropriate tags, helping users identify deprecated items at completion time.
  • Tests

    • Added unit tests validating deprecation tagging for completion items.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

📝 Walkthrough

Walkthrough

The changes extend the code completion system to recognize and tag deprecated declarations. The CodeCompletionCollector::try_add method now accepts a is_deprecated parameter, which when true, marks completion items with a Deprecated tag. Deprecated status is determined from declaration availability information.

Changes

Cohort / File(s) Summary
Deprecation Tagging Implementation
src/feature/code_completion.cpp
Extended CodeCompletionCollector::try_add with is_deprecated parameter; added logic to set CompletionItemTag::Deprecated on completion items when declarations are marked as deprecated via CXAvailability_Deprecated.
Deprecation Tests
tests/unit/feature/code_completion_tests.cpp
Added two new unit tests validating that deprecated declarations receive the Deprecated tag in completion items, and non-deprecated declarations do not.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 A deprecated flag flies high,
In completion items, for all to spy,
Old functions now marked with care,
So users know to beware!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions 'strikethrough' but the actual implementation uses CompletionItemTag::Deprecated tags, not strikethrough. The tag-based approach relies on editor rendering, not a strikethrough implementation in the code. Update the title to reflect the actual implementation: 'feat(completion): tag deprecated symbols' or 'feat(completion): mark deprecated completions with tag' would be more accurate.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/completion-deprecated

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Base automatically changed from feat/completion-improvements to main April 9, 2026 08:08
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>
@16bit-ykiko 16bit-ykiko force-pushed the feat/completion-deprecated branch from 558fe87 to 7c50364 Compare April 9, 2026 08:10
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟠 Major

Propagate 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 test

These 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

📥 Commits

Reviewing files that changed from the base of the PR and between bd238fe and 7c50364.

📒 Files selected for processing (2)
  • src/feature/code_completion.cpp
  • tests/unit/feature/code_completion_tests.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant