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

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

Open
Tracked by #55825
stereotype441 opened this issue Apr 7, 2023 · 0 comments
Labels
analyzer-language-patterns Issues with analyzer's support for the patterns language feature analyzer-refactoring area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. 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 area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-refactoring 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 analyzer-language-patterns Issues with analyzer's support for the patterns language feature label Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-language-patterns Issues with analyzer's support for the patterns language feature analyzer-refactoring area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. 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

3 participants