1414 ` package:json_serializable ` .
1515 * Removed ` lib/builder.dart ` . Import through ` source_gen.dart ` instead.
1616 * Removed ` OutputFormatter ` typedef.
17-
17+
1818* Add ` LibraryReader.allElements ` - a utility to iterate across all ` Element `
1919 instances contained in Dart library.
2020* Add ` LibraryReader.element ` to get back to the ` LibraryElement ` instance.
@@ -29,6 +29,12 @@ findTokenField(DartObject o) {
2929}
3030```
3131
32+ * Add ` throwOnUnresolved ` optional parameter to ` TypeChecker.annotationsOf ` ,
33+ ` TypeChecker.annotationsOfExact ` , ` TypeChecker.firstAnnotationOf ` , and
34+ ` TypeChecker.firstAnnotationOfExact ` . Setting this to ` false ` will enable you
35+ to check for matching annotations with incomplete type information (at your
36+ own risk).
37+
3238## 0.6.1+1
3339
3440* Tighten constraint on ` source_span ` .
@@ -70,14 +76,14 @@ findTokenField(DartObject o) {
7076 ``` dart
7177 import 'package:analyzer/dart/element/type.dart';
7278 import 'package:source_gen/source_gen.dart';
73-
79+
7480 void checkType(DartType dartType) {
7581 // Checks compared to runtime type `SomeClass`.
7682 print(const TypeChecker.forRuntime(SomeClass).isExactlyType(dartType));
77-
83+
7884 // Checks compared to a known Url/Symbol:
7985 const TypeChecker.forUrl('package:foo/foo.dart#SomeClass');
80-
86+
8187 // Checks compared to another resolved `DartType`:
8288 const TypeChecker.forStatic(anotherDartType);
8389 }
@@ -86,19 +92,19 @@ findTokenField(DartObject o) {
8692* Failing to add a ` library ` directive to a library that is being used as a
8793 generator target that generates partial files (` part of ` ) is now an explicit
8894 error that gives a hint on how to name and fix your library:
89-
95+
9096 ``` bash
9197 > Could not find library identifier so a " part of" cannot be built.
9298 >
9399 > Consider adding the following to your source file:
94100 >
95101 > " library foo.bar;"
96102 ```
97-
103+
98104 In Dart SDK ` >=1.25.0 ` this can be relaxed as ` part of ` can refer to a path.
99105 To opt-in, ` GeneratorBuilder ` now has a new flag, ` requireLibraryDirective ` .
100106 Set it to ` false ` , and also set your ` sdk ` constraint appropriately:
101-
107+
102108 ``` yaml
103109 sdk : ' >=1.25.0 <2.0.0'
104110 ` ` `
@@ -107,11 +113,11 @@ findTokenField(DartObject o) {
107113 high-level APIs, including `findType`, which traverses `export` directives
108114 for publicly exported types. For example, to find `Generator` from
109115 `package:source_gen/source_gen.dart` :
110-
116+
111117 ` ` ` dart
112118 void example(LibraryElement pkgSourceGen) {
113119 var library = new LibraryReader(pkgSourceGen);
114-
120+
115121 // Instead of pkgSourceGen.getType('Generator'), which is null.
116122 library.findType('Generator');
117123 }
@@ -120,26 +126,26 @@ findTokenField(DartObject o) {
120126* Added `ConstantReader`, a high-level API for reading from constant (static)
121127 values from Dart source code (usually represented by `DartObject` from the
122128 `analyzer` package) :
123-
129+
124130 ` ` ` dart
125131 abstract class ConstantReader {
126132 factory ConstantReader(DartObject object) => ...
127-
133+
128134 // Other methods and properties also exist.
129-
135+
130136 /// Reads[ field] from the constant as another constant value.
131137 ConstantReader read(String field);
132-
138+
133139 /// Reads [field] from the constant as a boolean.
134140 ///
135141 /// If the resulting value is ` null`, uses [defaultTo] if defined.
136142 bool readBool(String field, {bool defaultTo()});
137-
143+
138144 /// Reads [field] from the constant as an int.
139145 ///
140146 /// If the resulting value is `null`, uses [defaultTo] if defined.
141147 int readInt(String field, {int defaultTo()});
142-
148+
143149 /// Reads [field] from the constant as a string.
144150 ///
145151 /// If the resulting value is `null`, uses [defaultTo] if defined.
0 commit comments