Skip to content

refactor(code-actions): unify quick fix providers with strategy pattern#46

Open
9romise wants to merge 2 commits intomainfrom
refactor/quick-fix
Open

refactor(code-actions): unify quick fix providers with strategy pattern#46
9romise wants to merge 2 commits intomainfrom
refactor/quick-fix

Conversation

@9romise
Copy link
Member

@9romise 9romise commented Feb 18, 2026

Unify separate providers into a single QuickFixProvider that dispatches by diagnostic code.

@9romise 9romise marked this pull request as ready for review February 18, 2026 08:08
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

📝 Walkthrough

Walkthrough

This PR refactors the code-actions architecture by consolidating separate upgrade and vulnerability code-action providers into a unified QuickFixProvider, centralising extractor entries into a dedicated index module, and removing the upgrade message prefix constant. The changes involve moving extractorEntries from active-extractor to a new extractors index file, introducing a useCodeActions composition function to manage code-action registration, replacing separate UpgradeProvider and VulnerabilityCodeActionProvider classes with a single QuickFixProvider that handles both patterns, updating the upgrade diagnostic to include a code field, and adding a module path alias for cleaner imports. Tests for the old vulnerability provider are removed in favour of unified quick-fix tests.

Possibly related PRs

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description accurately describes the changeset: unifying separate code-action providers (UpgradeProvider and VulnerabilityCodeActionProvider) into a single QuickFixProvider that uses diagnostic codes for dispatch logic.

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

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/quick-fix

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.

Copy link
Contributor

@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.

🧹 Nitpick comments (3)
src/composables/active-extractor.ts (1)

4-4: Consider using the #extractors alias for consistency.

src/providers/code-actions/index.ts (added in this same PR) imports via '#extractors', but this file still uses the relative path. Using the alias here would align both consumers.

♻️ Suggested change
-import { extractorEntries } from '../extractors'
+import { extractorEntries } from '#extractors'
tests/code-actions/quick-fix.test.ts (1)

26-59: Consider adding negative/edge-case tests for the guard paths.

The three existing scenarios cover all happy-path branches. The early-return guards in QuickFixProvider (unknown code, no pattern match) are not exercised. Adding a couple of targeted tests would fully document expected no-op behaviour:

♻️ Suggested additions
+  it('unknown diagnostic code returns no actions', () => {
+    const diagnostic = createDiagnostic('unrelated', 'some message')
+    expect(provideCodeActions([diagnostic])).toHaveLength(0)
+  })
+
+  it('known code with non-matching message returns no actions', () => {
+    const diagnostic = createDiagnostic('upgrade', 'No version info here')
+    expect(provideCodeActions([diagnostic])).toHaveLength(0)
+  })
src/index.ts (1)

17-41: Optional: consider extracting hover and completion registrations into composables for consistency.

The new useCodeActions() pattern is cleaner than inline watchEffect blocks. The hover (lines 17–26) and completion (Lines 28–41) registrations follow the old pattern and could be similarly extracted (e.g. useHover(), useCompletion()) for uniformity. Not blocking — just a thought for a follow-up.

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