Skip to content

Update default whitespace to improve output when formatting is disabled #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2018
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
10 changes: 6 additions & 4 deletions json_serializable/lib/src/generator_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class _GeneratorHelper {
return \$checkedNew(
$classLiteral,
json,
() {''');
() {\n''');

var data = writeConstructorInvocation(
_element,
Expand All @@ -177,20 +177,22 @@ class _GeneratorHelper {
\$checkAllowedKeys(json, $listLiteral);''');
}
_buffer.write('''
var val = ${data.content};''');
var val = ${data.content};''');

for (var field in data.fieldsToSet) {
_buffer.writeln();
var safeName = _safeNameAccess(accessibleFields[field]);
_buffer.write('''
\$checkedConvert(json, $safeName, (v) => ''');
\$checkedConvert(json, $safeName, (v) => ''');
_buffer.write('val.$field = ');
_buffer.write(_deserializeForField(accessibleFields[field],
checkedProperty: true));
_buffer.write(');');
}

_buffer.writeln('return val; }');
_buffer.write('''\n
return val;
}''');

var fieldKeyMap = new Map.fromEntries(fieldsSetByFactory
.map((k) => new MapEntry(k, _nameAccess(accessibleFields[k])))
Expand Down
4 changes: 2 additions & 2 deletions json_serializable/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ CtorData writeConstructorInvocation(
buffer.writeAll(constructorArguments.map((paramElement) {
var content =
deserializeForField(paramElement.name, ctorParam: paramElement);
return ' $content';
return ' $content';
}), ',\n');
if (namedConstructorArguments.isNotEmpty) {
buffer.write(',');
Expand All @@ -298,7 +298,7 @@ CtorData writeConstructorInvocation(
buffer.writeAll(namedConstructorArguments.map((paramElement) {
var value =
deserializeForField(paramElement.name, ctorParam: paramElement);
return ' ${paramElement.name}: $value';
return ' ${paramElement.name}: $value';
}), ',\n');
}

Expand Down