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

Use a long annotation w/ parameters with trailing commas constructor #558

Closed
matanlurey opened this issue Nov 24, 2016 · 6 comments
Closed

Comments

@matanlurey
Copy link
Contributor

Apologies for the long issue name. The code will make it more clear, me thinks.

Nice, just using @required:

const factory RouteDefinition.fork(
  String path,
  List<RouteDefinition> children, {
  @required String defaultTo,
}) = ForkedRouteDefinition._;

Also works fine with something like @Required('I told you so, Bob').

Less nice, using @Required(... with a long enough string here...):

const factory RouteDefinition.fork(
  String path,
  List<RouteDefinition> children, {
  @Required('When `path` is navigated to, what path within `children` to use')
      String defaultTo,
//^^<-- What is this doing here?
}) = ForkedRouteDefinition._;
@munificent
Copy link
Member

Ah, yes. In this case, the annotation and the parameter don't all fit on one line.

I had to figure out what to do in this case and there wasn't a lot of hand-formatted prior art in the corpus to go on, so I kind of just picked something that was reasonable to implement.

@srawlins
Copy link
Member

srawlins commented Feb 1, 2017

Are you just expecting fewer spaces, Matan?

@matanlurey
Copy link
Contributor Author

I mean yeah, I'm expecting it to line up nicely :-/

@srawlins
Copy link
Member

srawlins commented Feb 9, 2018

This has been labelled trailing-commas, but it applies without commas as well. The formatter currently outputs code like:

void reallyLongFunctionName0(
    @Deprecated('This has been deprecated for many interesting reasons...')
        arg1) {
  return;
}

void fn1(
    {@Deprecated('This has been deprecated for many interesting reasons...')
        String argument1}) {
  return;
}

@munificent
Copy link
Member

Thanks for pointing that out, Sam!

@munificent
Copy link
Member

In the forthcoming tall style, these examples get formatted as:

class RouteDefinition {
  const factory RouteDefinition.fork(
    String path,
    List<RouteDefinition> children, {
    @Required('When `path` is navigated to, what path within `children` to use')
    String defaultTo,
  }) = ForkedRouteDefinition._;
}

And:

void reallyLongFunctionName0(
  @Deprecated('This has been deprecated for many interesting reasons...')
  arg1,
) {
  return;
}

void fn1({
  @Deprecated('This has been deprecated for many interesting reasons...')
  String argument1,
}) {
  return;
}

So I think we're good.

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

No branches or pull requests

3 participants