dart-lang / code_builder

A fluent API for generating valid Dart source code
https://pub.dev/packages/code_builder
BSD 3-Clause "New" or "Revised" License
423 stars 66 forks source link

Support newInstanceNamed with empty name #463

Open mattrberry opened 3 weeks ago

mattrberry commented 3 weeks ago

Opts to rewrite refer('Foo').newInstanceNamed('', []) as Foo rather than Foo.. Two primary reasons

  1. Foo. breaks compilation with bad error messages
  2. Analyzer's ConstructorElement#name is a non-nullable String, which pushes the isEmpty check to user code