Skip to content

Commit

Permalink
Merge pull request #7 from IO-Design-Team/feature/analyzer-6.5.0
Browse files Browse the repository at this point in the history
Migration for analyzer 6.5.0
  • Loading branch information
Rexios80 authored Aug 6, 2024
2 parents 49f6ef3 + 923dc5d commit 67e33c2
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 24 deletions.
6 changes: 6 additions & 0 deletions hive/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
1 change: 1 addition & 0 deletions hive/lib/hive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 6 additions & 0 deletions hive/lib/src/annotations/hive_field.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
part of '../../hive.dart';

/// Annotate all fields you want to persist with [HiveField].
@Target({
TargetKind.field,
TargetKind.getter,
TargetKind.setter,
TargetKind.enumValue,
})
class HiveField {
/// The index of this field.
final int index;
Expand Down
1 change: 1 addition & 0 deletions hive/lib/src/annotations/hive_type.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
part of '../../hive.dart';

/// Annotate classes with [HiveType] to generate a `TypeAdapter`.
@Target({TargetKind.type})
class HiveType {
/// The typeId of the annotated class.
final int typeId;
Expand Down
4 changes: 2 additions & 2 deletions hive/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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/

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"

Expand Down
4 changes: 1 addition & 3 deletions hive_generator/lib/src/class_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
25 changes: 7 additions & 18 deletions hive_generator/lib/src/type_adapter_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,12 @@ class TypeAdapterGenerator extends GeneratorForAnnotation<HiveType> {
final getters = <AdapterField>[];
final setters = <AdapterField>[];
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,
Expand All @@ -113,18 +107,13 @@ class TypeAdapterGenerator extends GeneratorForAnnotation<HiveType> {
}
}

// 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,
Expand Down
2 changes: 1 addition & 1 deletion hive_generator/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 67e33c2

Please sign in to comment.