Skip to content

Commit 77b7cf4

Browse files
committed
fix: review fixes
1 parent 8475a27 commit 77b7cf4

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/element2.dart';
86
import 'package:analyzer/dart/element/nullability_suffix.dart';
97
import 'package:build/build.dart';
@@ -86,22 +84,18 @@ mixin DecodeHelper implements HelperCore {
8684
/// If [functionBodyParts] has only one element, expression body is used.
8785
///
8886
/// ```dart
89-
/// '''
9087
/// ExampleClass _$ExampleClassFromJson(Map<String, dynamic> json) =>
9188
/// /* only body part here */
92-
/// '''
9389
/// ```
9490
///
9591
/// If [functionBodyParts] has more than one element, block body is used.
9692
///
9793
/// ```dart
98-
/// '''
9994
/// ExampleClass _$ExampleClassFromJson(Map<String, dynamic> json) {
10095
/// /* first body parts here */
10196
///
10297
/// return /* last body part here */;
10398
/// }
104-
/// '''
10599
/// ```
106100
String _createFromJsonFunctionSignature(Iterable<String> functionBodyParts) {
107101
final mapType = config.anyMap ? 'Map' : 'Map<String, dynamic>';
@@ -145,13 +139,11 @@ mixin DecodeHelper implements HelperCore {
145139
///
146140
/// For example:
147141
/// ```dart
148-
/// '''
149142
/// switch (json['type']) {
150143
/// 'FirstSubtype' => _$FirstSubtypeFromJson(json),
151144
/// 'SecondSubtype' => _$SecondSubtypeFromJson(json),
152145
/// _ => throw Exception('Unknown type: ${json['type']}'),
153146
/// };
154-
/// '''
155147
/// ```
156148
String _createSealedFunctionExpressionBody() {
157149
assert(element.isSealed);
@@ -185,7 +177,6 @@ _ => throw UnrecognizedUnionTypeException(
185177
///
186178
/// For example:
187179
/// ```dart
188-
/// '''
189180
/// $checkedCreate(
190181
/// 'FirstSubtype',
191182
/// json,
@@ -201,7 +192,6 @@ _ => throw UnrecognizedUnionTypeException(
201192
/// return val;
202193
/// },
203194
/// );
204-
/// '''
205195
/// ```
206196
String _createCheckedFunctionExpressionBody(
207197
_ConstructorData data,
@@ -268,39 +258,31 @@ _ => throw UnrecognizedUnionTypeException(
268258
///
269259
/// ```dart
270260
/// [
271-
/// '''
272261
/// ExampleClass(
273262
/// json['exampleField'] as String,
274263
/// )
275-
/// '''
276264
/// ]
277265
/// /* OR with fields to set */
278266
/// [
279-
/// '''
280267
/// ExampleClass(
281268
/// json['exampleField'] as String,
282269
/// )
283270
/// ..field1 = json['field1'] as String
284-
/// ..field2 = json['field2'] as String;
285-
/// '''
271+
/// ..field2 = json['field2'] as String
286272
/// ]
287273
/// ```
288274
///
289275
/// If there are checks, will return the checks followed by the
290276
/// constructor invocation.
291277
/// ```dart
292278
/// [
293-
/// '''
294279
/// $checkKeys(
295280
/// json,
296281
/// allowedKeys: const ['exampleField', 'field1', 'field2'],
297-
/// )
298-
/// ''',
299-
/// '''
282+
/// ),
300283
/// ExampleClass(
301284
/// json['exampleField'] as String,
302285
/// )
303-
/// '''
304286
/// ]
305287
/// ```
306288
///

json_serializable/lib/src/encoder_helper.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,8 @@ mixin EncodeHelper implements HelperCore {
103103
/// For example:
104104
///
105105
/// ```dart
106-
/// '''
107106
/// Map<String, dynamic> _$ExampleClassToJson(ExampleClass instance) =>
108107
/// /* expression body here */;
109-
/// '''
110108
/// ```
111109
String _createToJsonFunctionSignature(String functionExpressionBody) {
112110
final buffer = StringBuffer();
@@ -129,7 +127,6 @@ mixin EncodeHelper implements HelperCore {
129127
///
130128
/// For example:
131129
/// ```dart
132-
/// '''
133130
/// switch (instance) {
134131
/// final FirstSubtype instance => {
135132
/// 'type': 'FirstSubtype',
@@ -140,7 +137,6 @@ mixin EncodeHelper implements HelperCore {
140137
/// ..._$SecondSubtypeToJson(instance),
141138
/// },
142139
/// }
143-
/// '''
144140
/// ```
145141
String _createSealedFunctionExpressionBody() {
146142
assert(element.isSealed);
@@ -174,11 +170,9 @@ mixin EncodeHelper implements HelperCore {
174170
///
175171
/// For example:
176172
/// ```dart
177-
/// '''
178173
/// <String, dynamic>{
179174
/// 'exampleField': instance.exampleField,
180175
/// }
181-
/// '''
182176
/// ```
183177
String _createFieldMapFunctionExpressionBody(
184178
Set<FieldElement2> accessibleFields,

json_serializable/lib/src/utils.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Iterable<ClassElement2> sealedClassImplementations(
178178
.where((e) => e.allSupertypes.contains(sc.thisType));
179179
}
180180

181-
return [];
181+
return const Iterable<ClassElement2>.empty();
182182
}
183183

184184
/// If [targetType] is an enum, returns the [FieldElement2] instances associated

0 commit comments

Comments
 (0)