Skip to content

dart_style implementation for named arguments anywhere #1072

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
Tracked by #47451
munificent opened this issue Oct 29, 2021 · 0 comments · Fixed by #1094
Closed
Tracked by #47451

dart_style implementation for named arguments anywhere #1072

munificent opened this issue Oct 29, 2021 · 0 comments · Fixed by #1094
Assignees

Comments

@munificent
Copy link
Member

The "named arguments anywhere" language change allows named arguments to come before positional ones. Today, the argument list formatter assumes all named arguments will appear at the end of the argument list. Fixing this—and even figuring out how these mixed arguments lists should be formatted—might be pretty hard.

@munificent munificent changed the title Handle named arguments appearing before positional arguments Implement named arguments anywhere Oct 29, 2021
@devoncarew devoncarew changed the title Implement named arguments anywhere dart_style implementation for named arguments anywhere Oct 29, 2021
munificent added a commit that referenced this issue Feb 17, 2022
I opted to add support for this while being minimally invasive to the
existing style and formatting. All existing code which does not have any
positional arguments after named ones retains its previous formatting.

For new argument lists that use positional arguments after named ones,
I try to mostly follow the existing style rules even though they can be
fairly complex. In particular, it will be pretty aggressive about
applying block-style formatting to function literals inside argument
lists even with named args anywhere. I think that's important to support
the main use case I know of for the feature which is trailing positional
closures like:

function(named: 1, another: 2, () {
  block...
});

In argument lists using named args anywhere that don't have block
functions, it treats all arguments like named ones. That provides nice
simple formatting like:

function(
    argument1,
    named: argument2,
    argument3,
    another: argument4);

I think that does a good job of highlighting which arguments are named,
which is what we want.

Fix #1072.
munificent added a commit that referenced this issue Feb 23, 2022
* Formatting support for named arguments anywhere.

I opted to add support for this while being minimally invasive to the
existing style and formatting. All existing code which does not have any
positional arguments after named ones retains its previous formatting.

For new argument lists that use positional arguments after named ones,
I try to mostly follow the existing style rules even though they can be
fairly complex. In particular, it will be pretty aggressive about
applying block-style formatting to function literals inside argument
lists even with named args anywhere. I think that's important to support
the main use case I know of for the feature which is trailing positional
closures like:

function(named: 1, another: 2, () {
  block...
});

In argument lists using named args anywhere that don't have block
functions, it treats all arguments like named ones. That provides nice
simple formatting like:

function(
    argument1,
    named: argument2,
    argument3,
    another: argument4);

I think that does a good job of highlighting which arguments are named,
which is what we want.

Fix #1072.

* Rewrite doc comments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant