Skip to content

"Extract method" refactor should support multiple return values if records are enabled. #51990

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

Open
Tracked by #55825
stereotype441 opened this issue Apr 7, 2023 · 0 comments
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-refactoring Issues with analysis server refactorings P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@stereotype441
Copy link
Member

Prior to Dart 3.0, if a user selected a block of text in a method and triggered the "extract method" refactor, the refactor would fail if the extracted method would have to return multiple values.

Now that records (and patterns) have been added to Dart, this restriction should not be necessary anymore, since multiple return values can be handled using records now.

Note that there are some tricky cases, though. Traditional "extract method" behaves differently depending whether the returned variable is both an input and an output to the extracted method, or just an output. (In the former case, it replaces the method with a variable assignment; in the latter, it replaces the method with a variable declaration). It may require some ingenuity to handle the case where some variables are both an input and an output, while others are just an output 😃.

@stereotype441 stereotype441 added legacy-area-analyzer Use area-devexp instead. devexp-refactoring Issues with analysis server refactorings labels Apr 7, 2023
@keertip keertip added type-enhancement A request for a change that isn't a bug P3 A lower priority bug or feature request labels Apr 10, 2023
@pq pq added the dart-model-language-patterns Issues with analyzer's support for the patterns language feature label Apr 17, 2023
@bwilkerson bwilkerson added area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. and removed legacy-area-analyzer Use area-devexp instead. labels Feb 21, 2025
@bwilkerson bwilkerson removed the dart-model-language-patterns Issues with analyzer's support for the patterns language feature label Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-refactoring Issues with analysis server refactorings P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants