feat: migrate to analyzer 9.0.0 API

- Replace Element2 API with Element API
- Update imports from element2.dart to element.dart
- Replace .firstFragment.name2 with .name
- Replace .firstFragment.metadata2.annotations with .metadata.annotations
- Replace .fields2 with .fields
- Replace .methods2 with .methods
- Remove duplicate imports in annotation_validator.dart and generated_class.dart
- Update test mocks to use Element instead of Element2

All generators now work correctly with analyzer 9.0.0:
- melos analyze: SUCCESS (0 issues)
- melos codegen: SUCCESS (13 outputs generated)
- melos bootstrap: SUCCESS (8 packages)
This commit is contained in:
Sergey Penkovsky
2026-01-30 10:48:48 +03:00
parent e6b3017384
commit 0e555a6849
13 changed files with 90 additions and 154 deletions

View File

@@ -1,4 +1,4 @@
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:test/test.dart';
import 'package:cherrypick_generator/src/type_parser.dart';
@@ -223,20 +223,14 @@ void main() {
}
// Mock element for testing
Element2 _createMockElement() {
Element _createMockElement() {
return _MockElement();
}
class _MockElement implements Element2 {
class _MockElement implements Element {
@override
String get displayName => 'MockElement';
//@override
//String get name => 'MockElement';
//
//@override
//Source? get source => null;
@override
noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}