Skip to content

Commit 61843e3

Browse files
committed
fix: review fixes
1 parent 2d13371 commit 61843e3

File tree

3 files changed

+3
-27
lines changed

3 files changed

+3
-27
lines changed

json_serializable/lib/src/decode_helper.dart

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'dart:core';
6-
75
import 'package:analyzer/dart/element/element.dart';
86
import 'package:analyzer/dart/element/nullability_suffix.dart';
97
import 'package:build/build.dart';
@@ -93,22 +91,18 @@ mixin DecodeHelper implements HelperCore {
9391
/// If [functionBodyParts] has only one element, expression body is used.
9492
///
9593
/// ```dart
96-
/// '''
9794
/// ExampleClass _$ExampleClassFromJson(Map<String, dynamic> json) =>
9895
/// /* only body part here */
99-
/// '''
10096
/// ```
10197
///
10298
/// If [functionBodyParts] has more than one element, block body is used.
10399
///
104100
/// ```dart
105-
/// '''
106101
/// ExampleClass _$ExampleClassFromJson(Map<String, dynamic> json) {
107102
/// /* first body parts here */
108103
///
109104
/// return /* last body part here */;
110105
/// }
111-
/// '''
112106
/// ```
113107
String _createFromJsonFunctionSignature(Iterable<String> functionBodyParts) {
114108
final mapType = config.anyMap ? 'Map' : 'Map<String, dynamic>';
@@ -150,13 +144,11 @@ mixin DecodeHelper implements HelperCore {
150144
///
151145
/// For example:
152146
/// ```dart
153-
/// '''
154147
/// switch (json['type']) {
155148
/// 'FirstSubtype' => _$FirstSubtypeFromJson(json),
156149
/// 'SecondSubtype' => _$SecondSubtypeFromJson(json),
157150
/// _ => throw Exception('Unknown type: ${json['type']}'),
158151
/// };
159-
/// '''
160152
/// ```
161153
String _createSealedFunctionExpressionBody() {
162154
assert(element.isSealed);
@@ -195,7 +187,6 @@ _ => throw UnrecognizedUnionTypeException(
195187
///
196188
/// For example:
197189
/// ```dart
198-
/// '''
199190
/// $checkedCreate(
200191
/// 'FirstSubtype',
201192
/// json,
@@ -211,7 +202,6 @@ _ => throw UnrecognizedUnionTypeException(
211202
/// return val;
212203
/// },
213204
/// );
214-
/// '''
215205
/// ```
216206
String _createCheckedFunctionExpressionBody(
217207
_ConstructorData data,
@@ -278,39 +268,31 @@ _ => throw UnrecognizedUnionTypeException(
278268
///
279269
/// ```dart
280270
/// [
281-
/// '''
282271
/// ExampleClass(
283272
/// json['exampleField'] as String,
284273
/// )
285-
/// '''
286274
/// ]
287275
/// /* OR with fields to set */
288276
/// [
289-
/// '''
290277
/// ExampleClass(
291278
/// json['exampleField'] as String,
292279
/// )
293280
/// ..field1 = json['field1'] as String
294-
/// ..field2 = json['field2'] as String;
295-
/// '''
281+
/// ..field2 = json['field2'] as String
296282
/// ]
297283
/// ```
298284
///
299285
/// If there are checks, will return the checks followed by the
300286
/// constructor invocation.
301287
/// ```dart
302288
/// [
303-
/// '''
304289
/// $checkKeys(
305290
/// json,
306291
/// allowedKeys: const ['exampleField', 'field1', 'field2'],
307-
/// )
308-
/// ''',
309-
/// '''
292+
/// ),
310293
/// ExampleClass(
311294
/// json['exampleField'] as String,
312295
/// )
313-
/// '''
314296
/// ]
315297
/// ```
316298
///

json_serializable/lib/src/encoder_helper.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,8 @@ mixin EncodeHelper implements HelperCore {
101101
/// For example:
102102
///
103103
/// ```dart
104-
/// '''
105104
/// Map<String, dynamic> _$ExampleClassToJson(ExampleClass instance) =>
106105
/// /* expression body here */;
107-
/// '''
108106
/// ```
109107
String _createToJsonFunctionSignature(String functionExpressionBody) {
110108
final buffer = StringBuffer();
@@ -125,7 +123,6 @@ mixin EncodeHelper implements HelperCore {
125123
///
126124
/// For example:
127125
/// ```dart
128-
/// '''
129126
/// switch (instance) {
130127
/// final FirstSubtype instance => {
131128
/// 'type': 'FirstSubtype',
@@ -136,7 +133,6 @@ mixin EncodeHelper implements HelperCore {
136133
/// ..._$SecondSubtypeToJson(instance),
137134
/// },
138135
/// }
139-
/// '''
140136
/// ```
141137
String _createSealedFunctionExpressionBody() {
142138
assert(element.isSealed);
@@ -173,11 +169,9 @@ mixin EncodeHelper implements HelperCore {
173169
///
174170
/// For example:
175171
/// ```dart
176-
/// '''
177172
/// <String, dynamic>{
178173
/// 'exampleField': instance.exampleField,
179174
/// }
180-
/// '''
181175
/// ```
182176
String _createFieldMapFunctionExpressionBody(
183177
Set<FieldElement> accessibleFields,

json_serializable/lib/src/utils.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ Iterable<ClassElement> sealedClassImplementations(
183183
);
184184
}
185185

186-
return [];
186+
return const Iterable<ClassElement>.empty();
187187
}
188188

189189
/// If [targetType] is an enum, returns the [FieldElement] instances associated

0 commit comments

Comments
 (0)