DanTup ยท GitHub

Merged

Merged

Conversation

@DanTup

Pull request overview

This PR fixes issue #5913 where the "Add 'package' to dependencies" quickfix was not showing when a dev_dependency was used in a public file (lib/ or bin/). The fix ensures that when a package exists only in dev_dependencies but is imported from lib/ or bin/, the quickfix offers to add it to dependencies (and doesn't offer the dev_dependencies option, since that would be incorrect for public files).

Changes:

  • Modified the dependency filtering logic to exclude dev_dependencies when determining if a package already exists in the pubspec, for files in lib/ or bin/
  • Adjusted the code action creation to only offer the dev_dependencies option for files outside lib/ and bin/
  • Added test coverage to verify that the fix works correctly for packages listed only in dev_dependencies when imported from lib/

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/extension/providers/add_dependency_code_action_provider.ts Added logic to determine whether to include dev_dependencies based on file location (lib/bin vs other), and updated filtering and action creation accordingly
src/test/dart/pub/add.test.ts Added test case to verify that quickfix correctly offers only "Add to dependencies" (not "Add to dev_dependencies") when a dev_dependency is used in lib/

๐Ÿ’ก Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov

Codecov Report

โŒ Patch coverage is 37.50000% with 5 lines in your changes missing coverage. Please review.
โœ… Project coverage is 67.60%. Comparing base (4b88acb) to head (011bcd5).

Files with missing lines Patch % Lines
...n/providers/add_dependency_code_action_provider.ts 37.50% 3 Missing and 2 partials โš ๏ธ
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5914      +/-   ##
==========================================
- Coverage   67.64%   67.60%   -0.04%     
==========================================
  Files         169      169
  Lines       12979    12980       +1
  Branches     2566     2567       +1
==========================================
- Hits         8779     8775       -4     
- Misses       3745     3749       +4     
- Partials      455      456       +1     

โ˜” View full report in Codecov by Sentry.
๐Ÿ“ข Have feedback on the report? Share it here.

๐Ÿš€ New features to boost your workflow:
  • โ„๏ธ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • ๐Ÿ“ฆ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DanTup

@DanTup

@DanTup

DanTup deleted the fix-add-dep-quickfix branch

February 19, 2026 15:03

Read the original on github.com โ†—