generate method
Generates Dart code for an input Dart library.
May create additional outputs through the buildStep
, but the 'primary'
output is Dart code returned through the Future. If there is nothing to
generate for this library may return null, or a Future that resolves to
null or the empty string.
Implementation
@override
// Return results for the whole scope of notations
String generate(LibraryReader library, BuildStep buildStep) {
final result = StringBuffer();
for (final element in library.allElements) {
final annotations =
const TypeChecker.fromRuntime(GenerateWithMethodSetters)
.annotationsOf(element);
if (annotations.isNotEmpty) {
result.writeln(build(annotations));
}
}
return result.toString();
}