source_gen 0.9.10+3
source_gen: ^0.9.10+3 copied to clipboard
Source code generation builders and utilities for the Dart build system
0.9.10+3 #
- Allow the latest version of
package:analyzer.
0.9.10+2 #
- Expand allowed versions for the glob package as source_gen is compatible to break circular dependency issues in the ecosystem.
0.9.10+1 #
- Fix a bug in the early bailout optimization where it wouldn't check for annotations in part files.
0.9.10 #
- Optimize for the case where we have only GeneratorForAnnotation generators, and we know there are no annotations present in the file at all.
0.9.9 #
- Allow
package:analyzerversion0.41.x.
0.9.8 #
- Add support for
allowSyntaxErrorsflag introduced inpackage:buildversion1.4.0. - Update minimum Dart SDK to
2.10.0.
0.9.7+1 #
- Allow
package:analyzerversion0.40.x.
0.9.7 #
- Match Dart language version overrides parts generated by
PartBuilder.
0.9.6 #
- Add support for
SetinConstantReader.- Updated
isLiteralandliteralValueto handleSet. - Added
isSetandsetValuemembers.
- Updated
- Include matching Dart language version overrides in generated parts if the source library has a language version override.
- Streamlined error handling in all builders. There should be no user-visible behavior change.
- Improve the error message when source code formatting fails.
- Update minimum Dart SDK to
2.7.0. - Changed the behavior of
LibraryReader.allElementsto include extensions.
0.9.5 #
-
Add support for an
ignore_for_fileoption tocombining_builder. -
Expand documentation for
GeneratorForAnnotationto make it clear that it only targets elements at the top level of a library.
0.9.4+7 #
- Fix an exception during error reporting when the
Elementreported is in a summary file rather than a source file.
0.9.4+6 #
- Allow
package:analyzerversion0.39.x.
0.9.4+5 #
- Fix a bug for finding the element for a function with recent versions of
analyzer.
0.9.4+4 #
- Allow
pkg:analyzerversion0.38.x.
0.9.4+3 #
- Allow
pkg:analyzerversion0.37.x.
0.9.4+2 #
- Allow
pkg:analyzerversion0.36.x.
0.9.4+1 #
- Support the latest
pkg:analyzer.
0.9.4 #
- Use
ParsedLibraryResultto find source spans for unresolvable annotations.
0.9.3 #
- Rename
LibraryReader.classElementstoLibraryReader.classesto better reflect the behavior. Deprecate the old name. - Add
LibraryReader.enums.
0.9.2 #
- Avoid using the AST analyzer model from
LibraryReader. - Don't create part files with no corresponding library.
- Update analyzer constraint to allow 0.34.x.
0.9.1+3 #
- Support the latest
pkg:analyzer.
0.9.1+2 #
- Correctly handle properties in
spanForElement.
0.9.1+1 #
- Allow
package:buildversion 1.0.0.
0.9.1 #
-
The result of
ConstantReader.revive()now returns aRevivablethat assumes access to a private class, constructor, or function instead ofnullwhere possible. This allows generators that usepartfiles to still use this functionality and allows generators that use separate libraries to emit more actionable error messages (i.e."cannot use private class _X"). -
Revivable.isPrivatenow returnstruewhen the underlying class was public but the constructor was private, or theRevivablewas pointing to a top-level or static private field or method. Previously it was onlytruewhen referencing a private class.
0.9.0+1 #
- Fix
LibraryReader.classElementsto return classes from parts, if they exist, as well as from the defining library file.
0.9.0 #
- Introduce
SharedPartBuilderfor creating part files that can be merged with a newCombiningBuilder. Note thatCombiningBuilderonly outputs.g.dartfiles. - Breaking
PartBuildernow requires ageneratedExtensionsargument. The value should not be.g.dart. To produce.g.dartfiles please use theSharedPartBuilder.
0.8.3+1 #
- Allow using non-dev Dart 2 SDK.
0.8.3 #
GeneratorForAnnotationgenerateForAnnotatedElementnow allow multiple return values when implementations return anIterableorStream.- Values from
generateForAnnotatedElementhave whitespace trimmed.nulland empty values are ignored. - Duplicate values are collapsed into a single values. This allows emitting shared, top-level members without naming collisions.
0.8.2 #
-
Simplification to the output of generator names in header sections.
-
Update handling of whitespace in generator outputs.
- If the output from a generator has wrapping whitespace, it is trimmed.
- If the output from a generator is empty or whitespace-only, it is ignored.
- These changes will likely have no effect on output, unless you customize the code formatter.
0.8.1+3 #
- More redundant new lines elimination.
0.8.1+2 #
- Eliminate redundant new lines in the core builder. These were almost removed by running the default formatter. Now the unformatted code more closely matches the default output.
0.8.1+1 #
- Support
package:analyzer0.32.0.
0.8.1 #
-
Cleanup logging output that duplicates headers provided by
package:build_runner. -
InvalidGenerationSourceErroradded an optionalelementparameter to support more helpful error messages.
0.8.0 #
-
BREAKING removed the deprecated
requireLibraryDirectiveparameter inPartBuilder. -
Revivableno longer throws a type error when attempting to revive a reference to a top-level function or static-class method. Now is returns a reference to that function or method, as expected.
0.7.6 #
TypeCheckernow throws anUnresolvedAnnotationExceptionwith a more detailed exception body (and properties useful for further debugging) instead ofCould not resolve @null.
0.7.5+1 #
LibraryBuilderandPartBuildernow have a more readabletoString(), which is useful when emitting a warning or error in a build system. For example you may seeGenerating .g.dart: MyBuilderinstead ofInstance of LibraryBuilderin your build logs.
0.7.5 #
-
The
PartBuilderconstructor parameterrequireLibraryDirectivenow defaults tofalse. It will be removed in0.8.0. -
Require at least Dart
2.0.0-dev.19.0.
0.7.4+3 #
- Support the latest
analyzerpackage.
0.7.4+2 #
-
BUG FIX:
ConstantReader.revive()now properly returns no URL fragment when the constant expression is resolved from a top-level or static-field. The documentation had said otherwise, and it was impossible to tell the difference between a constructor and a field. Now, fields are always in the form of accessor ={clazz}.{field}or{topLevelField}. -
Fix file URIs on windows.
0.7.4+1 #
- Removed a
log.finestwith the output source of each generator. This allows a verbose option (-v) for tools like bazel or build_runner to be much more readable and debuggable. Files are emitted to disk for inspection in any case.
0.7.4 #
-
Added
typeNameOf, which is a safe way to get the name of aDartType, even when the type is aFunctionType, which has anullname in newer versions of the Dart analyzer. -
Added
LibraryReader.pathToUrl(Uri|String), which computes theimportorexportpath necessary to reach the provided URL from the current library. Also addedpathToAssetandpathToElementas convenience functions. -
Expanded
package:buildsupport to allow version0.12.0.
0.7.3 #
- Allow null and empty outputs form
GeneratorForAnnotation.
0.7.2+1 #
- Allow
package:buildversion 0.11.0
0.7.2 #
- Support an optional
headerargument toPartBuilderandLibraryBuilder.
0.7.1 #
Generator{ForAnnotation} #
- Return type of
generate{ForAnnotatedElement}is nowFutureOr<String>.
LibraryReader #
- Added
annotatedElementsto return all elements annotated with something. - Added
classElementsgetter for returning allclass-es in a library.
TypeChecker #
- Added
hasAnnotationOfandhasAnnotationOfExact.
ConstantReader #
- Added
isAny(for consistency, but deprecated) andisLiteral. - Added
literalValueas an alias for the now deprecatedanyValue. - Allow
literalValueto returnnullif the value is actuallynull. - Fixed a bug where a
Symbolwould return as aStringforanyValue. - Fixed a bug where a
ListandMapwere not considered literals.
0.7.0 #
-
Breaking changes: See the wiki for help upgrading.
Generator.generatenow operates on aLibraryReaderrather than being called for everyElementwithin a library. Generators can iterate over elements usingLibraryReader.allElements.GeneratorForAnnotationwill continue to callgenerateForAnnotatedElementrepeatedly for each element.GeneratorForAnnotationpasses in aConstantReaderfor the annotation instance rather than re-creating it using mirrors.GeneratorBuilderis replaced withPartBuilderandLibraryBuilderdepending on whether the output is meant to be included in apartfile.- Removed
JsonSerializableand related classes. These are moved topackage:json_serializable. - Removed
lib/builder.dart. Import throughsource_gen.dartinstead. - Removed
OutputFormattertypedef.
-
Add
LibraryReader.allElements- a utility to iterate across allElementinstances contained in Dart library. -
Add
LibraryReader.elementto get back to theLibraryElementinstance. -
Add
ConstantReader.objectValueto get back to theDartObjectinstance. -
Add
ConstantReader.peekto read a value that returnsnullif 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
throwOnUnresolvedoptional parameter toTypeChecker.annotationsOf,TypeChecker.annotationsOfExact,TypeChecker.firstAnnotationOf, andTypeChecker.firstAnnotationOfExact. Setting this tofalsewill enable you to check for matching annotations with incomplete type information (at your own risk). - Builder logs now log the primary inputs
AssetIdinstead of thelibrary, which is more useful for tracking down the actual files.
0.6.1+1 #
- Tighten constraint on
source_span.
0.6.1 #
- Added
spanForElement; returns aSourceSpanfor an analyzerElement. - Logs a warning to the console when a
GeneratorBuilderoutputs a part file for a given input, but that input does not definepart 'name.g.dart';.
0.6.0 #
- Breaking change:
TypeChecker#annotationsOf|firstAnnotationOfnow returns annotations that are assignable to theTypeChecker's type. As a result we've added#annotationsOfExact|firstAnnotationOfExactwhich has the old behavior for precise checks. TypeChecker#annotations...-methods now throw aStateErrorif one or more annotations on an element are not resolvable. This is usually a sign of a misspelling, missing import, or missing dependency.- Added
TypeChecker.any, which delegates to multiple otherTypeCheckerimplementations when making a type check.
0.5.10+1 #
- Update minimum
analyzerpackage to0.29.10.
0.5.10 #
- Bug fixes:
- Do not fail when "library" is omitted but nothing would be output.
- Do not fail on extensions that don't end in ".dart" (valid use case).
0.5.9 #
-
Update the minimum Dart SDK to
1.22.1. -
Deprecated
builder.dart: importsource_gen.dartinstead. -
Added
TypeChecker, a high-level API for performing static type checks:import 'package:analyzer/dart/element/type.dart'; import 'package:source_gen/source_gen.dart'; void checkType(DartType dartType) { // Checks compared to runtime type `SomeClass`. print(const TypeChecker.forRuntime(SomeClass).isExactlyType(dartType)); // Checks compared to a known Url/Symbol: const TypeChecker.forUrl('package:foo/foo.dart#SomeClass'); // Checks compared to another resolved `DartType`: const TypeChecker.forStatic(anotherDartType); } -
Failing to add a
librarydirective to a library that is being used as a generator target that generates partial files (part of) is now an explicit error that gives a hint on how to name and fix your library:> Could not find library identifier so a "part of" cannot be built. > > Consider adding the following to your source file: > > "library foo.bar;"In Dart SDK
>=1.25.0this can be relaxed aspart ofcan refer to a path. To opt-in,GeneratorBuildernow has a new flag,requireLibraryDirective. Set it tofalse, and also set yoursdkconstraint appropriately:sdk: '>=1.25.0 <2.0.0' -
Added
LibraryReader, a utility class forLibraryElementthat exposes high-level APIs, includingfindType, which traversesexportdirectives for publicly exported types. For example, to findGeneratorfrompackage:source_gen/source_gen.dart:void example(LibraryElement pkgSourceGen) { var library = new LibraryReader(pkgSourceGen); // Instead of pkgSourceGen.getType('Generator'), which is null. library.findType('Generator'); } -
Added
ConstantReader, a high-level API for reading from constant (static) values from Dart source code (usually represented byDartObjectfrom theanalyzerpackage):abstract class ConstantReader { factory ConstantReader(DartObject object) => ... // Other methods and properties also exist. /// Reads[ field] from the constant as another constant value. ConstantReader read(String field); /// Reads [field] from the constant as a boolean. /// /// If the resulting value is `null`, uses [defaultTo] if defined. bool readBool(String field, {bool defaultTo()}); /// Reads [field] from the constant as an int. /// /// If the resulting value is `null`, uses [defaultTo] if defined. int readInt(String field, {int defaultTo()}); /// Reads [field] from the constant as a string. /// /// If the resulting value is `null`, uses [defaultTo] if defined. String readString(String field, {String defaultTo()}); }
0.5.8 #
- Add
formatOutputoptional parameter to theGeneratorBuilderconstructor. This is a lambda of the formString formatOutput(String originalCode)which allows you do do custom formatting.
0.5.7 #
- Support for package:analyzer 0.30.0
0.5.6 #
- Support for package:build 0.9.0
0.5.5 #
- Support package:build 0.8.x
- Less verbose errors when analyzer fails to resolve the input.
0.5.4+3 #
- Support the latest release of
pkg/dart_style.
0.5.4+2 #
- Use the new
logfield instead of the deprecatedbuildStep.logger
0.5.4+1 #
- Give more information when
dartfmtfails.
0.5.4 #
- Update to latest
build,build_runner, andbuild_testreleases.
0.5.3+2 #
- BugFix: Always release the Resolver instance, even when generation does not run
0.5.3+1 #
- Don't throw when running against a non-library asset and getting no LibraryElement
0.5.3 #
- Add matchTypes method. As with anything imported from /src/ this is use-at-your-own-risk since it is not guaranteed to be stable
- Internal cleanup
- Drop some unused utility methods
- Move cli_util to dev_dependencies
- Avoid some deprecated analyzer apis
- Syntax tweaks
- Drop results.dart which had no usages
0.5.2 #
- Use library URIs (not names) to look up annotations in the mirror system.
- Loosen version constraint to allow package:build version 0.6
- Fix a bug against the latest SDK checking whether List implements Iterable
0.5.1+7 #
- Generate valid strong-mode code for typed lists.
0.5.1+6 #
- Support the latest version of
pkg/build.
0.5.1+5 #
- Remove "experimental" comment in
README.md.
0.5.1+4 #
- Support
package:analyzer0.29.0
0.5.1+3 #
- Upgrade to be compatible with the breaking changes in analyzer 0.28.0
0.5.1+2 #
- Avoid calling
computeNode()while instantiating annotation values
0.5.1+1 #
- Support the latest version of
buildpackage.
0.5.1 #
- Added GeneratorBuilder option isStandalone to generate files that aren't part of source file.
0.5.0+3 #
- Fixed multi-line error output.
0.5.0+2 #
-
Remove an outdated work-around.
-
Make strong-mode clean.
0.5.0+1 #
- Support the latest version of
pkg/build.
0.5.0 #
-
Breaking: Switch to the
buildpackage for runningGenerators. This means that the top levelbuildandgeneratefunctions are no longer available, and have been replaced by the top levelbuild,watch, andservefunctions from thebuildpackage, and theGeneratorBuilderclass. Seetool/build.dart,tool/watch.dart, andtool/phases.dartfor usage.- Note that the
buildpackage is experimental, and likely to change.
- Note that the
-
Breaking: The build package provides an abstraction for reading/writing files via the
BuildStepclass, and that is now also provided toGenerator#generateandGeneratorForAnnotation#generateForAnnotatedElementas a second argument. -
Timestamps are no longer included in generated code.
-
There is no longer a need to specify the files related to an individual generator via
AssociatedFileSet. Simply use theBuildStepinstance to read and write files and thebuildpackage will track any files you read in and run incremental rebuilds as necessary.
0.4.8 #
-
Added support for
SymbolandTypein annotations. -
Improved error output when unable to create an instance from an annotation.
0.4.7+2 #
- Upgrade to
analyzer '^0.27.1'and removed a work-around for a fixedanalyzerissue.
0.4.7+1 #
- Upgrade to
analyzer '^0.27.0'.
0.4.7 #
JsonSerializableGeneratornow supports classes with read-only properties.
0.4.6 #
-
JsonSerializable: AddedJsonKeyannotation. -
Improved output of generation errors and stack traces.
-
Require
analyzer '^0.26.2'.
0.4.5+1 #
- Handle
nullvalues forListproperties.
0.4.5 #
JsonSerializable: add support forListvalues.
0.4.4+1 #
- Updated
README.mdto highlight thebuild_systempackage and de-emphasize Dart Editor.
0.4.4 #
-
Added
omitGenerateTimestampandfollowLinksnamed args tobuild. -
Added
followLinkstogenerate.
0.4.3+1 #
- Update tests to use a more reliable method to find the current package root.
0.4.3 #
-
Require Dart
1.12. -
Add implicit support for
.packages. If the file exists, it is used. If not, we fall back to using thepackagesdirectory. -
Support the latest releases of
analyzeranddart_stylepackages.
0.4.2 #
- Use
fromJsonif it's defined in a child field.
0.4.0+1 #
- Support the latest release of
analyzerandargs.
0.4.0 #
- Analysis no longer parses function bodies. This greatly speeds up generation, but it could break any usage that needs function bodies.
0.3.0+2 #
- Fixed
README.md.
0.3.0+1 #
- Updates for move to
dart-langorg on GitHub.
0.3.0 #
-
BREAKING Returning a descriptive value from
generate. -
BREAKING Fixed incorrectly named argument
omitGenerateTimestamp. -
JsonSerializable: Handledynamicandvaras field types.
0.2.4 #
- Added
associatedFileSettoGenerator. Allows a generator to specify that changes to any file in a directory next to a Dart source file can initiate a generation run.
0.2.3 #
-
Use
async *. Requires SDK >=1.9.0-dev.10 -
Protect against crash during code format.
0.2.2 #
-
Added
omitGenerateTimestamp(incorrectly spelled) named argument togeneratemethod. -
Generator.generateis now called with theLibraryElement, too.
0.2.1 #
-
Fixed critical bug affecting annotation matching. #35
-
Started using published
dart_stylepackage.
0.2.0+1 #
- Updated
README.mdwith new examples. - Fixed sub-bullet indenting in
CHANGELOG.md.
0.2.0 #
- BREAKING Moved and renamed JSON serialization classes.
- Added a
JsonLiteralgenerator. - Improved handling and reporting of Generator errors.
JsonGenerator- Learned how to use constructor arguments.
- Learned how to properly handle
DateTime.
0.1.1 #
- Support for parametrized annotations.
- Add named arguments to
JsonGenerator.
0.1.0+1 #
README.mdupdates.
0.1.0 #
- BREAKING
Generator.generateis now async – returnsFuture<String> - Big update to
README.md.
0.0.1 #
- Ready for experimentation.
0.0.0+1 #
- First play release.