Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for moving symbols across packages with dart fix #48997

Closed
natebosch opened this issue May 11, 2022 · 20 comments
Closed

Add support for moving symbols across packages with dart fix #48997

natebosch opened this issue May 11, 2022 · 20 comments
Assignees
Labels
analyzer-bulk-fix analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@natebosch
Copy link
Member

Possibly a duplicate of #44892, or may also be considered an extension.

We'd like to move some members across packages, and stop exporting others. The user visible changes is that where they previously had a single import to package:test/test.dart they will now also need a dependency on package:matcher/expect.dart as well as an extra pubspec dependency.

If we can't target the diagnostic about the undefined name for the fix we would be OK with a migration where we mark the exports as deprecated for a while so that the fixes can be applied. We'd need support for deprecating exports in that case. #23067

@natebosch natebosch added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-data-driven-fixes labels May 11, 2022
@pq pq added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug labels May 11, 2022
@bwilkerson
Copy link
Member

@pq @keertip

@devoncarew
Copy link
Member

devoncarew commented Jun 1, 2022

Do we know who the owner for this item is? We'd like to ship support for this - for tooling to help us roll out the new package:checks - for the next stable SDK release.

@bwilkerson
Copy link
Member

@pq and @keertip are actively working on adding this support. We now support the case where the old export of expect has been removed, but not the case where the export has been marked as deprecated. The reason for that is the issue that was recently linked to this issue by @pq.

@devoncarew
Copy link
Member

Ah, great to hear! I didn't know this was in progress.

@pq
Copy link
Member

pq commented Jun 1, 2022

Yeah. #23067 is I think the blocker for @natebosch's use case.

@pq pq self-assigned this Jun 1, 2022
copybara-service bot pushed a commit that referenced this issue Jun 6, 2022
See: #48997

Change-Id: Iad16b9eae0523bc4bc14537af642b05efa75b6f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246663
Commit-Queue: Phil Quitslund <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 8, 2022
This reverts commit 3290d7a.

Reason for revert: flutter engine breakage (flutter/flutter#105641)

Original change's description:
> [data driven] support moving symbols across packages
>
> See: #48997
>
> Change-Id: Iad16b9eae0523bc4bc14537af642b05efa75b6f7
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246663
> Commit-Queue: Phil Quitslund <[email protected]>
> Reviewed-by: Brian Wilkerson <[email protected]>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I4a83d50497d6208b7f518ca1b381ece3aab192ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247606
Reviewed-by: Siva Annamalai <[email protected]>
Reviewed-by: Keerti Parthasarathy <[email protected]>
Commit-Queue: Phil Quitslund <[email protected]>
Reviewed-by: Phil Quitslund <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 13, 2022
This reverts commit f111a2d.

Reason for revert: this change was mistakenly associated w/ a windows bot breakage (flutter/flutter#105641)

Original change's description:
> Revert "[data driven] support moving symbols across packages"
>
> This reverts commit 3290d7a.
>
> Reason for revert: flutter engine breakage (flutter/flutter#105641)
>
> Original change's description:
> > [data driven] support moving symbols across packages
> >
> > See: #48997
> >
> > Change-Id: Iad16b9eae0523bc4bc14537af642b05efa75b6f7
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246663
> > Commit-Queue: Phil Quitslund <[email protected]>
> > Reviewed-by: Brian Wilkerson <[email protected]>
>
> # Not skipping CQ checks because original CL landed > 1 day ago.
>
> Change-Id: I4a83d50497d6208b7f518ca1b381ece3aab192ad
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247606
> Reviewed-by: Siva Annamalai <[email protected]>
> Reviewed-by: Keerti Parthasarathy <[email protected]>
> Commit-Queue: Phil Quitslund <[email protected]>
> Reviewed-by: Phil Quitslund <[email protected]>
> Reviewed-by: Brian Wilkerson <[email protected]>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I769dec0d85fc0a41048b21deec0724d8509ef8e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248061
Reviewed-by: Brian Wilkerson <[email protected]>
Reviewed-by: Keerti Parthasarathy <[email protected]>
Commit-Queue: Phil Quitslund <[email protected]>
@natebosch
Copy link
Member Author

We are getting things in place to move these APIs from test.

I could add the deprecations soon, but I'd ideally like to have fix support in place when I do. Can this be prioritized?

@bwilkerson
Copy link
Member

@jacob314 How does this prioritize relative to language feature support or analytics work?

@natebosch
Copy link
Member Author

We can use dart-lang/test#1978 to test the implementation when we start on it.

The end result should be:

  • Add import to package:matcher/expect.dart in any test with a deprecation diagnostic.
  • (Rarely) remove an import to package:test/test.dart if there were no other APIs being used. (Could skip this and let dart fix fix the unused import in the next run?)
  • Add a dependency to macher in the pubspec.yaml file.

I'm happy to add a dart fix config file to the PR whenever we have an idea of what the syntax will be for this type of move.

@bwilkerson
Copy link
Member

  • Add import to package:matcher/expect.dart in any test with a deprecation diagnostic.

That would be a good fix to have in general, but doesn't require data-driven fix support. Any time there's a deprecated_import_use we should be able to see which library it's declared in and add an explicit import. We might even have enough information in the element model to import it using the same URI as was in the export directive.

The fix doesn't currently exist.

  • (Rarely) remove an import to package:test/test.dart if there were no other APIs being used. (Could skip this and let dart fix fix the unused import in the next run?)

Yes. We always leave import clean-up until the very last pass. It avoids a large number of possible bugs.

  • Add a dependency to macher in the pubspec.yaml file.

That would be really nice. We've talked a few times about ways to update the pubspec.yaml file, but we don't currently have any support for doing so.

@natebosch
Copy link
Member Author

Is this something we can start on soon? We are getting closer to being ready to deprecate the export of matcher from test

@natebosch
Copy link
Member Author

but doesn't require data-driven fix support

Do we think it's sufficient for dart fix to only work during the intermediate period where we have the export but it is deprecated? Or should we also look for a way to express this in the data-driven config for it to keep working if the user jumps straight to a version without the export at all?

@jacob314
Copy link
Member

jacob314 commented May 4, 2023

I think it is important for the fix to still work after the migration period. Users will encounter documentation that omits the package:matcher import for a long time and LLMs will likely be confused and suggest code that omits the matcher import.

@mit-mit
Copy link
Member

mit-mit commented Jun 6, 2023

Hey there, is there a tentative timeline for this?

@pq
Copy link
Member

pq commented Jun 6, 2023

@keertip: are you planning to look at this?

@keertip
Copy link
Contributor

keertip commented Jun 6, 2023

no, had not planned to.

@pq
Copy link
Member

pq commented Jun 6, 2023

/fyi @srawlins @bwilkerson @jacob314

@srawlins
Copy link
Member

srawlins commented Jun 6, 2023

I don't think we have any timeline for this. It is not in our queue for Q2, but I think we can prioritize it for Q3.

Correct me if I'm wrong but it sounds like the remaining AIs are:

I'll note that we do not have a quick fix for depend_on_referenced_packages, and I'm not certain that it's possible. @bwilkerson you note above that:

We always leave import clean-up until the very last pass. It avoids a large number of possible bugs.

It sounds like it would be a natural step to add a step after import clean-up that adds and removes packages from dependencies and dev_dependencies. "Natural," but I don't want to imply "simple." Also... as far as dev_dependencies go, I think maybe you would only want to add dependencies, but never remove (they're not always there for use as imports).

@natebosch
Copy link
Member Author

Correct me if I'm wrong but it sounds like the remaining AIs are:

I think we also want support for encoding this in dart_fix.yaml. #48997 (comment)

@bwilkerson
Copy link
Member

It sounds like it would be a natural step to add a step after import clean-up that adds and removes packages from dependencies and dev_dependencies.

Yes, the clean-up-imports pass seems like a good time to update dependencies.

We'd need to collect all of the diagnostics used to find the imported packages for which a dependency needs to be added, then de-dup the list of dependencies so that we can build a consistent set of edits, but other than that it sounds reasonable.

@keertip keertip assigned keertip and unassigned pq Sep 18, 2023
copybara-service bot pushed a commit that referenced this issue Oct 26, 2023
This reverts commit 3c6ceb8.

Reason for revert: This breaks flutter tests - running dart fix in the flutter_svg package adds a flutter_svg: any dependency line to pubspec.yaml.

Original change's description:
> Add a pass to dart fix for pubspec changes
>
> Fixes #48997
>
> Change-Id: I543a550247920e121837f2bc6c75b5c1acecc670
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331740
> Commit-Queue: Keerti Parthasarathy <[email protected]>
> Reviewed-by: Brian Wilkerson <[email protected]>

Change-Id: I38a234b558d03c6c5c6c00f9ea55db7e1fbc7a89
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332171
Bot-Commit: Rubber Stamper <[email protected]>
Reviewed-by: William Hesse <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
Commit-Queue: Brian Wilkerson <[email protected]>
@keertip
Copy link
Contributor

keertip commented Dec 1, 2023

Changes to dart fix to add missing dependencies to pubspec have landed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-bulk-fix analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

8 participants