Skip to content

Commit

Permalink
Generate code that formats faster with "short" style. (#1336)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmorgan authored Dec 18, 2024
1 parent b0f0eb9 commit 306b669
Show file tree
Hide file tree
Showing 31 changed files with 661 additions and 488 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# 8.9.3 (unreleased)

- Generate code that formats faster with current "short" style. Both versions
are fast with the coming "tall" style.
- Mark `@nullable` deprecated: it does nothing and should not be used.

# 8.9.2
Expand Down
5 changes: 4 additions & 1 deletion benchmark/lib/node.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions benchmark/lib/simple_value.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions built_value_generator/lib/src/enum_source_class.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions built_value_generator/lib/src/enum_source_field.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions built_value_generator/lib/src/enum_source_library.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions built_value_generator/lib/src/fixes.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions built_value_generator/lib/src/memoized_getter.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions built_value_generator/lib/src/serializer_source_class.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions built_value_generator/lib/src/serializer_source_field.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions built_value_generator/lib/src/serializer_source_library.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 17 additions & 14 deletions built_value_generator/lib/src/value_source_class.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1104,20 +1104,23 @@ abstract class ValueSourceClass
}
result.writeln('_\$result = _\$v ?? ');
result.writeln('new $implName$_generics._(');
result.write(fieldBuilders.keys.map((field) {
final fieldBuilder = fieldBuilders[field];
if (needsNullCheck.contains(field)) {
if (genericFields.containsKey(field)) {
final genericType = genericFields[field];
return '$field: null is $genericType ? $fieldBuilder as $genericType '
': BuiltValueNullFieldError.checkNotNull($fieldBuilder'
", r'$name', '${escapeString(field)}')";
}
return '$field: BuiltValueNullFieldError.checkNotNull($fieldBuilder, '
"r'$name', '${escapeString(field)}')";
}
return '$field: $fieldBuilder';
}).join(','));
result.write(fieldBuilders.keys
.map((field) {
final fieldBuilder = fieldBuilders[field];
if (needsNullCheck.contains(field)) {
if (genericFields.containsKey(field)) {
final genericType = genericFields[field];
return '$field: null is $genericType ? $fieldBuilder as $genericType '
': BuiltValueNullFieldError.checkNotNull($fieldBuilder'
", r'$name', '${escapeString(field)}')";
}
return '$field: BuiltValueNullFieldError.checkNotNull($fieldBuilder, '
"r'$name', '${escapeString(field)}')";
}
return '$field: $fieldBuilder';
})
.map((fieldBuilder) => '$fieldBuilder,')
.join(''));
result.writeln(');');

if (needsTryCatchOnBuild) {
Expand Down
13 changes: 7 additions & 6 deletions built_value_generator/lib/src/value_source_class.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions built_value_generator/lib/src/value_source_field.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 16 additions & 12 deletions built_value_test/test/values.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 306b669

Please sign in to comment.