From 980f3e117a2b42e067e40029144935fb1e9c6ed0 Mon Sep 17 00:00:00 2001 From: Rexios Date: Sat, 6 Jul 2024 10:29:45 -0400 Subject: [PATCH 1/6] Working on adding Target annotations --- hive/lib/src/annotations/hive_field.dart | 7 +++++++ hive/lib/src/annotations/hive_type.dart | 1 + 2 files changed, 8 insertions(+) diff --git a/hive/lib/src/annotations/hive_field.dart b/hive/lib/src/annotations/hive_field.dart index c8e06d67..28583a20 100644 --- a/hive/lib/src/annotations/hive_field.dart +++ b/hive/lib/src/annotations/hive_field.dart @@ -1,6 +1,13 @@ part of '../../hive.dart'; /// Annotate all fields you want to persist with [HiveField]. +// TODO: Enable when Flutter supports analyser 6.5.0 +// @Target({ +// TargetKind.field, +// TargetKind.getter, +// TargetKind.setter, +// TargetKind.enumValue, +// }) class HiveField { /// The index of this field. final int index; diff --git a/hive/lib/src/annotations/hive_type.dart b/hive/lib/src/annotations/hive_type.dart index 5e59f1eb..f7df158c 100644 --- a/hive/lib/src/annotations/hive_type.dart +++ b/hive/lib/src/annotations/hive_type.dart @@ -1,6 +1,7 @@ part of '../../hive.dart'; /// Annotate classes with [HiveType] to generate a `TypeAdapter`. +@Target({TargetKind.classType, TargetKind.enumType}) class HiveType { /// The typeId of the annotated class. final int typeId; From 81b720d628009ce9c4c00dd38b8a9740c2c806e6 Mon Sep 17 00:00:00 2001 From: Rexios Date: Sat, 6 Jul 2024 10:36:55 -0400 Subject: [PATCH 2/6] Migration for analyzer 6.5.0 --- hive/lib/hive.dart | 1 + hive/lib/src/annotations/hive_field.dart | 13 +++++----- hive_generator/lib/src/class_builder.dart | 4 +-- .../lib/src/type_adapter_generator.dart | 25 ++++++------------- 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/hive/lib/hive.dart b/hive/lib/hive.dart index 92fc9687..5f2dfa27 100644 --- a/hive/lib/hive.dart +++ b/hive/lib/hive.dart @@ -17,6 +17,7 @@ import 'package:hive_ce/src/object/hive_list_impl.dart'; import 'package:hive_ce/src/object/hive_object.dart'; import 'package:hive_ce/src/util/extensions.dart'; import 'package:meta/meta.dart'; +import 'package:meta/meta_meta.dart'; export 'src/box_collection/box_collection_stub.dart' if (dart.library.js_interop) 'package:hive_ce/src/box_collection/box_collection_indexed_db.dart' diff --git a/hive/lib/src/annotations/hive_field.dart b/hive/lib/src/annotations/hive_field.dart index 28583a20..ba42f505 100644 --- a/hive/lib/src/annotations/hive_field.dart +++ b/hive/lib/src/annotations/hive_field.dart @@ -1,13 +1,12 @@ part of '../../hive.dart'; /// Annotate all fields you want to persist with [HiveField]. -// TODO: Enable when Flutter supports analyser 6.5.0 -// @Target({ -// TargetKind.field, -// TargetKind.getter, -// TargetKind.setter, -// TargetKind.enumValue, -// }) +@Target({ + TargetKind.field, + TargetKind.getter, + TargetKind.setter, + TargetKind.enumValue, +}) class HiveField { /// The index of this field. final int index; diff --git a/hive_generator/lib/src/class_builder.dart b/hive_generator/lib/src/class_builder.dart index 3faec4c0..70f7048b 100644 --- a/hive_generator/lib/src/class_builder.dart +++ b/hive_generator/lib/src/class_builder.dart @@ -223,7 +223,5 @@ String _suffixFromType(DartType type) { String _displayString(DartType e) { final suffix = _suffixFromType(e); - // TODO: Update when Flutter supports analyser 6.5.0 - // ignore: deprecated_member_use - return '${e.getDisplayString(withNullability: false)}$suffix'; + return '${e.getDisplayString()}$suffix'; } diff --git a/hive_generator/lib/src/type_adapter_generator.dart b/hive_generator/lib/src/type_adapter_generator.dart index a001e0f5..0cdc42f8 100644 --- a/hive_generator/lib/src/type_adapter_generator.dart +++ b/hive_generator/lib/src/type_adapter_generator.dart @@ -90,18 +90,12 @@ class TypeAdapterGenerator extends GeneratorForAnnotation { final getters = []; final setters = []; for (final name in accessorNames) { - // TODO: Update when Flutter supports analyser 6.5.0 - // ignore: deprecated_member_use - final getter = cls.lookUpGetter(name, library); + final getter = cls.augmented.lookUpGetter(name: name, library: library); if (getter != null) { final getterAnn = - // TODO: Update when Flutter supports analyser 6.5.0 - // ignore: deprecated_member_use - getHiveFieldAnn(getter.variable) ?? getHiveFieldAnn(getter); + getHiveFieldAnn(getter.variable2) ?? getHiveFieldAnn(getter); if (getterAnn != null) { - // TODO: Update when Flutter supports analyser 6.5.0 - // ignore: deprecated_member_use - final field = getter.variable; + final field = getter.variable2!; getters.add( AdapterField( getterAnn.index, @@ -113,18 +107,13 @@ class TypeAdapterGenerator extends GeneratorForAnnotation { } } - // TODO: Update when Flutter supports analyser 6.5.0 - // ignore: deprecated_member_use - final setter = cls.lookUpSetter('$name=', library); + final setter = + cls.augmented.lookUpSetter(name: '$name=', library: library); if (setter != null) { final setterAnn = - // TODO: Update when Flutter supports analyser 6.5.0 - // ignore: deprecated_member_use - getHiveFieldAnn(setter.variable) ?? getHiveFieldAnn(setter); + getHiveFieldAnn(setter.variable2) ?? getHiveFieldAnn(setter); if (setterAnn != null) { - // TODO: Update when Flutter supports analyser 6.5.0 - // ignore: deprecated_member_use - final field = setter.variable; + final field = setter.variable2!; setters.add( AdapterField( setterAnn.index, From 91408109a6c4c64034e1f07ecd26f37925ea399e Mon Sep 17 00:00:00 2001 From: Rexios Date: Sat, 6 Jul 2024 10:44:52 -0400 Subject: [PATCH 3/6] Update analyzer version --- hive_generator/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hive_generator/pubspec.yaml b/hive_generator/pubspec.yaml index e4428d9d..44d480c6 100644 --- a/hive_generator/pubspec.yaml +++ b/hive_generator/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: build: ^2.0.0 source_gen: ^1.0.0 hive_ce: ^2.4.0 - analyzer: ^6.0.0 + analyzer: ^6.5.0 source_helper: ^1.1.0 glob: ^2.1.2 path: ^1.9.0 From d4c2f32a8f416c94b495fabc75f2d48c958a122f Mon Sep 17 00:00:00 2001 From: Rexios Date: Sat, 6 Jul 2024 11:06:28 -0400 Subject: [PATCH 4/6] Tighten dependency constraints --- hive/pubspec.yaml | 4 ++-- hive_flutter/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hive/pubspec.yaml b/hive/pubspec.yaml index 86dfd9e3..43606f95 100644 --- a/hive/pubspec.yaml +++ b/hive/pubspec.yaml @@ -8,7 +8,7 @@ environment: sdk: ^3.4.0 dependencies: - meta: ^1.3.0 + meta: ^1.14.0 crypto: ^3.0.0 web: ^0.5.1 @@ -17,5 +17,5 @@ dev_dependencies: mocktail: ^1.0.4 rexios_lints: ^7.0.0 path: ^1.7.0 - pointycastle: ^3.0.1 + pointycastle: ^3.4.0 build_runner: ^2.1.2 diff --git a/hive_flutter/pubspec.yaml b/hive_flutter/pubspec.yaml index 2c23d39d..3290440c 100644 --- a/hive_flutter/pubspec.yaml +++ b/hive_flutter/pubspec.yaml @@ -18,5 +18,5 @@ dependencies: dev_dependencies: test: ^1.21.1 rexios_lints: ^7.0.0 - mockito: ^5.2.0 + mockito: ^5.4.1 build_runner: ^2.1.11 From 97eb63469a9f70b55a337612ededada61f19d0dc Mon Sep 17 00:00:00 2001 From: Rexios Date: Sat, 6 Jul 2024 11:08:27 -0400 Subject: [PATCH 5/6] Use `TargetKind.type` for `HiveType` Target --- hive/lib/src/annotations/hive_type.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hive/lib/src/annotations/hive_type.dart b/hive/lib/src/annotations/hive_type.dart index f7df158c..41760351 100644 --- a/hive/lib/src/annotations/hive_type.dart +++ b/hive/lib/src/annotations/hive_type.dart @@ -1,7 +1,7 @@ part of '../../hive.dart'; /// Annotate classes with [HiveType] to generate a `TypeAdapter`. -@Target({TargetKind.classType, TargetKind.enumType}) +@Target({TargetKind.type}) class HiveType { /// The typeId of the annotated class. final int typeId; From 923dc5dbf8166421683464cce32eaf8c1a56cd71 Mon Sep 17 00:00:00 2001 From: Rexios Date: Tue, 6 Aug 2024 17:32:22 -0400 Subject: [PATCH 6/6] Preparing for release --- hive/CHANGELOG.md | 6 ++++++ hive/pubspec.yaml | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hive/CHANGELOG.md b/hive/CHANGELOG.md index c17991b0..19b36dec 100644 --- a/hive/CHANGELOG.md +++ b/hive/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2.5.0 + +- Adds `Target` annotations to `HiveField` and `HiveType` to prevent invalid usage +- Bumps `analyzer` to `^6.5.0` to deal with deprecations +- Bumps `meta` to `^1.14.0` for `TargetKind.enumValue` + ## 2.4.4 - Loosens constraint on `web` diff --git a/hive/pubspec.yaml b/hive/pubspec.yaml index ef4e8138..5e188028 100644 --- a/hive/pubspec.yaml +++ b/hive/pubspec.yaml @@ -1,6 +1,6 @@ name: hive_ce description: Hive Community Edition - A spiritual continuation of Hive v2 -version: 2.4.4 +version: 2.5.0 homepage: https://github.com/IO-Design-Team/hive_ce/tree/main/hive documentation: https://docs.hivedb.dev/ @@ -8,7 +8,7 @@ environment: sdk: ^3.4.0 dependencies: - meta: ^1.12.0 + meta: ^1.14.0 crypto: ^3.0.0 web: ">=0.5.0 <2.0.0"