diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 41dade2..7e796f8 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -9,5 +9,4 @@ dependencies: dev_dependencies: build_runner: - build_resolvers: functional_data_generator: diff --git a/functional_data_generator/CHANGELOG.md b/functional_data_generator/CHANGELOG.md index 5529225..152262c 100644 --- a/functional_data_generator/CHANGELOG.md +++ b/functional_data_generator/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.2.2 + +- Update analyzer dependency to `^8.0.0` + ## 2.2.1 - Update analyzer dependency to `^7.4.0` diff --git a/functional_data_generator/lib/builder.dart b/functional_data_generator/lib/builder.dart index 37a59ed..f50128e 100644 --- a/functional_data_generator/lib/builder.dart +++ b/functional_data_generator/lib/builder.dart @@ -1,7 +1,7 @@ import 'dart:io'; import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:build/build.dart'; import 'package:collection/collection.dart'; import 'package:functional_data/functional_data.dart'; @@ -12,7 +12,7 @@ Builder functionalData(BuilderOptions options) => SharedPartBuilder([FunctionalD class FunctionalDataGenerator extends GeneratorForAnnotation { @override - Future generateForAnnotatedElement(Element2 element, ConstantReader annotation, BuildStep buildStep) => + Future generateForAnnotatedElement(Element element, ConstantReader annotation, BuildStep buildStep) => _generateDataType(element, annotation, buildStep); } @@ -39,8 +39,8 @@ class Pair { final S second; } -Future _generateDataType(Element2 element, ConstantReader annotation, BuildStep buildStep) async { - if (element is! ClassElement2) { +Future _generateDataType(Element element, ConstantReader annotation, BuildStep buildStep) async { + if (element is! ClassElement) { throw Exception('FunctionalData annotation must only be used on classes'); } @@ -63,26 +63,25 @@ Future _generateDataType(Element2 element, ConstantReader annotation, Bu throw Exception('[$element]: generateLenses requires copyWith to be generated'); } - final className = (element.name3 ?? '').replaceAll('\$', ''); + final className = (element.name ?? '').replaceAll('\$', ''); final classElement = element; // The one that can be used to specify every field - final genericConstructor = classElement.constructors2.firstWhere((element) => element.name3 == 'new'); - final positionalFields = - genericConstructor.formalParameters.where((p) => p.isPositional).map((p) => p.name3).toList(); + final genericConstructor = classElement.constructors.firstWhere((element) => element.name == 'new'); + final positionalFields = genericConstructor.formalParameters.where((p) => p.isPositional).map((p) => p.name).toList(); final fieldsWithIndex = - await Future.wait(classElement.fields2.where((f) => !f.isSynthetic && !f.isStatic).map((f) async { + await Future.wait(classElement.fields.where((f) => !f.isSynthetic && !f.isStatic).map((f) async { final declaration = await buildStep.resolver.astNodeFor(f.firstFragment) as VariableDeclaration?; final declarationList = declaration?.parent as VariableDeclarationList?; - final positionalIndex = positionalFields.indexOf(f.name3); + final positionalIndex = positionalFields.indexOf(f.name); return Pair( positionalIndex == -1 ? 9999 : positionalIndex, Field( - f.name3 ?? '', + f.name ?? '', declarationList?.type?.toSource() ?? 'dynamic', - _getCustomEquality(f.metadata2.annotations), + _getCustomEquality(f.metadata.annotations), isPositional: positionalIndex != -1, ), ); diff --git a/functional_data_generator/pubspec.yaml b/functional_data_generator/pubspec.yaml index c291a1c..bb4e45b 100644 --- a/functional_data_generator/pubspec.yaml +++ b/functional_data_generator/pubspec.yaml @@ -1,5 +1,5 @@ name: functional_data_generator -version: 2.2.1 +version: 2.2.2 description: >- Simple and non-intrusive code generator for boilerplate of data types. homepage: https://github.com/spkersten/dart_functional_data @@ -8,13 +8,12 @@ environment: sdk: '>=2.19.0 <4.0.0' dependencies: - analyzer: '^7.4.0' - build: ^3.0.0 + analyzer: '^8.0.0' + build: ^4.0.0 collection: ^1.15.0 functional_data: ^1.1.1 - source_gen: ^3.1.0 + source_gen: ^4.0.0 yaml: ^3.1.2 dev_dependencies: - build_resolvers: "^3.0.2" - build_runner: ^2.2.0 \ No newline at end of file + build_runner: ^2.10.4 \ No newline at end of file