Skip to content

v0.7.0

Compare
Choose a tag to compare
@natebosch natebosch released this 26 Jul 15:54
· 339 commits to master since this release
  • Breaking changes: See the wiki
    for help upgrading.

    • Generator.generate now operates on a LibraryReader rather than being
      called for every Element within a library. Generators can iterate over
      elements using LibraryReader.allElements. GeneratorForAnnotation will
      continue to call generateForAnnotatedElement repeatedly for each element.
    • GeneratorForAnnotation passes in a ConstantReader for the annotation
      instance rather than re-creating it using mirrors.
    • GeneratorBuilder is replaced with PartBuilder and LibraryBuilder
      depending on whether the output is meant to be included in a part file.
    • Removed JsonSerializable and related classes. These are moved to
      package:json_serializable.
    • Removed lib/builder.dart. Import through source_gen.dart instead.
    • Removed OutputFormatter typedef.
  • Add LibraryReader.allElements - a utility to iterate across all Element
    instances contained in Dart library.

  • Add LibraryReader.element to get back to the LibraryElement instance.

  • Add ConstantReader.objectValue to get back to the DartObject instance.

  • Add ConstantReader.peek to read a value that returns null if not found:

// Tries to read the field "token" first, then "_token".
findTokenField(DartObject o) {
  final reader = new ConstantReader(o);
  final token = o.peek('token') ?? o.read('_token');
}
  • Add throwOnUnresolved optional parameter to TypeChecker.annotationsOf,
    TypeChecker.annotationsOfExact, TypeChecker.firstAnnotationOf, and
    TypeChecker.firstAnnotationOfExact. Setting this to false will enable you
    to check for matching annotations with incomplete type information (at your
    own risk).
  • Builder logs now log the primary inputs AssetId instead of the library,
    which is more useful for tracking down the actual files.