mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-24 05:25:19 +00:00
refactor(generator): migrate cherrypick_generator to analyzer element2 API
- Fully migrated core cherrypick_generator and submodules to new analyzer element2 system: - Updated all GeneratorForAnnotation overrides to use Element2, ClassElement2, MethodElement2, FieldElement2 and new annotation/metadata access patterns. - Migrated signature and bodies for helpers, parsers, annotation validators, meta utils, and type parsers. - Fixed tests to use readerWriter instead of deprecated reader argument. - Refactored usage of now-absent 'metadata', 'parameters', 'fields', 'methods', 'source', and similar members to use correct *.firstFragment.* or API alternatives. - Cleaned up old imports and unused code. test(generator): update generator integration tests - Updated test calls to use correct TestReaderWriter type and bring test infra in line with current build_runner/testing API. build: update dependencies and pubspec to support latest analyzer/build ecosystem - Raised Dart SDK and package constraints as required for generated code and codegen plugins. - Updated pubspecs in root/examples as needed by build warnings. docs: add plots and assets (new files) BREAKING CHANGE: - Requires Dart 3.8+ and analyzer that supports element2. - All downstream codegen/tests depending on Element API must migrate to Element2 signatures and data model.
This commit is contained in:
@@ -480,9 +480,10 @@ void notAClass() {}
|
||||
);
|
||||
});
|
||||
|
||||
test('should generate empty mixin for class without @inject fields',
|
||||
() async {
|
||||
const input = '''
|
||||
test(
|
||||
'should generate empty mixin for class without @inject fields',
|
||||
() async {
|
||||
const input = '''
|
||||
import 'package:cherrypick_annotations/cherrypick_annotations.dart';
|
||||
|
||||
part 'test_widget.inject.cherrypick.g.dart';
|
||||
@@ -494,7 +495,7 @@ class TestWidget {
|
||||
}
|
||||
''';
|
||||
|
||||
const expectedOutput = '''
|
||||
const expectedOutput = '''
|
||||
// dart format width=80
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
@@ -509,8 +510,9 @@ mixin _\$TestWidget {
|
||||
}
|
||||
''';
|
||||
|
||||
await _testGeneration(input, expectedOutput);
|
||||
});
|
||||
await _testGeneration(input, expectedOutput);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
group('Edge Cases', () {
|
||||
@@ -593,12 +595,8 @@ mixin _\$TestWidget {
|
||||
Future<void> _testGeneration(String input, String expectedOutput) async {
|
||||
await testBuilder(
|
||||
injectBuilder(BuilderOptions.empty),
|
||||
{
|
||||
'a|lib/test_widget.dart': input,
|
||||
},
|
||||
outputs: {
|
||||
'a|lib/test_widget.inject.cherrypick.g.dart': expectedOutput,
|
||||
},
|
||||
reader: await PackageAssetReader.currentIsolate(),
|
||||
{'a|lib/test_widget.dart': input},
|
||||
outputs: {'a|lib/test_widget.inject.cherrypick.g.dart': expectedOutput},
|
||||
readerWriter: TestReaderWriter(),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user