Skip to content

Standardize on Element.name everywhere #170

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
May 22, 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
2 changes: 1 addition & 1 deletion json_serializable/lib/src/generator_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class _GeneratorHelper {

Set<String> fieldsSetByFactory;
if (_generator.checked) {
var classLiteral = escapeDartString(_element.displayName);
var classLiteral = escapeDartString(_element.name);

_buffer.writeln('\$checkedNew($classLiteral, json, ()');

Expand Down
2 changes: 1 addition & 1 deletion json_serializable/lib/src/json_key_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:source_gen/source_gen.dart';
@alwaysThrows
T _throwUnsupported<T>(FieldElement element, String message) =>
throw new InvalidGenerationSourceError(
'Error with `@JsonKey` on `${element.displayName}`. $message',
'Error with `@JsonKey` on `${element.name}`. $message',
element: element);

final _jsonKeyExpando = new Expando<JsonKeyWithConversion>();
Expand Down
2 changes: 1 addition & 1 deletion json_serializable/lib/src/json_literal_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class JsonLiteralGenerator extends GeneratorForAnnotation<JsonLiteral> {
var thing = _jsonLiteralAsDart(content, asConst).toString();
var marked = asConst ? 'const' : 'final';

return '$marked _\$${element.displayName}JsonLiteral = $thing;';
return '$marked _\$${element.name}JsonLiteral = $thing;';
}
}

Expand Down
10 changes: 4 additions & 6 deletions json_serializable/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ Set<FieldElement> createSortedFieldSet(ClassElement element) {

var undefinedFields = fieldsList.where((fe) => fe.type.isUndefined).toList();
if (undefinedFields.isNotEmpty) {
var description =
undefinedFields.map((fe) => '`${fe.displayName}`').join(', ');
var description = undefinedFields.map((fe) => '`${fe.name}`').join(', ');

throw new InvalidGenerationSourceError(
'At least one field has an invalid type: $description.',
Expand Down Expand Up @@ -194,7 +193,7 @@ CtorData writeConstructorInvocation(
Map<String, String> unavailableReasons,
String deserializeForField(String paramOrFieldName,
{ParameterElement ctorParam})) {
var className = classElement.displayName;
var className = classElement.name;

var ctor = classElement.unnamedConstructor;
if (ctor == null) {
Expand All @@ -212,7 +211,7 @@ CtorData writeConstructorInvocation(
// ignore: deprecated_member_use
if (arg.parameterKind == ParameterKind.REQUIRED) {
var msg = 'Cannot populate the required constructor '
'argument: ${arg.displayName}.';
'argument: ${arg.name}.';

var additionalInfo = unavailableReasons[arg.name];

Expand Down Expand Up @@ -277,8 +276,7 @@ void _validateConstructorArguments(
var undefinedArgs =
constructorArguments.where((pe) => pe.type.isUndefined).toList();
if (undefinedArgs.isNotEmpty) {
var description =
undefinedArgs.map((fe) => '`${fe.displayName}`').join(', ');
var description = undefinedArgs.map((fe) => '`${fe.name}`').join(', ');

throw new InvalidGenerationSourceError(
'At least one constructor argument has an invalid type: $description.',
Expand Down