Skip to content

Refactoring to convert params/args between positional and named #56280

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

Closed
lukehutch opened this issue Jul 18, 2024 · 3 comments
Closed

Refactoring to convert params/args between positional and named #56280

lukehutch opened this issue Jul 18, 2024 · 3 comments
Labels
devexp-refactoring Issues with analysis server refactorings legacy-area-analyzer Use area-devexp instead. P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@lukehutch
Copy link

lukehutch commented Jul 18, 2024

It would be great if the Dart tooling supported a quick fix that converted functions between positional and named argument types (in either direction).

If the function already has a mix of parameter types, then only the applicable parameters would be converted.

Before:

  Widget _endorsementWidget(
    Profile profile,
    EndorsementView endorsementView,
    bool isOwnProfile,
    bool hideIfApproved,
  ) { ... }

After:

  Widget _endorsementWidget({
    required Profile profile,
    required EndorsementView endorsementView,
    required bool isOwnProfile,
    required bool hideIfApproved,
  }) { ... }

or vice versa.

All invocation site args should also be fixed to correspond to the change in the definition of the function parameters.

(Dart version 3.5.0-180.3.beta)

@dart-github-bot
Copy link
Collaborator

Summary: The user requests a quick fix to convert function parameters between positional and named arguments, updating both the function definition and invocation sites to maintain consistency. This would allow users to easily switch between argument styles.

@dart-github-bot dart-github-bot added legacy-area-analyzer Use area-devexp instead. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-enhancement A request for a change that isn't a bug labels Jul 18, 2024
@bwilkerson
Copy link
Member

We have an experimental refactoring for this. If you're using VS Code you can enable it by checking the "Dart: Experimental Refactors" option.

@bwilkerson bwilkerson added the devexp-refactoring Issues with analysis server refactorings label Jul 18, 2024
@lrhn lrhn removed the triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. label Jul 19, 2024
@srawlins srawlins changed the title Quick fix to convert params/args between positional and named Refactoring to convert params/args between positional and named Jul 24, 2024
@srawlins srawlins added the P3 A lower priority bug or feature request label Jul 26, 2024
@bwilkerson
Copy link
Member

I'm closing this as a duplicate of #45675.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-refactoring Issues with analysis server refactorings legacy-area-analyzer Use area-devexp instead. 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

5 participants