code_builder 1.0.0-alpha+5 code_builder: ^1.0.0-alpha+5 copied to clipboard
A fluent API for generating Dart code
1.0.0-alpha+5 #
- MethodBuilder with no statements will create an empty block instead of a semicolon.
// main() {}
method('main')
- Fix lambdas and closures to not include a trailing semicolon when used as an expression.
// () => false
new MethodBuilder.closure(returns: literal(false));
1.0.0-alpha+4 #
- Add support for latest
pkg/analyzer
.
1.0.0-alpha+3 #
- BREAKING CHANGE: Added generics support to
TypeBuilder
:
importFrom
becomes a named, not positional argument, and the named
argument genericTypes
is added (Iterable<TypeBuilder>
).
// List<String>
new TypeBuilder('List', genericTypes: [reference('String')])
- Added generic support to
ReferenceBuilder
:
// List<String>
reference('List').toTyped([reference('String')])
- Fixed a bug where
ReferenceBuilder.buildAst
was not implemented - Added
and
andor
methods toExpressionBuilder
:
// true || false
literal(true).or(literal(false));
// true && false
literal(true).and(literal(false));
- Added support for creating closures -
MethodBuilder.closure
:
// () => true
new MethodBuilder.closure(
returns: literal(true),
returnType: lib$core.bool,
)
1.0.0-alpha+2 #
- Added
returnVoid
to well,return;
- Added support for top-level field assignments:
new LibraryBuilder()..addMember(literal(false).asConst('foo'))
- Added support for specifying a
target
when usingasAssign
:
// Outputs bank.bar = goldBar
reference('goldBar').asAssign('bar', target: reference('bank'))
- Added support for the cascade operator:
// Outputs foo..doThis()..doThat()
reference('foo').cascade((c) => <ExpressionBuilder> [
c.invoke('doThis', []),
c.invoke('doThat', []),
]);
- Added support for accessing a property
// foo.bar
reference('foo').property('bar');
1.0.0-alpha+1 #
- Slight updates to confusing documentation.
- Added support for null-aware assignments.
- Added
show
andhide
support toImportBuilder
- Added
deferred
support toImportBuilder
- Added
ExportBuilder
- Added
list
andmap
literals that support generic types
1.0.0-alpha #
- Large refactor that makes the library more feature complete.
0.1.1 #
- Add concept of
Scope
and changetoAst
to support it
Now your entire AST tree can be scoped and import directives
automatically added to a LibraryBuilder
for you if you use
LibraryBuilder.scope
.
0.1.0 #
- Initial version