Skip to content

Commit 4b9e805

Browse files
committed
fix: review fixes
1 parent 6bf34e8 commit 4b9e805

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';
@@ -79,22 +77,18 @@ mixin DecodeHelper implements HelperCore {
7977
/// If [functionBodyParts] has only one element, expression body is used.
8078
///
8179
/// ```dart
82-
/// '''
8380
/// ExampleClass _$ExampleClassFromJson(Map<String, dynamic> json) =>
8481
/// /* only body part here */
85-
/// '''
8682
/// ```
8783
///
8884
/// If [functionBodyParts] has more than one element, block body is used.
8985
///
9086
/// ```dart
91-
/// '''
9287
/// ExampleClass _$ExampleClassFromJson(Map<String, dynamic> json) {
9388
/// /* first body parts here */
9489
///
9590
/// return /* last body part here */;
9691
/// }
97-
/// '''
9892
/// ```
9993
String _createFromJsonFunctionSignature(Iterable<String> functionBodyParts) {
10094
final mapType = config.anyMap ? 'Map' : 'Map<String, dynamic>';
@@ -138,13 +132,11 @@ mixin DecodeHelper implements HelperCore {
138132
///
139133
/// For example:
140134
/// ```dart
141-
/// '''
142135
/// switch (json['type']) {
143136
/// 'FirstSubtype' => _$FirstSubtypeFromJson(json),
144137
/// 'SecondSubtype' => _$SecondSubtypeFromJson(json),
145138
/// _ => throw Exception('Unknown type: ${json['type']}'),
146139
/// };
147-
/// '''
148140
/// ```
149141
String _createSealedFunctionExpressionBody() {
150142
assert(element.isSealed);
@@ -178,7 +170,6 @@ _ => throw UnrecognizedUnionTypeException(
178170
///
179171
/// For example:
180172
/// ```dart
181-
/// '''
182173
/// $checkedCreate(
183174
/// 'FirstSubtype',
184175
/// json,
@@ -194,7 +185,6 @@ _ => throw UnrecognizedUnionTypeException(
194185
/// return val;
195186
/// },
196187
/// );
197-
/// '''
198188
/// ```
199189
String _createCheckedFunctionExpressionBody(
200190
_ConstructorData data,
@@ -261,39 +251,31 @@ _ => throw UnrecognizedUnionTypeException(
261251
///
262252
/// ```dart
263253
/// [
264-
/// '''
265254
/// ExampleClass(
266255
/// json['exampleField'] as String,
267256
/// )
268-
/// '''
269257
/// ]
270258
/// /* OR with fields to set */
271259
/// [
272-
/// '''
273260
/// ExampleClass(
274261
/// json['exampleField'] as String,
275262
/// )
276263
/// ..field1 = json['field1'] as String
277-
/// ..field2 = json['field2'] as String;
278-
/// '''
264+
/// ..field2 = json['field2'] as String
279265
/// ]
280266
/// ```
281267
///
282268
/// If there are checks, will return the checks followed by the
283269
/// constructor invocation.
284270
/// ```dart
285271
/// [
286-
/// '''
287272
/// $checkKeys(
288273
/// json,
289274
/// allowedKeys: const ['exampleField', 'field1', 'field2'],
290-
/// )
291-
/// ''',
292-
/// '''
275+
/// ),
293276
/// ExampleClass(
294277
/// json['exampleField'] as String,
295278
/// )
296-
/// '''
297279
/// ]
298280
/// ```
299281
///

json_serializable/lib/src/encoder_helper.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,8 @@ mixin EncodeHelper implements HelperCore {
100100
/// For example:
101101
///
102102
/// ```dart
103-
/// '''
104103
/// Map<String, dynamic> _$ExampleClassToJson(ExampleClass instance) =>
105104
/// /* expression body here */;
106-
/// '''
107105
/// ```
108106
String _createToJsonFunctionSignature(String functionExpressionBody) {
109107
final buffer = StringBuffer();
@@ -126,7 +124,6 @@ mixin EncodeHelper implements HelperCore {
126124
///
127125
/// For example:
128126
/// ```dart
129-
/// '''
130127
/// switch (instance) {
131128
/// final FirstSubtype instance => {
132129
/// 'type': 'FirstSubtype',
@@ -137,7 +134,6 @@ mixin EncodeHelper implements HelperCore {
137134
/// ..._$SecondSubtypeToJson(instance),
138135
/// },
139136
/// }
140-
/// '''
141137
/// ```
142138
String _createSealedFunctionExpressionBody() {
143139
assert(element.isSealed);
@@ -171,11 +167,9 @@ mixin EncodeHelper implements HelperCore {
171167
///
172168
/// For example:
173169
/// ```dart
174-
/// '''
175170
/// <String, dynamic>{
176171
/// 'exampleField': instance.exampleField,
177172
/// }
178-
/// '''
179173
/// ```
180174
String _createFieldMapFunctionExpressionBody(
181175
Set<FieldElement> 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<ClassElement> sealedClassImplementations(
178178
.where((e) => e.allSupertypes.contains(sc.thisType));
179179
}
180180

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

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

0 commit comments

Comments
 (0)