v0.7.0
-
Breaking changes: See the wiki
for help upgrading.Generator.generate
now operates on aLibraryReader
rather than being
called for everyElement
within a library. Generators can iterate over
elements usingLibraryReader.allElements
.GeneratorForAnnotation
will
continue to callgenerateForAnnotatedElement
repeatedly for each element.GeneratorForAnnotation
passes in aConstantReader
for the annotation
instance rather than re-creating it using mirrors.GeneratorBuilder
is replaced withPartBuilder
andLibraryBuilder
depending on whether the output is meant to be included in apart
file.- Removed
JsonSerializable
and related classes. These are moved to
package:json_serializable
. - Removed
lib/builder.dart
. Import throughsource_gen.dart
instead. - Removed
OutputFormatter
typedef.
-
Add
LibraryReader.allElements
- a utility to iterate across allElement
instances contained in Dart library. -
Add
LibraryReader.element
to get back to theLibraryElement
instance. -
Add
ConstantReader.objectValue
to get back to theDartObject
instance. -
Add
ConstantReader.peek
to read a value that returnsnull
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 toTypeChecker.annotationsOf
,
TypeChecker.annotationsOfExact
,TypeChecker.firstAnnotationOf
, and
TypeChecker.firstAnnotationOfExact
. Setting this tofalse
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 thelibrary
,
which is more useful for tracking down the actual files.