Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkgs/code_builder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
## 4.10.2-wip

* Support `Expression.newInstanceNamed` with empty name
* Consistently add blank lines between `=>` in class-like definitions.
* Fixed bug: Fields declared with `static` and `external` now produce code with
correct order
* Upgrade `dart_style` and `source_gen` to remove `package:macros` dependency.
* Require Dart `^3.6.0` due to the upgrades.
* Support `Expression.newInstanceNamed` with empty name
* Fixed bug: Fields declared with `static` and `external` now produce code with correct order

## 4.10.1

Expand Down
50 changes: 15 additions & 35 deletions pkgs/code_builder/lib/src/emitter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,7 @@ class DartEmitter extends Object
visitField(f, out);
out.writeln();
}
for (var m in spec.methods) {
visitMethod(m, out);
if (_isLambdaMethod(m)) {
out.writeln(';');
}
out.writeln();
}
_visitMethods(spec.methods, out);
out.writeln(' }');
return out;
}
Expand Down Expand Up @@ -201,13 +195,7 @@ class DartEmitter extends Object
visitField(f, out);
out.writeln();
}
for (var m in spec.methods) {
visitMethod(m, out);
if (_isLambdaMethod(m)) {
out.write(';');
}
out.writeln();
}
_visitMethods(spec.methods, out);
out.write(' }');
return out;
}
Expand Down Expand Up @@ -326,13 +314,7 @@ class DartEmitter extends Object
visitField(f, out);
out.writeln();
}
for (var m in spec.methods) {
visitMethod(m, out);
if (_isLambdaMethod(m)) {
out.write(';');
}
out.writeln();
}
_visitMethods(spec.methods, out);
out.writeln(' }');
return out;
}
Expand Down Expand Up @@ -372,13 +354,7 @@ class DartEmitter extends Object
visitField(f, out);
out.writeln();
}
for (var m in spec.methods) {
visitMethod(m, out);
if (_isLambdaMethod(m)) {
out.writeln(';');
}
out.writeln();
}
_visitMethods(spec.methods, out);
out.writeln('}');
return out;
}
Expand Down Expand Up @@ -800,6 +776,16 @@ class DartEmitter extends Object
}
}

void _visitMethods(Iterable<Method> methods, StringSink out) {
for (final m in methods) {
visitMethod(m, out);
if (_isLambdaMethod(m)) {
out.writeln(';');
}
out.writeln();
}
}

@override
StringSink visitReference(Reference spec, [StringSink? output]) =>
(output ??= StringBuffer())..write(allocator.allocate(spec));
Expand Down Expand Up @@ -907,13 +893,7 @@ class DartEmitter extends Object
visitField(f, out);
out.writeln();
}
for (var m in spec.methods) {
visitMethod(m, out);
if (_isLambdaMethod(m)) {
out.write(';');
}
out.writeln();
}
_visitMethods(spec.methods, out);
out.writeln(' }');
return out;
}
Expand Down
1 change: 1 addition & 0 deletions pkgs/code_builder/test/specs/enum_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ void main() {
c;

int get myInt => 123;

Iterable<String> myStrings() sync* {
yield 'a';
yield 'b';
Expand Down