Skip to content

Commit def4b1e

Browse files
authored
Upgrade analyzer to 5.2.0 and fix deprecated warnings (#1232)
1 parent 2cfe92a commit def4b1e

File tree

17 files changed

+84
-79
lines changed

17 files changed

+84
-79
lines changed

.github/workflows/dart.yml

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,23 @@ jobs:
4040
- name: mono_repo self validate
4141
run: dart pub global run mono_repo generate --validate
4242
job_002:
43-
name: "analyzer_and_format; Dart 2.17.0; PKGS: _test_yaml, checked_yaml, example, json_annotation, json_serializable; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`"
43+
name: "analyzer_and_format; Dart 2.18.0; PKGS: _test_yaml, checked_yaml, example, json_annotation, json_serializable; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`"
4444
runs-on: ubuntu-latest
4545
steps:
4646
- name: Cache Pub hosted dependencies
4747
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7
4848
with:
4949
path: "~/.pub-cache/hosted"
50-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:format-analyze"
50+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:format-analyze"
5151
restore-keys: |
52-
os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable
53-
os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0
52+
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable
53+
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0
5454
os:ubuntu-latest;pub-cache-hosted
5555
os:ubuntu-latest
5656
- name: Setup Dart SDK
5757
uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d
5858
with:
59-
sdk: "2.17.0"
59+
sdk: "2.18.0"
6060
- id: checkout
6161
name: Checkout repository
6262
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
@@ -212,23 +212,23 @@ jobs:
212212
if: "always() && steps.json_serializable_pub_upgrade.conclusion == 'success'"
213213
working-directory: json_serializable
214214
job_004:
215-
name: "unit_test; Dart 2.17.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`"
215+
name: "unit_test; Dart 2.18.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`"
216216
runs-on: ubuntu-latest
217217
steps:
218218
- name: Cache Pub hosted dependencies
219219
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7
220220
with:
221221
path: "~/.pub-cache/hosted"
222-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0"
222+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0"
223223
restore-keys: |
224-
os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0;packages:_test_yaml-checked_yaml-example-json_serializable
225-
os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0
224+
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:_test_yaml-checked_yaml-example-json_serializable
225+
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0
226226
os:ubuntu-latest;pub-cache-hosted
227227
os:ubuntu-latest
228228
- name: Setup Dart SDK
229229
uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d
230230
with:
231-
sdk: "2.17.0"
231+
sdk: "2.18.0"
232232
- id: checkout
233233
name: Checkout repository
234234
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
@@ -273,23 +273,23 @@ jobs:
273273
- job_002
274274
- job_003
275275
job_005:
276-
name: "unit_test; Dart 2.17.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/annotation_version_test.dart`"
276+
name: "unit_test; Dart 2.18.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/annotation_version_test.dart`"
277277
runs-on: ubuntu-latest
278278
steps:
279279
- name: Cache Pub hosted dependencies
280280
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7
281281
with:
282282
path: "~/.pub-cache/hosted"
283-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0;packages:json_serializable;commands:test_3"
283+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:json_serializable;commands:test_3"
284284
restore-keys: |
285-
os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0;packages:json_serializable
286-
os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0
285+
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:json_serializable
286+
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0
287287
os:ubuntu-latest;pub-cache-hosted
288288
os:ubuntu-latest
289289
- name: Setup Dart SDK
290290
uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d
291291
with:
292-
sdk: "2.17.0"
292+
sdk: "2.18.0"
293293
- id: checkout
294294
name: Checkout repository
295295
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
@@ -307,23 +307,23 @@ jobs:
307307
- job_002
308308
- job_003
309309
job_006:
310-
name: "unit_test; Dart 2.17.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`"
310+
name: "unit_test; Dart 2.18.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`"
311311
runs-on: ubuntu-latest
312312
steps:
313313
- name: Cache Pub hosted dependencies
314314
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7
315315
with:
316316
path: "~/.pub-cache/hosted"
317-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0;packages:json_serializable;commands:test_1"
317+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:json_serializable;commands:test_1"
318318
restore-keys: |
319-
os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0;packages:json_serializable
320-
os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0
319+
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:json_serializable
320+
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0
321321
os:ubuntu-latest;pub-cache-hosted
322322
os:ubuntu-latest
323323
- name: Setup Dart SDK
324324
uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d
325325
with:
326-
sdk: "2.17.0"
326+
sdk: "2.18.0"
327327
- id: checkout
328328
name: Checkout repository
329329
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
@@ -341,23 +341,23 @@ jobs:
341341
- job_002
342342
- job_003
343343
job_007:
344-
name: "unit_test; Dart 2.17.0; PKG: json_serializable; `dart test -p chrome`"
344+
name: "unit_test; Dart 2.18.0; PKG: json_serializable; `dart test -p chrome`"
345345
runs-on: ubuntu-latest
346346
steps:
347347
- name: Cache Pub hosted dependencies
348348
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7
349349
with:
350350
path: "~/.pub-cache/hosted"
351-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0;packages:json_serializable;commands:test_2"
351+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:json_serializable;commands:test_2"
352352
restore-keys: |
353-
os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0;packages:json_serializable
354-
os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0
353+
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:json_serializable
354+
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0
355355
os:ubuntu-latest;pub-cache-hosted
356356
os:ubuntu-latest
357357
- name: Setup Dart SDK
358358
uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d
359359
with:
360-
sdk: "2.17.0"
360+
sdk: "2.18.0"
361361
- id: checkout
362362
name: Checkout repository
363363
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
@@ -538,23 +538,23 @@ jobs:
538538
- job_002
539539
- job_003
540540
job_012:
541-
name: "ensure_build; Dart 2.17.0; PKGS: _test_yaml, checked_yaml, example; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`"
541+
name: "ensure_build; Dart 2.18.0; PKGS: _test_yaml, checked_yaml, example; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`"
542542
runs-on: ubuntu-latest
543543
steps:
544544
- name: Cache Pub hosted dependencies
545545
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7
546546
with:
547547
path: "~/.pub-cache/hosted"
548-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0;packages:_test_yaml-checked_yaml-example;commands:test_1"
548+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:_test_yaml-checked_yaml-example;commands:test_1"
549549
restore-keys: |
550-
os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0;packages:_test_yaml-checked_yaml-example
551-
os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0
550+
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0;packages:_test_yaml-checked_yaml-example
551+
os:ubuntu-latest;pub-cache-hosted;sdk:2.18.0
552552
os:ubuntu-latest;pub-cache-hosted
553553
os:ubuntu-latest
554554
- name: Setup Dart SDK
555555
uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d
556556
with:
557-
sdk: "2.17.0"
557+
sdk: "2.18.0"
558558
- id: checkout
559559
name: Checkout repository
560560
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8

_test_yaml/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: _test_yaml
22
publish_to: none
33

44
environment:
5-
sdk: '>=2.17.0 <3.0.0'
5+
sdk: '>=2.18.0 <3.0.0'
66

77
dev_dependencies:
88
_json_serial_shared_test:

checked_yaml/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## 2.0.2-dev
22

33
- Require `json_annotation` `^4.3.0`
4-
- Require Dart SDK `>=2.17`
4+
- Require Dart SDK `>=2.18`
55

66
## 2.0.1
77

checked_yaml/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: >-
66
package:json_serializable and package:yaml.
77
repository: https://github.com/google/json_serializable.dart/tree/master/checked_yaml
88
environment:
9-
sdk: '>=2.17.0 <3.0.0'
9+
sdk: '>=2.18.0 <3.0.0'
1010

1111
dependencies:
1212
json_annotation: ^4.3.0

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: example
22
publish_to: none
33

44
environment:
5-
sdk: '>=2.17.0 <3.0.0'
5+
sdk: '>=2.18.0 <3.0.0'
66

77
dependencies:
88
json_annotation: ^4.7.0

json_annotation/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- Update `JsonKey` documentation to align with new features in
44
`package:json_serializable`.
5+
- Require Dart SDK `>=2.18.0`.
56

67
## 4.7.0
78

json_annotation/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: >-
66
repository: https://github.com/google/json_serializable.dart/tree/master/json_annotation
77

88
environment:
9-
sdk: '>=2.17.0 <3.0.0'
9+
sdk: '>=2.18.0 <3.0.0'
1010

1111
dependencies:
1212
meta: ^1.4.0

json_serializable/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 6.6.0-dev
2+
3+
- Require Dart SDK `>=2.18.0`.
4+
- Require `analyzer: ^5.2.0`
5+
16
## 6.5.4
27

38
- Fixed handling of nullable fields with converters which return non-nullable
@@ -20,7 +25,7 @@
2025
## 6.5.0
2126

2227
- Allow constructors to be passed to `JsonKey` parameters that support
23-
`Function` types.
28+
`Function` types.
2429
- Accept `Function` values for `JsonKey.defaultValue`. The provided
2530
`Function` will be invoked for the default value if the target JSON element is
2631
missing or `null`.

json_serializable/lib/src/enum_utils.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import 'json_literal_generator.dart';
1313
import 'utils.dart';
1414

1515
String constMapName(DartType targetType) =>
16-
'_\$${targetType.element2!.name}EnumMap';
16+
'_\$${targetType.element!.name}EnumMap';
1717

1818
/// If [targetType] is not an enum, return `null`.
1919
///
@@ -41,7 +41,7 @@ String? enumValueMapFromType(
4141
if (enumMap == null) return null;
4242

4343
final items = enumMap.entries
44-
.map((e) => ' ${targetType.element2!.name}.${e.key.name}: '
44+
.map((e) => ' ${targetType.element!.name}.${e.key.name}: '
4545
'${jsonLiteralAsDart(e.value)},')
4646
.join();
4747

@@ -52,7 +52,7 @@ Map<FieldElement, Object?>? _enumMap(
5252
DartType targetType, {
5353
bool nullWithNoAnnotation = false,
5454
}) {
55-
final annotation = _jsonEnumChecker.firstAnnotationOf(targetType.element2!);
55+
final annotation = _jsonEnumChecker.firstAnnotationOf(targetType.element!);
5656
final jsonEnum = _fromAnnotation(annotation);
5757

5858
final enumFields = iterateEnumFields(targetType);
@@ -84,7 +84,7 @@ Object? _generateEntry({
8484
if (valueField != null) {
8585
// TODO: fieldRename is pointless here!!! At least log a warning!
8686

87-
final fieldElementType = field.type.element2 as EnumElement;
87+
final fieldElementType = field.type.element as EnumElement;
8888

8989
final e = fieldElementType.getField(valueField);
9090

@@ -93,7 +93,7 @@ Object? _generateEntry({
9393
'`JsonEnum.valueField` was set to "$valueField", but '
9494
'that is not a valid, instance field on '
9595
'`${typeToCode(targetType)}`.',
96-
element: targetType.element2,
96+
element: targetType.element,
9797
);
9898
}
9999

@@ -105,7 +105,7 @@ Object? _generateEntry({
105105
throw InvalidGenerationSourceError(
106106
'`JsonEnum.valueField` was set to "$valueField", but '
107107
'that field does not have a type of String, int, or null.',
108-
element: targetType.element2,
108+
element: targetType.element,
109109
);
110110
}
111111
} else {

json_serializable/lib/src/field_helpers.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ class _FieldSet implements Comparable<_FieldSet> {
3737

3838
static int _sortByLocation(FieldElement a, FieldElement b) {
3939
final checkerA = TypeChecker.fromStatic(
40-
(a.enclosingElement3 as InterfaceElement).thisType,
40+
(a.enclosingElement as InterfaceElement).thisType,
4141
);
4242

43-
if (!checkerA.isExactly(b.enclosingElement3)) {
43+
if (!checkerA.isExactly(b.enclosingElement)) {
4444
// in this case, you want to prioritize the enclosingElement that is more
4545
// "super".
4646

47-
if (checkerA.isAssignableFrom(b.enclosingElement3)) {
47+
if (checkerA.isAssignableFrom(b.enclosingElement)) {
4848
return -1;
4949
}
5050

5151
final checkerB = TypeChecker.fromStatic(
52-
(b.enclosingElement3 as InterfaceElement).thisType);
52+
(b.enclosingElement as InterfaceElement).thisType);
5353

54-
if (checkerB.isAssignableFrom(a.enclosingElement3)) {
54+
if (checkerB.isAssignableFrom(a.enclosingElement)) {
5555
return 1;
5656
}
5757
}
@@ -83,7 +83,7 @@ Iterable<FieldElement> createSortedFieldSet(ClassElement element) {
8383

8484
for (final v in manager.getInheritedConcreteMap2(element).values) {
8585
assert(v is! FieldElement);
86-
if (_dartCoreObjectChecker.isExactly(v.enclosingElement3)) {
86+
if (_dartCoreObjectChecker.isExactly(v.enclosingElement)) {
8787
continue;
8888
}
8989

0 commit comments

Comments
 (0)