diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..b1f2a0c3 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +**/*.*.dart linguist-generated=true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index daf488d0..0a7755c1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,20 +16,25 @@ jobs: strategy: matrix: package: + - benchmarks/ - packages/freezed - packages/freezed/example - packages/freezed_annotation - packages/freezed_lint + - packages/freezed_lint/example channel: + - master - stable dependencies: - get - downgrade exclude: - - channel: stable + - channel: master dependencies: downgrade - - package: packages/freezed_lint - channel: stable + + defaults: + run: + working-directory: ${{ matrix.package }} steps: - uses: actions/checkout@v5 @@ -37,50 +42,34 @@ jobs: - uses: subosito/flutter-action@v2 with: channel: ${{ matrix.channel }} - cache: ${{ matrix.channel == 'stable' }} - - # It is executed separately - - name: Removing example folder - # Retain example for lint golden test - if: matrix.package != 'packages/freezed_lint' - run: rm -rf example - working-directory: ${{ matrix.package }} + cache: ${{ matrix.channel == 'master' }} - name: Install dependencies - run: | - flutter pub ${{ matrix.dependencies }} - working-directory: ${{ matrix.package }} + run: flutter pub ${{ matrix.dependencies }} - name: Check format # Check dart format only on stable if: matrix.channel == 'stable' run: dart format --set-exit-if-changed . - working-directory: ${{ matrix.package }} - name: Generate - run: | - if grep -q build_runner "pubspec.yaml"; then - dart pub run build_runner build --delete-conflicting-outputs - fi - working-directory: ${{ matrix.package }} + if: matrix.package != 'packages/freezed_lint/example' + continue-on-error: true + run: dart run build_runner build --delete-conflicting-outputs - name: Analyze - run: flutter analyze + run: flutter analyze --fatal-infos working-directory: ${{ matrix.package }} - name: Run tests run: | - if grep -q "name: example" "pubspec.yaml"; then + if grep -q "flutter_test:" "pubspec.yaml"; then flutter test - else + elif grep -q "test:" "pubspec.yaml"; then dart test fi working-directory: ${{ matrix.package }} - name: Lint golden test - if: matrix.package == 'packages/freezed_lint' - run: | - dart pub get - dart analyze - dart run custom_lint - working-directory: 'packages/freezed_lint/example' + if: matrix.package == 'packages/freezed_lint/example' + run: dart run custom_lint --fatal-infos diff --git a/.gitignore b/.gitignore index b4db8079..84af905e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ +.dart_tool .idea/ *.iml build/ node_modules -/package-lock.json \ No newline at end of file +/package-lock.json diff --git a/benchmarks/.gitignore b/benchmarks/.gitignore index 220a573b..637a17cb 100644 --- a/benchmarks/.gitignore +++ b/benchmarks/.gitignore @@ -1,6 +1,3 @@ -/.dart_tool /test/**/*.g.dart /test/**/*.freezed.dart .packages -# Remove the following pattern if you wish to check in your lock file -pubspec.lock \ No newline at end of file diff --git a/benchmarks/lib/src/copy_with.dart b/benchmarks/lib/src/copy_with.dart index 2684bdf1..34c2e69c 100644 --- a/benchmarks/lib/src/copy_with.dart +++ b/benchmarks/lib/src/copy_with.dart @@ -11,9 +11,7 @@ abstract class Model with _$Model { @freezed abstract class ModelWrapper with _$ModelWrapper { - factory ModelWrapper({ - required Model model, - }) = _ModelWrapper; + factory ModelWrapper({required Model model}) = _ModelWrapper; } void main(List arguments) { diff --git a/benchmarks/lib/src/copy_with.freezed.dart b/benchmarks/lib/src/copy_with.freezed.dart index d39b5892..9f3bbc6b 100644 --- a/benchmarks/lib/src/copy_with.freezed.dart +++ b/benchmarks/lib/src/copy_with.freezed.dart @@ -1,6 +1,5 @@ -// dart format width=80 -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark diff --git a/benchmarks/lib/src/equal.freezed.dart b/benchmarks/lib/src/equal.freezed.dart index 4205236b..29c84df8 100644 --- a/benchmarks/lib/src/equal.freezed.dart +++ b/benchmarks/lib/src/equal.freezed.dart @@ -1,6 +1,5 @@ -// dart format width=80 -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark diff --git a/benchmarks/pubspec.yaml b/benchmarks/pubspec.yaml index ca1220ad..1ad764e7 100644 --- a/benchmarks/pubspec.yaml +++ b/benchmarks/pubspec.yaml @@ -1,27 +1,19 @@ -name: example +name: freezed_benchmarks description: A new Flutter project. publish_to: none environment: sdk: ^3.5.0 +resolution: workspace + dependencies: flutter: sdk: flutter - freezed_annotation: - path: ../packages/freezed_annotation - json_annotation: ^4.4.0 + freezed_annotation: ^3.0.0 + json_annotation: ^4.9.0 dev_dependencies: - freezed: - path: ../packages/freezed + freezed: ^3.0.2 json_serializable: ^6.1.3 build_runner: - flutter_test: - sdk: flutter - -dependency_overrides: - freezed: - path: ../packages/freezed - freezed_annotation: - path: ../packages/freezed_annotation diff --git a/packages/freezed/.gitignore b/packages/freezed/.gitignore index 220a573b..637a17cb 100644 --- a/packages/freezed/.gitignore +++ b/packages/freezed/.gitignore @@ -1,6 +1,3 @@ -/.dart_tool /test/**/*.g.dart /test/**/*.freezed.dart .packages -# Remove the following pattern if you wish to check in your lock file -pubspec.lock \ No newline at end of file diff --git a/packages/freezed/build.yaml b/packages/freezed/build.yaml index f31ada05..c2570540 100644 --- a/packages/freezed/build.yaml +++ b/packages/freezed/build.yaml @@ -1,11 +1,15 @@ targets: $default: + sources: + exclude: + - example/* + - example/**/* + builders: freezed: enabled: true generate_for: exclude: - - example - test/source_gen_src.dart include: - test/* diff --git a/packages/freezed/example/.gitignore b/packages/freezed/example/.gitignore index 91ca32d6..ae1f1838 100644 --- a/packages/freezed/example/.gitignore +++ b/packages/freezed/example/.gitignore @@ -1,6 +1,3 @@ -*.freezed.dart -*.g.dart - # Miscellaneous *.class *.log diff --git a/packages/freezed/example/build.yaml b/packages/freezed/example/build.yaml index f8d0d73e..12b3f2d9 100644 --- a/packages/freezed/example/build.yaml +++ b/packages/freezed/example/build.yaml @@ -5,3 +5,5 @@ targets: options: union_key: custom-key union_value_case: pascal + map: false + when: false diff --git a/packages/freezed/example/lib/diagnosticable.freezed.dart b/packages/freezed/example/lib/diagnosticable.freezed.dart new file mode 100644 index 00000000..eb89e255 --- /dev/null +++ b/packages/freezed/example/lib/diagnosticable.freezed.dart @@ -0,0 +1,327 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'diagnosticable.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$Example implements DiagnosticableTreeMixin { + + dynamic get theAnswer; + + +@override +void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('type', 'Example<$T>')) + ..add(DiagnosticsProperty('theAnswer', theAnswer)); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Example&&const DeepCollectionEquality().equals(other.theAnswer, theAnswer)); +} + + +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(theAnswer)); + +@override +String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) { + return 'Example<$T>(theAnswer: $theAnswer)'; +} + + +} + +/// @nodoc +class $ExampleCopyWith { +$ExampleCopyWith(Example _, $Res Function(Example) __); +} + + + +/// @nodoc + + +class _Example extends Example with DiagnosticableTreeMixin { + _Example(this.a, this.b): super._(); + + + final int a; + final String b; + +/// Create a copy of Example +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ExampleCopyWith> get copyWith => __$ExampleCopyWithImpl>(this, _$identity); + + +@override +void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('type', 'Example<$T>')) + ..add(DiagnosticsProperty('a', a))..add(DiagnosticsProperty('b', b)); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Example&&(identical(other.a, a) || other.a == a)&&(identical(other.b, b) || other.b == b)); +} + + +@override +int get hashCode => Object.hash(runtimeType,a,b); + +@override +String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) { + return 'Example<$T>(a: $a, b: $b)'; +} + + +} + +/// @nodoc +abstract mixin class _$ExampleCopyWith implements $ExampleCopyWith { + factory _$ExampleCopyWith(_Example value, $Res Function(_Example) _then) = __$ExampleCopyWithImpl; +@useResult +$Res call({ + int a, String b +}); + + + + +} +/// @nodoc +class __$ExampleCopyWithImpl + implements _$ExampleCopyWith { + __$ExampleCopyWithImpl(this._self, this._then); + + final _Example _self; + final $Res Function(_Example) _then; + +/// Create a copy of Example +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? a = null,Object? b = null,}) { + return _then(_Example( +null == a ? _self.a : a // ignore: cast_nullable_to_non_nullable +as int,null == b ? _self.b : b // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +/// @nodoc + + +class _Example2 extends Example with DiagnosticableTreeMixin { + _Example2(this.c): super._(); + + + final T c; + +/// Create a copy of Example +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$Example2CopyWith> get copyWith => __$Example2CopyWithImpl>(this, _$identity); + + +@override +void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('type', 'Example<$T>.named')) + ..add(DiagnosticsProperty('c', c)); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Example2&&const DeepCollectionEquality().equals(other.c, c)); +} + + +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(c)); + +@override +String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) { + return 'Example<$T>.named(c: $c)'; +} + + +} + +/// @nodoc +abstract mixin class _$Example2CopyWith implements $ExampleCopyWith { + factory _$Example2CopyWith(_Example2 value, $Res Function(_Example2) _then) = __$Example2CopyWithImpl; +@useResult +$Res call({ + T c +}); + + + + +} +/// @nodoc +class __$Example2CopyWithImpl + implements _$Example2CopyWith { + __$Example2CopyWithImpl(this._self, this._then); + + final _Example2 _self; + final $Res Function(_Example2) _then; + +/// Create a copy of Example +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? c = freezed,}) { + return _then(_Example2( +freezed == c ? _self.c : c // ignore: cast_nullable_to_non_nullable +as T, + )); +} + + +} + +/// @nodoc +mixin _$ConcreteExample implements DiagnosticableTreeMixin { + + + + +@override +void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('type', 'ConcreteExample<$T>')) + ; +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is ConcreteExample); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) { + return 'ConcreteExample<$T>()'; +} + + +} + +/// @nodoc +class $ConcreteExampleCopyWith { +$ConcreteExampleCopyWith(ConcreteExample _, $Res Function(ConcreteExample) __); +} + + + +/// @nodoc + + +class _ConcreteExample extends ConcreteExample with DiagnosticableTreeMixin { + _ConcreteExample(): super._(); + + + + + + +@override +void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('type', 'ConcreteExample<$T>')) + ; +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ConcreteExample); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) { + return 'ConcreteExample<$T>()'; +} + + +} + + + + +/// @nodoc +mixin _$ToString { + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is ToString); +} + + +@override +int get hashCode => runtimeType.hashCode; + + + +} + +/// @nodoc +class $ToStringCopyWith<$Res> { +$ToStringCopyWith(ToString _, $Res Function(ToString) __); +} + + + +/// @nodoc + + +class _ToString extends ToString { + _ToString(): super._(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ToString); +} + + +@override +int get hashCode => runtimeType.hashCode; + + + +} + + + + +// dart format on diff --git a/packages/freezed/example/lib/equals.freezed.dart b/packages/freezed/example/lib/equals.freezed.dart new file mode 100644 index 00000000..40f05bf9 --- /dev/null +++ b/packages/freezed/example/lib/equals.freezed.dart @@ -0,0 +1,131 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'equals.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$Equals { + + String? get name; int? get age; +/// Create a copy of Equals +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$EqualsCopyWith get copyWith => _$EqualsCopyWithImpl(this as Equals, _$identity); + + + + + +@override +String toString() { + return 'Equals(name: $name, age: $age)'; +} + + +} + +/// @nodoc +abstract mixin class $EqualsCopyWith<$Res> { + factory $EqualsCopyWith(Equals value, $Res Function(Equals) _then) = _$EqualsCopyWithImpl; +@useResult +$Res call({ + String? name, int? age +}); + + + + +} +/// @nodoc +class _$EqualsCopyWithImpl<$Res> + implements $EqualsCopyWith<$Res> { + _$EqualsCopyWithImpl(this._self, this._then); + + final Equals _self; + final $Res Function(Equals) _then; + +/// Create a copy of Equals +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? name = freezed,Object? age = freezed,}) { + return _then(_self.copyWith( +name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,age: freezed == age ? _self.age : age // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + +} + + + +/// @nodoc + + +class _Equals extends Equals { + _Equals({this.name, this.age}): super._(); + + +@override final String? name; +@override final int? age; + +/// Create a copy of Equals +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$EqualsCopyWith<_Equals> get copyWith => __$EqualsCopyWithImpl<_Equals>(this, _$identity); + + + + + +@override +String toString() { + return 'Equals(name: $name, age: $age)'; +} + + +} + +/// @nodoc +abstract mixin class _$EqualsCopyWith<$Res> implements $EqualsCopyWith<$Res> { + factory _$EqualsCopyWith(_Equals value, $Res Function(_Equals) _then) = __$EqualsCopyWithImpl; +@override @useResult +$Res call({ + String? name, int? age +}); + + + + +} +/// @nodoc +class __$EqualsCopyWithImpl<$Res> + implements _$EqualsCopyWith<$Res> { + __$EqualsCopyWithImpl(this._self, this._then); + + final _Equals _self; + final $Res Function(_Equals) _then; + +/// Create a copy of Equals +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = freezed,Object? age = freezed,}) { + return _then(_Equals( +name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,age: freezed == age ? _self.age : age // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + + +} + +// dart format on diff --git a/packages/freezed/example/lib/main.freezed.dart b/packages/freezed/example/lib/main.freezed.dart new file mode 100644 index 00000000..66c4f08c --- /dev/null +++ b/packages/freezed/example/lib/main.freezed.dart @@ -0,0 +1,728 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'main.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$MyClass implements DiagnosticableTreeMixin { + + String? get a; int? get b; +/// Create a copy of MyClass +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$MyClassCopyWith get copyWith => _$MyClassCopyWithImpl(this as MyClass, _$identity); + + +@override +void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('type', 'MyClass')) + ..add(DiagnosticsProperty('a', a))..add(DiagnosticsProperty('b', b)); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is MyClass&&(identical(other.a, a) || other.a == a)&&(identical(other.b, b) || other.b == b)); +} + + +@override +int get hashCode => Object.hash(runtimeType,a,b); + +@override +String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) { + return 'MyClass(a: $a, b: $b)'; +} + + +} + +/// @nodoc +abstract mixin class $MyClassCopyWith<$Res> { + factory $MyClassCopyWith(MyClass value, $Res Function(MyClass) _then) = _$MyClassCopyWithImpl; +@useResult +$Res call({ + String? a, int? b +}); + + + + +} +/// @nodoc +class _$MyClassCopyWithImpl<$Res> + implements $MyClassCopyWith<$Res> { + _$MyClassCopyWithImpl(this._self, this._then); + + final MyClass _self; + final $Res Function(MyClass) _then; + +/// Create a copy of MyClass +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? a = freezed,Object? b = freezed,}) { + return _then(_self.copyWith( +a: freezed == a ? _self.a : a // ignore: cast_nullable_to_non_nullable +as String?,b: freezed == b ? _self.b : b // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + +} + + + +/// @nodoc + + +class _MyClass with DiagnosticableTreeMixin implements MyClass { + _MyClass({this.a, this.b}); + + +@override final String? a; +@override final int? b; + +/// Create a copy of MyClass +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$MyClassCopyWith<_MyClass> get copyWith => __$MyClassCopyWithImpl<_MyClass>(this, _$identity); + + +@override +void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('type', 'MyClass')) + ..add(DiagnosticsProperty('a', a))..add(DiagnosticsProperty('b', b)); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _MyClass&&(identical(other.a, a) || other.a == a)&&(identical(other.b, b) || other.b == b)); +} + + +@override +int get hashCode => Object.hash(runtimeType,a,b); + +@override +String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) { + return 'MyClass(a: $a, b: $b)'; +} + + +} + +/// @nodoc +abstract mixin class _$MyClassCopyWith<$Res> implements $MyClassCopyWith<$Res> { + factory _$MyClassCopyWith(_MyClass value, $Res Function(_MyClass) _then) = __$MyClassCopyWithImpl; +@override @useResult +$Res call({ + String? a, int? b +}); + + + + +} +/// @nodoc +class __$MyClassCopyWithImpl<$Res> + implements _$MyClassCopyWith<$Res> { + __$MyClassCopyWithImpl(this._self, this._then); + + final _MyClass _self; + final $Res Function(_MyClass) _then; + +/// Create a copy of MyClass +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? a = freezed,Object? b = freezed,}) { + return _then(_MyClass( +a: freezed == a ? _self.a : a // ignore: cast_nullable_to_non_nullable +as String?,b: freezed == b ? _self.b : b // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + + +} + +Union _$UnionFromJson( + Map json +) { + switch (json['custom-key']) { + case 'Default': + return Data.fromJson( + json + ); + case 'Loading': + return Loading.fromJson( + json + ); + case 'Error': + return ErrorDetails.fromJson( + json + ); + case 'Complex': + return Complex.fromJson( + json + ); + + default: + throw CheckedFromJsonException( + json, + 'custom-key', + 'Union', + 'Invalid union type "${json['custom-key']}"!' +); + } + +} + +/// @nodoc +mixin _$Union implements DiagnosticableTreeMixin { + + + + /// Serializes this Union to a JSON map. + Map toJson(); + +@override +void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('type', 'Union')) + ; +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Union); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) { + return 'Union()'; +} + + +} + +/// @nodoc +class $UnionCopyWith<$Res> { +$UnionCopyWith(Union _, $Res Function(Union) __); +} + + + +/// @nodoc +@JsonSerializable() + +class Data with DiagnosticableTreeMixin implements Union { + const Data(this.value, {final String? $type}): $type = $type ?? 'Default'; + factory Data.fromJson(Map json) => _$DataFromJson(json); + + final int value; + +@JsonKey(name: 'custom-key') +final String $type; + + +/// Create a copy of Union +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$DataCopyWith get copyWith => _$DataCopyWithImpl(this, _$identity); + +@override +Map toJson() { + return _$DataToJson(this, ); +} +@override +void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('type', 'Union')) + ..add(DiagnosticsProperty('value', value)); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Data&&(identical(other.value, value) || other.value == value)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,value); + +@override +String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) { + return 'Union(value: $value)'; +} + + +} + +/// @nodoc +abstract mixin class $DataCopyWith<$Res> implements $UnionCopyWith<$Res> { + factory $DataCopyWith(Data value, $Res Function(Data) _then) = _$DataCopyWithImpl; +@useResult +$Res call({ + int value +}); + + + + +} +/// @nodoc +class _$DataCopyWithImpl<$Res> + implements $DataCopyWith<$Res> { + _$DataCopyWithImpl(this._self, this._then); + + final Data _self; + final $Res Function(Data) _then; + +/// Create a copy of Union +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? value = null,}) { + return _then(Data( +null == value ? _self.value : value // ignore: cast_nullable_to_non_nullable +as int, + )); +} + + +} + +/// @nodoc +@JsonSerializable() + +class Loading with DiagnosticableTreeMixin implements Union { + const Loading({final String? $type}): $type = $type ?? 'Loading'; + factory Loading.fromJson(Map json) => _$LoadingFromJson(json); + + + +@JsonKey(name: 'custom-key') +final String $type; + + + +@override +Map toJson() { + return _$LoadingToJson(this, ); +} +@override +void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('type', 'Union.loading')) + ; +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Loading); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) { + return 'Union.loading()'; +} + + +} + + + + +/// @nodoc +@JsonSerializable() + +class ErrorDetails with DiagnosticableTreeMixin implements Union { + const ErrorDetails([this.message, final String? $type]): $type = $type ?? 'Error'; + factory ErrorDetails.fromJson(Map json) => _$ErrorDetailsFromJson(json); + + final String? message; + +@JsonKey(name: 'custom-key') +final String $type; + + +/// Create a copy of Union +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ErrorDetailsCopyWith get copyWith => _$ErrorDetailsCopyWithImpl(this, _$identity); + +@override +Map toJson() { + return _$ErrorDetailsToJson(this, ); +} +@override +void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('type', 'Union.error')) + ..add(DiagnosticsProperty('message', message)); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is ErrorDetails&&(identical(other.message, message) || other.message == message)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,message); + +@override +String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) { + return 'Union.error(message: $message)'; +} + + +} + +/// @nodoc +abstract mixin class $ErrorDetailsCopyWith<$Res> implements $UnionCopyWith<$Res> { + factory $ErrorDetailsCopyWith(ErrorDetails value, $Res Function(ErrorDetails) _then) = _$ErrorDetailsCopyWithImpl; +@useResult +$Res call({ + String? message +}); + + + + +} +/// @nodoc +class _$ErrorDetailsCopyWithImpl<$Res> + implements $ErrorDetailsCopyWith<$Res> { + _$ErrorDetailsCopyWithImpl(this._self, this._then); + + final ErrorDetails _self; + final $Res Function(ErrorDetails) _then; + +/// Create a copy of Union +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? message = freezed,}) { + return _then(ErrorDetails( +freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + +/// @nodoc +@JsonSerializable() + +class Complex with DiagnosticableTreeMixin implements Union { + const Complex(this.a, this.b, {final String? $type}): $type = $type ?? 'Complex'; + factory Complex.fromJson(Map json) => _$ComplexFromJson(json); + + final int a; + final String b; + +@JsonKey(name: 'custom-key') +final String $type; + + +/// Create a copy of Union +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ComplexCopyWith get copyWith => _$ComplexCopyWithImpl(this, _$identity); + +@override +Map toJson() { + return _$ComplexToJson(this, ); +} +@override +void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('type', 'Union.complex')) + ..add(DiagnosticsProperty('a', a))..add(DiagnosticsProperty('b', b)); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Complex&&(identical(other.a, a) || other.a == a)&&(identical(other.b, b) || other.b == b)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,a,b); + +@override +String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) { + return 'Union.complex(a: $a, b: $b)'; +} + + +} + +/// @nodoc +abstract mixin class $ComplexCopyWith<$Res> implements $UnionCopyWith<$Res> { + factory $ComplexCopyWith(Complex value, $Res Function(Complex) _then) = _$ComplexCopyWithImpl; +@useResult +$Res call({ + int a, String b +}); + + + + +} +/// @nodoc +class _$ComplexCopyWithImpl<$Res> + implements $ComplexCopyWith<$Res> { + _$ComplexCopyWithImpl(this._self, this._then); + + final Complex _self; + final $Res Function(Complex) _then; + +/// Create a copy of Union +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? a = null,Object? b = null,}) { + return _then(Complex( +null == a ? _self.a : a // ignore: cast_nullable_to_non_nullable +as int,null == b ? _self.b : b // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +/// @nodoc +mixin _$SharedProperty implements DiagnosticableTreeMixin { + + String? get name; +/// Create a copy of SharedProperty +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SharedPropertyCopyWith get copyWith => _$SharedPropertyCopyWithImpl(this as SharedProperty, _$identity); + + +@override +void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('type', 'SharedProperty')) + ..add(DiagnosticsProperty('name', name)); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SharedProperty&&(identical(other.name, name) || other.name == name)); +} + + +@override +int get hashCode => Object.hash(runtimeType,name); + +@override +String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) { + return 'SharedProperty(name: $name)'; +} + + +} + +/// @nodoc +abstract mixin class $SharedPropertyCopyWith<$Res> { + factory $SharedPropertyCopyWith(SharedProperty value, $Res Function(SharedProperty) _then) = _$SharedPropertyCopyWithImpl; +@useResult +$Res call({ + String? name +}); + + + + +} +/// @nodoc +class _$SharedPropertyCopyWithImpl<$Res> + implements $SharedPropertyCopyWith<$Res> { + _$SharedPropertyCopyWithImpl(this._self, this._then); + + final SharedProperty _self; + final $Res Function(SharedProperty) _then; + +/// Create a copy of SharedProperty +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? name = freezed,}) { + return _then(_self.copyWith( +name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + + +/// @nodoc + + +class SharedProperty0 with DiagnosticableTreeMixin implements SharedProperty { + SharedProperty0({this.name, this.age}); + + +@override final String? name; + final int? age; + +/// Create a copy of SharedProperty +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SharedProperty0CopyWith get copyWith => _$SharedProperty0CopyWithImpl(this, _$identity); + + +@override +void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('type', 'SharedProperty.person')) + ..add(DiagnosticsProperty('name', name))..add(DiagnosticsProperty('age', age)); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SharedProperty0&&(identical(other.name, name) || other.name == name)&&(identical(other.age, age) || other.age == age)); +} + + +@override +int get hashCode => Object.hash(runtimeType,name,age); + +@override +String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) { + return 'SharedProperty.person(name: $name, age: $age)'; +} + + +} + +/// @nodoc +abstract mixin class $SharedProperty0CopyWith<$Res> implements $SharedPropertyCopyWith<$Res> { + factory $SharedProperty0CopyWith(SharedProperty0 value, $Res Function(SharedProperty0) _then) = _$SharedProperty0CopyWithImpl; +@override @useResult +$Res call({ + String? name, int? age +}); + + + + +} +/// @nodoc +class _$SharedProperty0CopyWithImpl<$Res> + implements $SharedProperty0CopyWith<$Res> { + _$SharedProperty0CopyWithImpl(this._self, this._then); + + final SharedProperty0 _self; + final $Res Function(SharedProperty0) _then; + +/// Create a copy of SharedProperty +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = freezed,Object? age = freezed,}) { + return _then(SharedProperty0( +name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,age: freezed == age ? _self.age : age // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + + +} + +/// @nodoc + + +class SharedProperty1 with DiagnosticableTreeMixin implements SharedProperty { + SharedProperty1({this.name, this.population}); + + +@override final String? name; + final int? population; + +/// Create a copy of SharedProperty +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SharedProperty1CopyWith get copyWith => _$SharedProperty1CopyWithImpl(this, _$identity); + + +@override +void debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties + ..add(DiagnosticsProperty('type', 'SharedProperty.city')) + ..add(DiagnosticsProperty('name', name))..add(DiagnosticsProperty('population', population)); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SharedProperty1&&(identical(other.name, name) || other.name == name)&&(identical(other.population, population) || other.population == population)); +} + + +@override +int get hashCode => Object.hash(runtimeType,name,population); + +@override +String toString({ DiagnosticLevel minLevel = DiagnosticLevel.info }) { + return 'SharedProperty.city(name: $name, population: $population)'; +} + + +} + +/// @nodoc +abstract mixin class $SharedProperty1CopyWith<$Res> implements $SharedPropertyCopyWith<$Res> { + factory $SharedProperty1CopyWith(SharedProperty1 value, $Res Function(SharedProperty1) _then) = _$SharedProperty1CopyWithImpl; +@override @useResult +$Res call({ + String? name, int? population +}); + + + + +} +/// @nodoc +class _$SharedProperty1CopyWithImpl<$Res> + implements $SharedProperty1CopyWith<$Res> { + _$SharedProperty1CopyWithImpl(this._self, this._then); + + final SharedProperty1 _self; + final $Res Function(SharedProperty1) _then; + +/// Create a copy of SharedProperty +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = freezed,Object? population = freezed,}) { + return _then(SharedProperty1( +name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,population: freezed == population ? _self.population : population // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + + +} + +// dart format on diff --git a/packages/freezed/example/lib/main.g.dart b/packages/freezed/example/lib/main.g.dart new file mode 100644 index 00000000..ae395261 --- /dev/null +++ b/packages/freezed/example/lib/main.g.dart @@ -0,0 +1,43 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'main.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Data _$DataFromJson(Map json) => + Data((json['value'] as num).toInt(), $type: json['custom-key'] as String?); + +Map _$DataToJson(Data instance) => { + 'value': instance.value, + 'custom-key': instance.$type, +}; + +Loading _$LoadingFromJson(Map json) => + Loading($type: json['custom-key'] as String?); + +Map _$LoadingToJson(Loading instance) => { + 'custom-key': instance.$type, +}; + +ErrorDetails _$ErrorDetailsFromJson(Map json) => + ErrorDetails(json['message'] as String?, json['custom-key'] as String?); + +Map _$ErrorDetailsToJson(ErrorDetails instance) => + { + 'message': instance.message, + 'custom-key': instance.$type, + }; + +Complex _$ComplexFromJson(Map json) => Complex( + (json['a'] as num).toInt(), + json['b'] as String, + $type: json['custom-key'] as String?, +); + +Map _$ComplexToJson(Complex instance) => { + 'a': instance.a, + 'b': instance.b, + 'custom-key': instance.$type, +}; diff --git a/packages/freezed/example/lib/non_diagnosticable.freezed.dart b/packages/freezed/example/lib/non_diagnosticable.freezed.dart new file mode 100644 index 00000000..da2067cb --- /dev/null +++ b/packages/freezed/example/lib/non_diagnosticable.freezed.dart @@ -0,0 +1,1039 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'non_diagnosticable.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$Example { + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Example); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'Example<$T>()'; +} + + +} + +/// @nodoc +class $ExampleCopyWith { +$ExampleCopyWith(Example _, $Res Function(Example) __); +} + + + +/// @nodoc + + +class _Example implements Example { + _Example(this.a, this.b); + + + final int a; + final String b; + +/// Create a copy of Example +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ExampleCopyWith> get copyWith => __$ExampleCopyWithImpl>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Example&&(identical(other.a, a) || other.a == a)&&(identical(other.b, b) || other.b == b)); +} + + +@override +int get hashCode => Object.hash(runtimeType,a,b); + +@override +String toString() { + return 'Example<$T>(a: $a, b: $b)'; +} + + +} + +/// @nodoc +abstract mixin class _$ExampleCopyWith implements $ExampleCopyWith { + factory _$ExampleCopyWith(_Example value, $Res Function(_Example) _then) = __$ExampleCopyWithImpl; +@useResult +$Res call({ + int a, String b +}); + + + + +} +/// @nodoc +class __$ExampleCopyWithImpl + implements _$ExampleCopyWith { + __$ExampleCopyWithImpl(this._self, this._then); + + final _Example _self; + final $Res Function(_Example) _then; + +/// Create a copy of Example +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? a = null,Object? b = null,}) { + return _then(_Example( +null == a ? _self.a : a // ignore: cast_nullable_to_non_nullable +as int,null == b ? _self.b : b // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +/// @nodoc + + +class _Example2 implements Example { + _Example2(this.c); + + + final T c; + +/// Create a copy of Example +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$Example2CopyWith> get copyWith => __$Example2CopyWithImpl>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Example2&&const DeepCollectionEquality().equals(other.c, c)); +} + + +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(c)); + +@override +String toString() { + return 'Example<$T>.named(c: $c)'; +} + + +} + +/// @nodoc +abstract mixin class _$Example2CopyWith implements $ExampleCopyWith { + factory _$Example2CopyWith(_Example2 value, $Res Function(_Example2) _then) = __$Example2CopyWithImpl; +@useResult +$Res call({ + T c +}); + + + + +} +/// @nodoc +class __$Example2CopyWithImpl + implements _$Example2CopyWith { + __$Example2CopyWithImpl(this._self, this._then); + + final _Example2 _self; + final $Res Function(_Example2) _then; + +/// Create a copy of Example +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? c = freezed,}) { + return _then(_Example2( +freezed == c ? _self.c : c // ignore: cast_nullable_to_non_nullable +as T, + )); +} + + +} + +/// @nodoc +mixin _$SimpleImplements { + + String get name; +/// Create a copy of SimpleImplements +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SimpleImplementsCopyWith get copyWith => _$SimpleImplementsCopyWithImpl(this as SimpleImplements, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SimpleImplements&&(identical(other.name, name) || other.name == name)); +} + + +@override +int get hashCode => Object.hash(runtimeType,name); + +@override +String toString() { + return 'SimpleImplements(name: $name)'; +} + + +} + +/// @nodoc +abstract mixin class $SimpleImplementsCopyWith<$Res> { + factory $SimpleImplementsCopyWith(SimpleImplements value, $Res Function(SimpleImplements) _then) = _$SimpleImplementsCopyWithImpl; +@useResult +$Res call({ + String name +}); + + + + +} +/// @nodoc +class _$SimpleImplementsCopyWithImpl<$Res> + implements $SimpleImplementsCopyWith<$Res> { + _$SimpleImplementsCopyWithImpl(this._self, this._then); + + final SimpleImplements _self; + final $Res Function(SimpleImplements) _then; + +/// Create a copy of SimpleImplements +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? name = null,}) { + return _then(_self.copyWith( +name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String, + )); +} + +} + + + +/// @nodoc + + +class SimplePerson implements SimpleImplements { + const SimplePerson(this.name, this.age); + + +@override final String name; + final int age; + +/// Create a copy of SimpleImplements +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SimplePersonCopyWith get copyWith => _$SimplePersonCopyWithImpl(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SimplePerson&&(identical(other.name, name) || other.name == name)&&(identical(other.age, age) || other.age == age)); +} + + +@override +int get hashCode => Object.hash(runtimeType,name,age); + +@override +String toString() { + return 'SimpleImplements.person(name: $name, age: $age)'; +} + + +} + +/// @nodoc +abstract mixin class $SimplePersonCopyWith<$Res> implements $SimpleImplementsCopyWith<$Res> { + factory $SimplePersonCopyWith(SimplePerson value, $Res Function(SimplePerson) _then) = _$SimplePersonCopyWithImpl; +@override @useResult +$Res call({ + String name, int age +}); + + + + +} +/// @nodoc +class _$SimplePersonCopyWithImpl<$Res> + implements $SimplePersonCopyWith<$Res> { + _$SimplePersonCopyWithImpl(this._self, this._then); + + final SimplePerson _self; + final $Res Function(SimplePerson) _then; + +/// Create a copy of SimpleImplements +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = null,Object? age = null,}) { + return _then(SimplePerson( +null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,null == age ? _self.age : age // ignore: cast_nullable_to_non_nullable +as int, + )); +} + + +} + +/// @nodoc + + +class SimpleStreet with AdministrativeArea implements SimpleImplements { + const SimpleStreet(this.name); + + +@override final String name; + +/// Create a copy of SimpleImplements +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SimpleStreetCopyWith get copyWith => _$SimpleStreetCopyWithImpl(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SimpleStreet&&(identical(other.name, name) || other.name == name)); +} + + +@override +int get hashCode => Object.hash(runtimeType,name); + +@override +String toString() { + return 'SimpleImplements.street(name: $name)'; +} + + +} + +/// @nodoc +abstract mixin class $SimpleStreetCopyWith<$Res> implements $SimpleImplementsCopyWith<$Res> { + factory $SimpleStreetCopyWith(SimpleStreet value, $Res Function(SimpleStreet) _then) = _$SimpleStreetCopyWithImpl; +@override @useResult +$Res call({ + String name +}); + + + + +} +/// @nodoc +class _$SimpleStreetCopyWithImpl<$Res> + implements $SimpleStreetCopyWith<$Res> { + _$SimpleStreetCopyWithImpl(this._self, this._then); + + final SimpleStreet _self; + final $Res Function(SimpleStreet) _then; + +/// Create a copy of SimpleImplements +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = null,}) { + return _then(SimpleStreet( +null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +/// @nodoc + + +class SimpleCity with House implements SimpleImplements { + const SimpleCity(this.name, this.population); + + +@override final String name; + final int population; + +/// Create a copy of SimpleImplements +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SimpleCityCopyWith get copyWith => _$SimpleCityCopyWithImpl(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SimpleCity&&(identical(other.name, name) || other.name == name)&&(identical(other.population, population) || other.population == population)); +} + + +@override +int get hashCode => Object.hash(runtimeType,name,population); + +@override +String toString() { + return 'SimpleImplements.city(name: $name, population: $population)'; +} + + +} + +/// @nodoc +abstract mixin class $SimpleCityCopyWith<$Res> implements $SimpleImplementsCopyWith<$Res> { + factory $SimpleCityCopyWith(SimpleCity value, $Res Function(SimpleCity) _then) = _$SimpleCityCopyWithImpl; +@override @useResult +$Res call({ + String name, int population +}); + + + + +} +/// @nodoc +class _$SimpleCityCopyWithImpl<$Res> + implements $SimpleCityCopyWith<$Res> { + _$SimpleCityCopyWithImpl(this._self, this._then); + + final SimpleCity _self; + final $Res Function(SimpleCity) _then; + +/// Create a copy of SimpleImplements +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = null,Object? population = null,}) { + return _then(SimpleCity( +null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,null == population ? _self.population : population // ignore: cast_nullable_to_non_nullable +as int, + )); +} + + +} + +/// @nodoc + + +class SimpleCountry with House implements SimpleImplements, GeographicArea { + const SimpleCountry(this.name, this.population); + + +@override final String name; + final int population; + +/// Create a copy of SimpleImplements +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SimpleCountryCopyWith get copyWith => _$SimpleCountryCopyWithImpl(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SimpleCountry&&(identical(other.name, name) || other.name == name)&&(identical(other.population, population) || other.population == population)); +} + + +@override +int get hashCode => Object.hash(runtimeType,name,population); + +@override +String toString() { + return 'SimpleImplements.country(name: $name, population: $population)'; +} + + +} + +/// @nodoc +abstract mixin class $SimpleCountryCopyWith<$Res> implements $SimpleImplementsCopyWith<$Res> { + factory $SimpleCountryCopyWith(SimpleCountry value, $Res Function(SimpleCountry) _then) = _$SimpleCountryCopyWithImpl; +@override @useResult +$Res call({ + String name, int population +}); + + + + +} +/// @nodoc +class _$SimpleCountryCopyWithImpl<$Res> + implements $SimpleCountryCopyWith<$Res> { + _$SimpleCountryCopyWithImpl(this._self, this._then); + + final SimpleCountry _self; + final $Res Function(SimpleCountry) _then; + +/// Create a copy of SimpleImplements +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = null,Object? population = null,}) { + return _then(SimpleCountry( +null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,null == population ? _self.population : population // ignore: cast_nullable_to_non_nullable +as int, + )); +} + + +} + +/// @nodoc +mixin _$CustomMethodImplements { + + String get name; +/// Create a copy of CustomMethodImplements +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CustomMethodImplementsCopyWith get copyWith => _$CustomMethodImplementsCopyWithImpl(this as CustomMethodImplements, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is CustomMethodImplements&&(identical(other.name, name) || other.name == name)); +} + + +@override +int get hashCode => Object.hash(runtimeType,name); + +@override +String toString() { + return 'CustomMethodImplements(name: $name)'; +} + + +} + +/// @nodoc +abstract mixin class $CustomMethodImplementsCopyWith<$Res> { + factory $CustomMethodImplementsCopyWith(CustomMethodImplements value, $Res Function(CustomMethodImplements) _then) = _$CustomMethodImplementsCopyWithImpl; +@useResult +$Res call({ + String name +}); + + + + +} +/// @nodoc +class _$CustomMethodImplementsCopyWithImpl<$Res> + implements $CustomMethodImplementsCopyWith<$Res> { + _$CustomMethodImplementsCopyWithImpl(this._self, this._then); + + final CustomMethodImplements _self; + final $Res Function(CustomMethodImplements) _then; + +/// Create a copy of CustomMethodImplements +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? name = null,}) { + return _then(_self.copyWith( +name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String, + )); +} + +} + + + +/// @nodoc + + +class PersonCustomMethod extends CustomMethodImplements { + const PersonCustomMethod(this.name, this.age): super._(); + + +@override final String name; + final int age; + +/// Create a copy of CustomMethodImplements +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PersonCustomMethodCopyWith get copyWith => _$PersonCustomMethodCopyWithImpl(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is PersonCustomMethod&&(identical(other.name, name) || other.name == name)&&(identical(other.age, age) || other.age == age)); +} + + +@override +int get hashCode => Object.hash(runtimeType,name,age); + +@override +String toString() { + return 'CustomMethodImplements.person(name: $name, age: $age)'; +} + + +} + +/// @nodoc +abstract mixin class $PersonCustomMethodCopyWith<$Res> implements $CustomMethodImplementsCopyWith<$Res> { + factory $PersonCustomMethodCopyWith(PersonCustomMethod value, $Res Function(PersonCustomMethod) _then) = _$PersonCustomMethodCopyWithImpl; +@override @useResult +$Res call({ + String name, int age +}); + + + + +} +/// @nodoc +class _$PersonCustomMethodCopyWithImpl<$Res> + implements $PersonCustomMethodCopyWith<$Res> { + _$PersonCustomMethodCopyWithImpl(this._self, this._then); + + final PersonCustomMethod _self; + final $Res Function(PersonCustomMethod) _then; + +/// Create a copy of CustomMethodImplements +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = null,Object? age = null,}) { + return _then(PersonCustomMethod( +null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,null == age ? _self.age : age // ignore: cast_nullable_to_non_nullable +as int, + )); +} + + +} + +/// @nodoc + + +class StreetCustomMethod extends CustomMethodImplements with Shop, AdministrativeArea { + const StreetCustomMethod(this.name): super._(); + + +@override final String name; + +/// Create a copy of CustomMethodImplements +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$StreetCustomMethodCopyWith get copyWith => _$StreetCustomMethodCopyWithImpl(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is StreetCustomMethod&&(identical(other.name, name) || other.name == name)); +} + + +@override +int get hashCode => Object.hash(runtimeType,name); + +@override +String toString() { + return 'CustomMethodImplements.street(name: $name)'; +} + + +} + +/// @nodoc +abstract mixin class $StreetCustomMethodCopyWith<$Res> implements $CustomMethodImplementsCopyWith<$Res> { + factory $StreetCustomMethodCopyWith(StreetCustomMethod value, $Res Function(StreetCustomMethod) _then) = _$StreetCustomMethodCopyWithImpl; +@override @useResult +$Res call({ + String name +}); + + + + +} +/// @nodoc +class _$StreetCustomMethodCopyWithImpl<$Res> + implements $StreetCustomMethodCopyWith<$Res> { + _$StreetCustomMethodCopyWithImpl(this._self, this._then); + + final StreetCustomMethod _self; + final $Res Function(StreetCustomMethod) _then; + +/// Create a copy of CustomMethodImplements +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = null,}) { + return _then(StreetCustomMethod( +null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +/// @nodoc + + +class CityCustomMethod extends CustomMethodImplements with House implements GeographicArea { + const CityCustomMethod(this.name, this.population): super._(); + + +@override final String name; + final int population; + +/// Create a copy of CustomMethodImplements +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CityCustomMethodCopyWith get copyWith => _$CityCustomMethodCopyWithImpl(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is CityCustomMethod&&(identical(other.name, name) || other.name == name)&&(identical(other.population, population) || other.population == population)); +} + + +@override +int get hashCode => Object.hash(runtimeType,name,population); + +@override +String toString() { + return 'CustomMethodImplements.city(name: $name, population: $population)'; +} + + +} + +/// @nodoc +abstract mixin class $CityCustomMethodCopyWith<$Res> implements $CustomMethodImplementsCopyWith<$Res> { + factory $CityCustomMethodCopyWith(CityCustomMethod value, $Res Function(CityCustomMethod) _then) = _$CityCustomMethodCopyWithImpl; +@override @useResult +$Res call({ + String name, int population +}); + + + + +} +/// @nodoc +class _$CityCustomMethodCopyWithImpl<$Res> + implements $CityCustomMethodCopyWith<$Res> { + _$CityCustomMethodCopyWithImpl(this._self, this._then); + + final CityCustomMethod _self; + final $Res Function(CityCustomMethod) _then; + +/// Create a copy of CustomMethodImplements +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = null,Object? population = null,}) { + return _then(CityCustomMethod( +null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,null == population ? _self.population : population // ignore: cast_nullable_to_non_nullable +as int, + )); +} + + +} + +/// @nodoc + + +class DuplexCustomMethod extends CustomMethodImplements implements Shop, GeographicArea { + const DuplexCustomMethod(this.name): super._(); + + +@override final String name; + +/// Create a copy of CustomMethodImplements +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$DuplexCustomMethodCopyWith get copyWith => _$DuplexCustomMethodCopyWithImpl(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is DuplexCustomMethod&&(identical(other.name, name) || other.name == name)); +} + + +@override +int get hashCode => Object.hash(runtimeType,name); + +@override +String toString() { + return 'CustomMethodImplements.duplex(name: $name)'; +} + + +} + +/// @nodoc +abstract mixin class $DuplexCustomMethodCopyWith<$Res> implements $CustomMethodImplementsCopyWith<$Res> { + factory $DuplexCustomMethodCopyWith(DuplexCustomMethod value, $Res Function(DuplexCustomMethod) _then) = _$DuplexCustomMethodCopyWithImpl; +@override @useResult +$Res call({ + String name +}); + + + + +} +/// @nodoc +class _$DuplexCustomMethodCopyWithImpl<$Res> + implements $DuplexCustomMethodCopyWith<$Res> { + _$DuplexCustomMethodCopyWithImpl(this._self, this._then); + + final DuplexCustomMethod _self; + final $Res Function(DuplexCustomMethod) _then; + +/// Create a copy of CustomMethodImplements +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = null,}) { + return _then(DuplexCustomMethod( +null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +/// @nodoc +mixin _$GenericImplements { + + String get name; +/// Create a copy of GenericImplements +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$GenericImplementsCopyWith> get copyWith => _$GenericImplementsCopyWithImpl>(this as GenericImplements, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is GenericImplements&&(identical(other.name, name) || other.name == name)); +} + + +@override +int get hashCode => Object.hash(runtimeType,name); + +@override +String toString() { + return 'GenericImplements<$T>(name: $name)'; +} + + +} + +/// @nodoc +abstract mixin class $GenericImplementsCopyWith { + factory $GenericImplementsCopyWith(GenericImplements value, $Res Function(GenericImplements) _then) = _$GenericImplementsCopyWithImpl; +@useResult +$Res call({ + String name +}); + + + + +} +/// @nodoc +class _$GenericImplementsCopyWithImpl + implements $GenericImplementsCopyWith { + _$GenericImplementsCopyWithImpl(this._self, this._then); + + final GenericImplements _self; + final $Res Function(GenericImplements) _then; + +/// Create a copy of GenericImplements +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? name = null,}) { + return _then(_self.copyWith( +name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String, + )); +} + +} + + + +/// @nodoc + + +class GenericPerson implements GenericImplements { + const GenericPerson(this.name, this.age); + + +@override final String name; + final int age; + +/// Create a copy of GenericImplements +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$GenericPersonCopyWith> get copyWith => _$GenericPersonCopyWithImpl>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is GenericPerson&&(identical(other.name, name) || other.name == name)&&(identical(other.age, age) || other.age == age)); +} + + +@override +int get hashCode => Object.hash(runtimeType,name,age); + +@override +String toString() { + return 'GenericImplements<$T>.person(name: $name, age: $age)'; +} + + +} + +/// @nodoc +abstract mixin class $GenericPersonCopyWith implements $GenericImplementsCopyWith { + factory $GenericPersonCopyWith(GenericPerson value, $Res Function(GenericPerson) _then) = _$GenericPersonCopyWithImpl; +@override @useResult +$Res call({ + String name, int age +}); + + + + +} +/// @nodoc +class _$GenericPersonCopyWithImpl + implements $GenericPersonCopyWith { + _$GenericPersonCopyWithImpl(this._self, this._then); + + final GenericPerson _self; + final $Res Function(GenericPerson) _then; + +/// Create a copy of GenericImplements +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = null,Object? age = null,}) { + return _then(GenericPerson( +null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,null == age ? _self.age : age // ignore: cast_nullable_to_non_nullable +as int, + )); +} + + +} + +/// @nodoc + + +class GenericCity with House implements GenericImplements, GeographicArea { + const GenericCity(this.name, this.population); + + +@override final String name; + final int population; + +/// Create a copy of GenericImplements +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$GenericCityCopyWith> get copyWith => _$GenericCityCopyWithImpl>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is GenericCity&&(identical(other.name, name) || other.name == name)&&(identical(other.population, population) || other.population == population)); +} + + +@override +int get hashCode => Object.hash(runtimeType,name,population); + +@override +String toString() { + return 'GenericImplements<$T>.city(name: $name, population: $population)'; +} + + +} + +/// @nodoc +abstract mixin class $GenericCityCopyWith implements $GenericImplementsCopyWith { + factory $GenericCityCopyWith(GenericCity value, $Res Function(GenericCity) _then) = _$GenericCityCopyWithImpl; +@override @useResult +$Res call({ + String name, int population +}); + + + + +} +/// @nodoc +class _$GenericCityCopyWithImpl + implements $GenericCityCopyWith { + _$GenericCityCopyWithImpl(this._self, this._then); + + final GenericCity _self; + final $Res Function(GenericCity) _then; + +/// Create a copy of GenericImplements +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = null,Object? population = null,}) { + return _then(GenericCity( +null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,null == population ? _self.population : population // ignore: cast_nullable_to_non_nullable +as int, + )); +} + + +} + +// dart format on diff --git a/packages/freezed/example/lib/time_slot.freezed.dart b/packages/freezed/example/lib/time_slot.freezed.dart new file mode 100644 index 00000000..d21ca538 --- /dev/null +++ b/packages/freezed/example/lib/time_slot.freezed.dart @@ -0,0 +1,145 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'time_slot.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$TimeSlot { + + TimeOfDay? get start; TimeOfDay? get end; +/// Create a copy of TimeSlot +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$TimeSlotCopyWith get copyWith => _$TimeSlotCopyWithImpl(this as TimeSlot, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is TimeSlot&&(identical(other.start, start) || other.start == start)&&(identical(other.end, end) || other.end == end)); +} + + +@override +int get hashCode => Object.hash(runtimeType,start,end); + +@override +String toString() { + return 'TimeSlot(start: $start, end: $end)'; +} + + +} + +/// @nodoc +abstract mixin class $TimeSlotCopyWith<$Res> { + factory $TimeSlotCopyWith(TimeSlot value, $Res Function(TimeSlot) _then) = _$TimeSlotCopyWithImpl; +@useResult +$Res call({ + TimeOfDay? start, TimeOfDay? end +}); + + + + +} +/// @nodoc +class _$TimeSlotCopyWithImpl<$Res> + implements $TimeSlotCopyWith<$Res> { + _$TimeSlotCopyWithImpl(this._self, this._then); + + final TimeSlot _self; + final $Res Function(TimeSlot) _then; + +/// Create a copy of TimeSlot +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? start = freezed,Object? end = freezed,}) { + return _then(_self.copyWith( +start: freezed == start ? _self.start : start // ignore: cast_nullable_to_non_nullable +as TimeOfDay?,end: freezed == end ? _self.end : end // ignore: cast_nullable_to_non_nullable +as TimeOfDay?, + )); +} + +} + + + +/// @nodoc + + +class _TimeSlot implements TimeSlot { + _TimeSlot({this.start, this.end}); + + +@override final TimeOfDay? start; +@override final TimeOfDay? end; + +/// Create a copy of TimeSlot +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$TimeSlotCopyWith<_TimeSlot> get copyWith => __$TimeSlotCopyWithImpl<_TimeSlot>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _TimeSlot&&(identical(other.start, start) || other.start == start)&&(identical(other.end, end) || other.end == end)); +} + + +@override +int get hashCode => Object.hash(runtimeType,start,end); + +@override +String toString() { + return 'TimeSlot(start: $start, end: $end)'; +} + + +} + +/// @nodoc +abstract mixin class _$TimeSlotCopyWith<$Res> implements $TimeSlotCopyWith<$Res> { + factory _$TimeSlotCopyWith(_TimeSlot value, $Res Function(_TimeSlot) _then) = __$TimeSlotCopyWithImpl; +@override @useResult +$Res call({ + TimeOfDay? start, TimeOfDay? end +}); + + + + +} +/// @nodoc +class __$TimeSlotCopyWithImpl<$Res> + implements _$TimeSlotCopyWith<$Res> { + __$TimeSlotCopyWithImpl(this._self, this._then); + + final _TimeSlot _self; + final $Res Function(_TimeSlot) _then; + +/// Create a copy of TimeSlot +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? start = freezed,Object? end = freezed,}) { + return _then(_TimeSlot( +start: freezed == start ? _self.start : start // ignore: cast_nullable_to_non_nullable +as TimeOfDay?,end: freezed == end ? _self.end : end // ignore: cast_nullable_to_non_nullable +as TimeOfDay?, + )); +} + + +} + +// dart format on diff --git a/packages/freezed/example/pubspec.yaml b/packages/freezed/example/pubspec.yaml index 4d1d3f83..7b42269d 100644 --- a/packages/freezed/example/pubspec.yaml +++ b/packages/freezed/example/pubspec.yaml @@ -3,25 +3,18 @@ description: A new Flutter project. publish_to: none environment: - sdk: ">=3.6.0 <4.0.0" + sdk: ">=3.8.0 <4.0.0" +resolution: workspace dependencies: flutter: sdk: flutter - freezed_annotation: - path: ../../freezed_annotation + freezed_annotation: ^3.0.0 json_annotation: ^4.9.0 dev_dependencies: - freezed: - path: ../ + freezed: ^3.0.2 json_serializable: ^6.9.4 build_runner: flutter_test: sdk: flutter - -dependency_overrides: - freezed: - path: ../ - freezed_annotation: - path: ../../freezed_annotation diff --git a/packages/freezed/lib/src/ast.dart b/packages/freezed/lib/src/ast.dart index 786e7bb9..d6c6ab27 100644 --- a/packages/freezed/lib/src/ast.dart +++ b/packages/freezed/lib/src/ast.dart @@ -1,6 +1,6 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/ast/token.dart'; -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; extension AstX on AstNode { String? get documentation { @@ -28,10 +28,10 @@ extension ClassX on ClassDeclaration { element, ...element.allSupertypes .where((e) => !e.isDartCoreObject) - .map((e) => e.element3), + .map((e) => e.element), ]) { - for (final method in type.methods2) { - if (method.name3 == 'toString') { + for (final method in type.methods) { + if (method.name == 'toString') { return true; } } @@ -42,50 +42,50 @@ extension ClassX on ClassDeclaration { bool get hasSuperEqual => declaredFragment!.element.allSupertypes .where((e) => !e.isDartCoreObject) - .map((e) => e.element3) + .map((e) => e.element) .any((e) => e.hasEqual); bool get hasCustomEquals => declaredFragment!.element.hasEqual; bool get hasSuperHashCode => declaredFragment!.element.allSupertypes .where((e) => !e.isDartCoreObject) - .map((e) => e.element3) + .map((e) => e.element) .any((e) => e.hasHashCode); } -extension on InterfaceElement2 { - bool get hasEqual => methods2.any(((e) => e.isOperator && e.name3 == '==')); +extension on InterfaceElement { + bool get hasEqual => methods.any(((e) => e.isOperator && e.name == '==')); - bool get hasHashCode => getters2.any((e) => e.name3 == 'hashCode'); + bool get hasHashCode => getters.any((e) => e.name == 'hashCode'); } extension ConstructorX on ConstructorDeclaration { String get fullName { - final classElement = declaredFragment!.element.enclosingElement2; + final classElement = declaredFragment!.element.enclosingElement; - var generics = classElement.typeParameters2 - .map((e) => '\$${e.name3}') + var generics = classElement.typeParameters + .map((e) => '\$${e.name}') .join(', '); if (generics.isNotEmpty) { generics = '<$generics>'; } - final className = classElement.enclosingElement2.name3; + final className = classElement.enclosingElement.name; return name == null ? '$className$generics' : '$className$generics.$name'; } String get escapedName { - final classElement = declaredFragment!.element.enclosingElement2; + final classElement = declaredFragment!.element.enclosingElement; - var generics = classElement.typeParameters2 - .map((e) => '\$${e.name3}') + var generics = classElement.typeParameters + .map((e) => '\$${e.name}') .join(', '); if (generics.isNotEmpty) { generics = '<$generics>'; } - final escapedElementName = classElement.name3!.replaceAll(r'$', r'\$'); + final escapedElementName = classElement.name!.replaceAll(r'$', r'\$'); final escapedConstructorName = name?.lexeme.replaceAll(r'$', r'\$'); return escapedConstructorName == null diff --git a/packages/freezed/lib/src/models.dart b/packages/freezed/lib/src/models.dart index 8adeca3e..3270493b 100644 --- a/packages/freezed/lib/src/models.dart +++ b/packages/freezed/lib/src/models.dart @@ -4,7 +4,7 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/constant/value.dart'; -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/nullability_suffix.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:collection/collection.dart'; @@ -27,7 +27,7 @@ class _Sentinel { const _Sentinel(); } -extension on Element2 { +extension on Element { bool get hasJsonSerializable { return const TypeChecker.typeNamed( JsonSerializable, @@ -36,9 +36,9 @@ extension on Element2 { } } -extension on ConstructorElement2 { +extension on ConstructorElement { bool isFallbackUnion(String? fallbackConstructorName) { - final constructorName = isDefaultConstructor(this) ? 'default' : name3; + final constructorName = isDefaultConstructor(this) ? 'default' : name; return constructorName == fallbackConstructorName; } @@ -51,7 +51,7 @@ extension on ConstructorElement2 { return annotation.getField('value')!.toStringValue()!; } - final constructorName = isDefaultConstructor(this) ? 'default' : name3!; + final constructorName = isDefaultConstructor(this) ? 'default' : name!; switch (unionCase) { case null: case FreezedUnionCase.none: @@ -97,8 +97,8 @@ class DeepCloneableProperty { final parameterType = parameter.type; if (parameterType is! InterfaceType) continue; - final typeElement = parameterType.element3; - if (typeElement is! ClassElement2) continue; + final typeElement = parameterType.element; + if (typeElement is! ClassElement) continue; final freezedAnnotation = freezedType.firstAnnotationOf( typeElement, @@ -116,10 +116,10 @@ class DeepCloneableProperty { if (configs.copyWith == false) continue; yield DeepCloneableProperty( - name: parameter.name3!, + name: parameter.name!, type: type, nullable: parameter.type.isNullable, - typeName: typeElement.name3!, + typeName: typeElement.name!, genericParameters: GenericsParameterTemplate( (parameter.type as InterfaceType).typeArguments .map((e) => e.getDisplayString()) @@ -269,7 +269,7 @@ When specifying fields in non-factory constructor then specifying factory constr } final redirectedName = - constructor.redirectedConstructor?.type.name2.lexeme; + constructor.redirectedConstructor?.type.name.lexeme; if (redirectedName == null) { _assertValidNormalConstructorUsage(declaration, constructor); @@ -283,7 +283,7 @@ When specifying fields in non-factory constructor then specifying factory constr final excludedProperties = manualConstructor?.parameters.parameters - .map((e) => e.declaredFragment!.element.name3!) + .map((e) => e.declaredFragment!.element.name!) .toSet() ?? {}; @@ -318,7 +318,7 @@ When specifying fields in non-factory constructor then specifying factory constr decorators: constructor.metadata .where((element) { final elementSourceUri = - element.element2?.baseElement.library2?.uri; + element.element?.baseElement.library?.uri; final isFreezedAnnotation = elementSourceUri != null && @@ -424,7 +424,7 @@ class ImplementsAnnotation { ImplementsAnnotation({required this.type}); static Iterable parseAll( - ConstructorElement2 constructor, + ConstructorElement constructor, ) sync* { for (final meta in const TypeChecker.typeNamed( Implements, @@ -436,7 +436,7 @@ class ImplementsAnnotation { } else { yield ImplementsAnnotation( type: resolveFullTypeStringFrom( - constructor.library2, + constructor.library, (meta.type! as InterfaceType).typeArguments.single, ), ); @@ -451,9 +451,9 @@ class WithAnnotation { WithAnnotation({required this.type}); static Iterable parseAll( - ConstructorElement2 constructor, + ConstructorElement constructor, ) sync* { - for (final metadata in constructor.metadata2.annotations) { + for (final metadata in constructor.metadata.annotations) { if (!metadata.isWith) continue; final object = metadata.computeConstantValue()!; @@ -463,7 +463,7 @@ class WithAnnotation { } else { yield WithAnnotation( type: resolveFullTypeStringFrom( - constructor.library2, + constructor.library, (object.type! as InterfaceType).typeArguments.single, ), ); @@ -522,7 +522,7 @@ class CopyWithTarget { extension on NamedType { bool isSuperMixin(ClassDeclaration declaration) => - name2.lexeme == '_\$${declaration.name.lexeme.public}'; + name.lexeme == '_\$${declaration.name.lexeme.public}'; } class Class { @@ -552,7 +552,7 @@ class Class { final ClassDeclaration _node; final Set parents = {}; - LibraryElement2 get library => _node.declaredFragment!.element.library2; + LibraryElement get library => _node.declaredFragment!.element.library; static Class _from( ClassDeclaration declaration, @@ -570,7 +570,7 @@ class Class { ); if (constructors.isNotEmpty) { - for (final field in declaration.declaredFragment!.element.fields2) { + for (final field in declaration.declaredFragment!.element.fields) { _assertValidFieldUsage(field, shouldUseExtends: privateCtor != null); } } @@ -676,14 +676,14 @@ To fix, either: options: configs, constructors: constructors, concretePropertiesName: [ - for (final p in declaration.declaredFragment!.element.fields2) - if (!p.isStatic) p.name3!, + for (final p in declaration.declaredFragment!.element.fields) + if (!p.isStatic) p.name!, ], genericsDefinitionTemplate: GenericsDefinitionTemplate.fromGenericElement( - declaration.declaredFragment!.element.typeParameters2, + declaration.declaredFragment!.element.typeParameters, ), genericsParameterTemplate: GenericsParameterTemplate.fromGenericElement( - declaration.declaredFragment!.element.typeParameters2, + declaration.declaredFragment!.element.typeParameters, ), ); } @@ -745,7 +745,7 @@ To fix, either: if (clazz._node.extendsClause case final extend?) extend.superclass, ...?clazz._node.implementsClause?.interfaces, ...?clazz._node.withClause?.mixinTypes, - ].map((e) => e.name2.lexeme); + ].map((e) => e.name.lexeme); for (final superType in superTypes) { final superTypeClass = classMap[superType]; @@ -832,9 +832,11 @@ To fix, either: doc: property.$1.documentation, isFinal: property.$1.fields.isFinal, isSynthetic: false, - decorators: switch (property.$1.declaredFragment?.element) { - final Annotatable e => parseDecorators(e.metadata2.annotations), - _ => [], + decorators: switch (property.$1.declaredFragment) { + final Fragment fragment => parseDecorators( + fragment.element.metadata.annotations, + ), + null => [], }, ); } @@ -862,9 +864,9 @@ To fix, either: } late final typeSystem = - declaration.declaredFragment!.element.library2.typeSystem; + declaration.declaredFragment!.element.library.typeSystem; late final typeProvider = - declaration.declaredFragment!.element.library2.typeProvider; + declaration.declaredFragment!.element.library.typeProvider; fieldLoop: for (final entry in typesMap.entries) { @@ -918,7 +920,7 @@ To fix, either: isFinal = true; typeString = resolveFullTypeStringFrom( - declaration.declaredFragment!.element.library2, + declaration.declaredFragment!.element.library, type, ); } @@ -964,7 +966,7 @@ To fix, either: param: parameter.name, ); - final library = parameter.parameterElement!.library2!; + final library = parameter.parameterElement!.library!; var commonTypeBetweenAllUnionConstructors = parameter.parameterElement!.type; @@ -1061,12 +1063,12 @@ To fix, either: } static void _assertValidFieldUsage( - FieldElement2 field, { + FieldElement field, { required bool shouldUseExtends, }) { if (field.isStatic) return; - if (field.setter2 != null) { + if (field.setter != null) { throw InvalidGenerationSourceError( 'Classes decorated with @freezed cannot have mutable properties', element: field, @@ -1075,9 +1077,9 @@ To fix, either: // The field is a "Type get name => " if (!shouldUseExtends && - field.getter2 != null && - !field.getter2!.isAbstract && - !field.getter2!.isSynthetic) { + field.getter != null && + !field.getter!.isAbstract && + !field.getter!.isSynthetic) { throw InvalidGenerationSourceError( 'Getters require a MyClass._() constructor', element: field, @@ -1129,10 +1131,10 @@ class Library { return Library( hasJson: units.any( (unit) => - unit.declaredFragment!.element.library2.importsJsonSerializable, + unit.declaredFragment!.element.library.importsJsonSerializable, ), hasDiagnostics: units.any( - (unit) => unit.declaredFragment!.element.library2.importsDiagnosticable, + (unit) => unit.declaredFragment!.element.library.importsDiagnosticable, ), ); } @@ -1357,18 +1359,18 @@ extension ClassDeclarationX on ClassDeclaration { } } -extension on LibraryElement2 { +extension on LibraryElement { bool get importsJsonSerializable { return findAllAvailableTopLevelElements().any((element) { - return element.name3 == 'JsonSerializable' && - (element.library2?.isFromPackage('json_annotation') ?? false); + return element.name == 'JsonSerializable' && + (element.library?.isFromPackage('json_annotation') ?? false); }); } bool get importsDiagnosticable { return findAllAvailableTopLevelElements().any((element) { - return element.name3 == 'DiagnosticableTreeMixin' && - (element.library2?.isFromPackage('flutter') ?? false); + return element.name == 'DiagnosticableTreeMixin' && + (element.library?.isFromPackage('flutter') ?? false); }); } } diff --git a/packages/freezed/lib/src/parse_generator.dart b/packages/freezed/lib/src/parse_generator.dart index db7c315c..e6b6f3ab 100644 --- a/packages/freezed/lib/src/parse_generator.dart +++ b/packages/freezed/lib/src/parse_generator.dart @@ -3,7 +3,7 @@ import 'dart:async'; import 'package:analyzer/dart/analysis/results.dart'; import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/constant/value.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:source_gen/source_gen.dart'; @@ -57,7 +57,7 @@ abstract class ParserGenerator @override Stream generateForAnnotatedElement( - Element2 element, + Element element, ConstantReader annotation, BuildStep buildStep, ) async* { @@ -75,7 +75,7 @@ abstract class ParserGenerator unit as ResolvedUnitResult; final Object? ast = unit.unit.declarations.firstWhereOrNull( (declaration) => - declaration.declaredFragment?.element.name3 == element.name3!, + declaration.declaredFragment?.element.name == element.name!, ); if (ast == null) { throw InvalidGenerationSourceError('Ast not found', element: element); diff --git a/packages/freezed/lib/src/templates/concrete_template.dart b/packages/freezed/lib/src/templates/concrete_template.dart index 19271f4a..da43ba73 100644 --- a/packages/freezed/lib/src/templates/concrete_template.dart +++ b/packages/freezed/lib/src/templates/concrete_template.dart @@ -1,5 +1,5 @@ import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:freezed/src/freezed_generator.dart'; import 'package:freezed/src/models.dart'; import 'package:freezed/src/templates/properties.dart'; @@ -522,7 +522,7 @@ extension DefaultValue on FormalParameterElement { inPackage: 'freezed_annotation', ); - for (final meta in metadata2.annotations) { + for (final meta in metadata.annotations) { final obj = meta.computeConstantValue()!; if (matcher.isExactlyType(obj.type!)) { final source = meta.toSource(); diff --git a/packages/freezed/lib/src/templates/parameter_template.dart b/packages/freezed/lib/src/templates/parameter_template.dart index 6fc83770..1c4772e1 100644 --- a/packages/freezed/lib/src/templates/parameter_template.dart +++ b/packages/freezed/lib/src/templates/parameter_template.dart @@ -1,5 +1,5 @@ import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:collection/collection.dart'; import 'package:freezed/src/ast.dart'; @@ -11,10 +11,10 @@ class GenericsDefinitionTemplate { GenericsDefinitionTemplate(this.typeParameters); factory GenericsDefinitionTemplate.fromGenericElement( - List generics, + List generics, ) { return GenericsDefinitionTemplate( - generics.map((e) => e.displayString2()).toList(), + generics.map((e) => e.displayString()).toList(), ); } @@ -36,9 +36,9 @@ class GenericsParameterTemplate { GenericsParameterTemplate(this.typeParameters); factory GenericsParameterTemplate.fromGenericElement( - List generics, + List generics, ) { - return GenericsParameterTemplate(generics.map((e) => e.name3!).toList()); + return GenericsParameterTemplate(generics.map((e) => e.name!).toList()); } final List typeParameters; @@ -70,13 +70,13 @@ class ParametersTemplate { final e = p.declaredFragment!.element; final value = Parameter( - name: e.name3!, + name: e.name!, defaultValueSource: e.defaultValue, isRequired: e.isRequiredNamed, isFinal: addImplicitFinal || e.isFinal, type: e.type, typeDisplayString: parseTypeSource(p), - decorators: parseDecorators(e.metadata2.annotations), + decorators: parseDecorators(e.metadata.annotations), doc: p.documentation ?? '', showDefaultValue: true, parameterElement: e, diff --git a/packages/freezed/lib/src/templates/properties.dart b/packages/freezed/lib/src/templates/properties.dart index 863d74e0..770dffbc 100644 --- a/packages/freezed/lib/src/templates/properties.dart +++ b/packages/freezed/lib/src/templates/properties.dart @@ -1,5 +1,5 @@ import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:freezed/src/ast.dart'; import 'package:freezed/src/templates/parameter_template.dart'; @@ -52,13 +52,13 @@ class Property { } return Property( - name: element.name3!, + name: element.name!, isFinal: addImplicitFinal || element.isFinal, isSynthetic: isSynthetic, doc: parameter.documentation ?? '', type: element.type, typeDisplayString: parseTypeSource(parameter), - decorators: parseDecorators(element.metadata2.annotations), + decorators: parseDecorators(element.metadata.annotations), defaultValueSource: defaultValue, hasJsonKey: element.hasJsonKey, ); @@ -114,7 +114,7 @@ class Property { bool? hasJsonKey, String? doc, bool? isPossiblyDartCollection, - TypeParameterElement2? parameterElement, + TypeParameterElement? parameterElement, }) { return Property( type: type ?? this.type, diff --git a/packages/freezed/lib/src/templates/prototypes.dart b/packages/freezed/lib/src/templates/prototypes.dart index 10fcf489..2fb5a9d6 100644 --- a/packages/freezed/lib/src/templates/prototypes.dart +++ b/packages/freezed/lib/src/templates/prototypes.dart @@ -1,4 +1,4 @@ -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:source_gen/source_gen.dart'; @@ -41,8 +41,8 @@ extension FreezedElementAnnotation on ElementAnnotation { } } -bool isDefaultConstructor(ConstructorElement2 constructor) { - return constructor.name3 == 'new'; +bool isDefaultConstructor(ConstructorElement constructor) { + return constructor.name == 'new'; } String constructorNameToCallbackName(String constructorName) { diff --git a/packages/freezed/lib/src/tools/imports.dart b/packages/freezed/lib/src/tools/imports.dart index 4d995395..4d0c39a0 100644 --- a/packages/freezed/lib/src/tools/imports.dart +++ b/packages/freezed/lib/src/tools/imports.dart @@ -1,18 +1,18 @@ -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; -extension LibraryHasImport on LibraryElement2 { - LibraryElement2? findTransitiveExportWhere( - bool Function(LibraryElement2 library) visitor, +extension LibraryHasImport on LibraryElement { + LibraryElement? findTransitiveExportWhere( + bool Function(LibraryElement library) visitor, ) { if (visitor(this)) return this; - final visitedLibraries = {}; - LibraryElement2? visitLibrary(LibraryElement2 library) { + final visitedLibraries = {}; + LibraryElement? visitLibrary(LibraryElement library) { if (!visitedLibraries.add(library)) return null; if (visitor(library)) return library; - for (final export in library.exportedLibraries2) { + for (final export in library.exportedLibraries) { final result = visitLibrary(export); if (result != null) return result; } @@ -20,7 +20,7 @@ extension LibraryHasImport on LibraryElement2 { return null; } - for (final import in exportedLibraries2) { + for (final import in exportedLibraries) { final result = visitLibrary(import); if (result != null) return result; } @@ -28,7 +28,7 @@ extension LibraryHasImport on LibraryElement2 { return null; } - bool anyTransitiveExport(bool Function(LibraryElement2 library) visitor) { + bool anyTransitiveExport(bool Function(LibraryElement library) visitor) { return findTransitiveExportWhere(visitor) != null; } } diff --git a/packages/freezed/lib/src/tools/recursive_import_locator.dart b/packages/freezed/lib/src/tools/recursive_import_locator.dart index 2ec6600e..a41dc7d2 100644 --- a/packages/freezed/lib/src/tools/recursive_import_locator.dart +++ b/packages/freezed/lib/src/tools/recursive_import_locator.dart @@ -1,7 +1,7 @@ -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:collection/collection.dart'; -extension FindAllAvailableTopLevelElements on LibraryElement2 { +extension FindAllAvailableTopLevelElements on LibraryElement { bool isFromPackage(String packageName) { return firstFragment.source.fullName.startsWith('/$packageName/'); } @@ -11,7 +11,7 @@ extension FindAllAvailableTopLevelElements on LibraryElement2 { /// /// This function does not guarantees that the elements returned are unique. /// It is possible for the same object to be present multiple times in the list. - Iterable findAllAvailableTopLevelElements() { + Iterable findAllAvailableTopLevelElements() { return _findAllAvailableTopLevelElements( {}, checkExports: false, @@ -23,20 +23,20 @@ extension FindAllAvailableTopLevelElements on LibraryElement2 { ); } - Iterable _findAllAvailableTopLevelElements( + Iterable _findAllAvailableTopLevelElements( Set<_LibraryKey> visitedLibraryPaths, { required bool checkExports, required _LibraryKey key, }) sync* { - yield* children2; + yield* children; final librariesToCheck = checkExports ? fragments - .expand((e) => e.libraryExports2) + .expand((e) => e.libraryExports) .map(_LibraryDirectives.fromExport) .nonNulls : fragments - .expand((e) => e.libraryImports2) + .expand((e) => e.libraryImports) .map(_LibraryDirectives.fromImport) .nonNulls; @@ -55,8 +55,8 @@ extension FindAllAvailableTopLevelElements on LibraryElement2 { return (directive.showStatements.isEmpty && directive.hideStatements.isEmpty) || (directive.hideStatements.isNotEmpty && - !directive.hideStatements.contains(element.name3)) || - directive.showStatements.contains(element.name3); + !directive.hideStatements.contains(element.name)) || + directive.showStatements.contains(element.name); }); } } @@ -70,7 +70,7 @@ class _LibraryDirectives { }); static _LibraryDirectives? fromExport(LibraryExport export) { - final library = export.exportedLibrary2; + final library = export.exportedLibrary; if (library == null) return null; final hideStatements = export.combinators @@ -91,7 +91,7 @@ class _LibraryDirectives { } static _LibraryDirectives? fromImport(LibraryImport export) { - final library = export.importedLibrary2; + final library = export.importedLibrary; if (library == null) return null; final hideStatements = export.combinators @@ -113,7 +113,7 @@ class _LibraryDirectives { final Set hideStatements; final Set showStatements; - final LibraryElement2 library; + final LibraryElement library; _LibraryKey get key { return _LibraryKey( diff --git a/packages/freezed/lib/src/tools/type.dart b/packages/freezed/lib/src/tools/type.dart index b269d1e8..5e3ae210 100644 --- a/packages/freezed/lib/src/tools/type.dart +++ b/packages/freezed/lib/src/tools/type.dart @@ -1,4 +1,4 @@ -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/nullability_suffix.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:collection/collection.dart'; @@ -24,26 +24,26 @@ extension DartTypeX on DartType { } } -/// Returns the [Element2] for a given [DartType] +/// Returns the [Element] for a given [DartType] /// /// this is usually type.element, except if it is a typedef then it is /// type.alias.element -Element2? _getElementForType(DartType type) { +Element? _getElementForType(DartType type) { if (type is InterfaceType) { - return type.element3; + return type.element; } if (type is FunctionType) { - return type.alias?.element2; + return type.alias?.element; } return null; } /// Renders a type based on its string + potential import alias -String resolveFullTypeStringFrom(LibraryElement2 originLibrary, DartType type) { +String resolveFullTypeStringFrom(LibraryElement originLibrary, DartType type) { final owner = originLibrary.firstFragment.prefixes.firstWhereOrNull((e) { return e.imports.any((l) { - return l.importedLibrary2!.anyTransitiveExport((library) { - return library.id == _getElementForType(type)?.library2?.id; + return l.importedLibrary!.anyTransitiveExport((library) { + return library.id == _getElementForType(type)?.library?.id; }); }); }); @@ -62,8 +62,8 @@ String resolveFullTypeStringFrom(LibraryElement2 originLibrary, DartType type) { // 'dynamic Function(String)' // // Instead of 'SomeTypedef' - if (type is FunctionType && type.alias?.element2 != null) { - displayType = type.alias!.element2.name3!; + if (type is FunctionType && type.alias?.element != null) { + displayType = type.alias!.element.name!; if (type.alias!.typeArguments.isNotEmpty) { displayType += '<${type.alias!.typeArguments.join(', ')}>'; } @@ -84,14 +84,14 @@ String resolveFullTypeStringFrom(LibraryElement2 originLibrary, DartType type) { // This a regression in analyzer 5.13.0 if (type is InterfaceType && type.typeArguments.any((e) => e is InvalidType)) { - final dynamicType = type.element3.library2.typeProvider.dynamicType; + final dynamicType = type.element.library.typeProvider.dynamicType; var modified = type; modified.typeArguments..replaceWhere((t) => t is InvalidType, dynamicType); displayType = modified.getDisplayString(); } if (owner != null) { - return '${owner.name3}.$displayType'; + return '${owner.name}.$displayType'; } return displayType; diff --git a/packages/freezed/pubspec.yaml b/packages/freezed/pubspec.yaml index 02055856..a1cd3607 100644 --- a/packages/freezed/pubspec.yaml +++ b/packages/freezed/pubspec.yaml @@ -8,26 +8,27 @@ issue_tracker: https://github.com/rrousselGit/freezed/issues environment: sdk: ">=3.8.0 <4.0.0" +resolution: workspace dependencies: - analyzer: ">=7.5.9 <8.0.0" - build: ^3.0.0 + analyzer: ^8.0.0 + build: ^4.0.0 build_config: ^1.1.0 collection: ^1.15.0 meta: ^1.9.1 - source_gen: ^3.0.0 + source_gen: ^4.0.0 freezed_annotation: 3.1.0 - json_annotation: ^4.8.0 - dart_style: ^3.0.0 + json_annotation: ^4.9.0 + dart_style: ^3.1.0 pub_semver: ^2.2.0 dev_dependencies: json_serializable: ^6.10.0 build_test: ^3.3.0 - build_runner: ^2.3.3 + build_runner: ^2.8.0 test: ^1.21.0 matcher: ^0.12.14 - source_gen_test: ^1.2.0 + source_gen_test: ^1.3.1 expect_error: ^1.0.10 flutter: sdk: flutter diff --git a/packages/freezed/pubspec_overrides.yaml b/packages/freezed/pubspec_overrides.yaml deleted file mode 100644 index 6ba2de87..00000000 --- a/packages/freezed/pubspec_overrides.yaml +++ /dev/null @@ -1,17 +0,0 @@ -dependency_overrides: - freezed_annotation: - path: ../freezed_annotation - # pub downgrade: - # build_runner 2.2.0 => glob 2.0.0 => file 6.0.0 - # freezed requires file: ^6.1.3 - file: ^6.1.3 - # analyzer 5.2.0 => pub_semver 2.0.0 - # freezed requires pub_semver: ^2.1.3 - pub_semver: ^2.1.3 - # expect_error 1.0.4 => pubspec 2.0.1 => uri 1.0.0 => quiver 3.0.0 - # freezed requires quiver: ^3.2.0 - quiver: ^3.2.0 - # watcher 1.0.0 extends, implements, or mixens sealed class 'FileSystemEvent' - watcher: ^1.1.0 - # https://github.com/dart-lang/build/issues/3733#issuecomment-2272082820 - frontend_server_client: ^4.0.0 diff --git a/packages/freezed/test/bidirectional_test.dart b/packages/freezed/test/bidirectional_test.dart index 060f0834..949f7d89 100644 --- a/packages/freezed/test/bidirectional_test.dart +++ b/packages/freezed/test/bidirectional_test.dart @@ -20,7 +20,7 @@ void main() { ) as ErrorsResult; - expect(errorResult.errors, isEmpty); + expect(errorResult.diagnostics, isEmpty); }); test('bidirectional deep_copy', () { diff --git a/packages/freezed/test/common.dart b/packages/freezed/test/common.dart index c4a2cf84..e22ff92e 100644 --- a/packages/freezed/test/common.dart +++ b/packages/freezed/test/common.dart @@ -1,6 +1,5 @@ import 'package:analyzer/dart/analysis/results.dart'; import 'package:analyzer/diagnostic/diagnostic.dart'; -import 'package:analyzer/error/error.dart'; import 'package:build_test/build_test.dart'; import 'package:test/test.dart'; @@ -23,7 +22,7 @@ $src final errorResult = await main!.session.getErrors('/freezed/test/integration/main.dart') as ErrorsResult; - final criticalErrors = errorResult.errors + final criticalErrors = errorResult.diagnostics .where((element) => element.severity == Severity.error) .toList(); @@ -34,7 +33,7 @@ $src class CompileError extends Error { CompileError(this.errors); - final List errors; + final List errors; @override String toString() { diff --git a/packages/freezed/test/common_types_test.dart b/packages/freezed/test/common_types_test.dart index 0b046be1..e92f3827 100644 --- a/packages/freezed/test/common_types_test.dart +++ b/packages/freezed/test/common_types_test.dart @@ -25,7 +25,7 @@ Future main() async { ) as ErrorsResult; - expect(errorResult.errors, isEmpty); + expect(errorResult.diagnostics, isEmpty); }); group('CommonSuperSubtype', () { diff --git a/packages/freezed/test/decorator_test.dart b/packages/freezed/test/decorator_test.dart index 2132d124..1f7f484c 100644 --- a/packages/freezed/test/decorator_test.dart +++ b/packages/freezed/test/decorator_test.dart @@ -17,7 +17,7 @@ void main() { '/freezed/test/integration/decorator.freezed.dart', ) as ErrorsResult; - expect(errorResult.errors, isEmpty); + expect(errorResult.diagnostics, isEmpty); errorResult = await main.session.getErrors('/freezed/test/integration/decorator.dart') as ErrorsResult; @@ -33,32 +33,29 @@ import 'decorator.dart'; ''', }, (r) => r.libraries.firstWhere( - (element) => element.library2.name3 == 'decorator', + (element) => element.library.name == 'decorator', ), readAllSourcesFromFilesystem: true, ); final concrete = main.classes.firstWhere( - (e) => e.name3 == r'ListDecorator0', + (e) => e.name == r'ListDecorator0', ); expect( - concrete.fields2 - .firstWhere((element) => element.name3 == '_a') - .metadata2 + concrete.fields + .firstWhere((element) => element.name == '_a') + .metadata .annotations, isEmpty, ); - final unmodifiableGetter = concrete.fields2 - .firstWhere((element) => element.name3 == 'a') - .getter2!; + final unmodifiableGetter = concrete.fields + .firstWhere((element) => element.name == 'a') + .getter!; - expect(unmodifiableGetter.metadata2.annotations.length, 2); - expect( - unmodifiableGetter.metadata2.annotations.last.toSource(), - '@Foo()', - ); + expect(unmodifiableGetter.metadata.annotations.length, 2); + expect(unmodifiableGetter.metadata.annotations.last.toSource(), '@Foo()'); }, ); @@ -96,7 +93,7 @@ void main() { await main.session.getErrors('/freezed/test/integration/main.dart') as ErrorsResult; expect( - errorResult.errors.map((e) => e.errorCode.name), + errorResult.diagnostics.map((e) => e.diagnosticCode.name), anyOf([ [ 'UNUSED_RESULT', diff --git a/packages/freezed/test/deep_copy_test.dart b/packages/freezed/test/deep_copy_test.dart index 55eae442..6182479f 100644 --- a/packages/freezed/test/deep_copy_test.dart +++ b/packages/freezed/test/deep_copy_test.dart @@ -31,7 +31,7 @@ void main() { ) as ErrorsResult; - expect(errorResult.errors, isEmpty); + expect(errorResult.diagnostics, isEmpty); }); test('has no issue #2', () async { @@ -49,7 +49,7 @@ void main() { ) as ErrorsResult; - expect(errorResult.errors, isEmpty); + expect(errorResult.diagnostics, isEmpty); }); test('handles null', () { @@ -422,7 +422,7 @@ void main() { import 'deep_copy.dart'; void main() { - final value = NoCommonProperty.assistant!(Assistant()); + final value = NoCommonProperty.assistant!(Assistant()); NoCommonPropertyAssistant copy = value.copyWith(assistant: Assistant()); } '''), @@ -734,7 +734,7 @@ void main() { await main.session.getErrors('/freezed/test/integration/main.dart') as ErrorsResult; - expect(errorResult.errors.map((e) => e.errorCode.name), [ + expect(errorResult.diagnostics.map((e) => e.diagnosticCode.name), [ 'UNUSED_RESULT', 'UNUSED_RESULT', ]); diff --git a/packages/freezed/test/generic_test.dart b/packages/freezed/test/generic_test.dart index 818d40c5..7b8425f8 100644 --- a/packages/freezed/test/generic_test.dart +++ b/packages/freezed/test/generic_test.dart @@ -52,7 +52,7 @@ void main() { ) as ErrorsResult; - expect(errorResult.errors, isEmpty); + expect(errorResult.diagnostics, isEmpty); }); test('is generic', () { diff --git a/packages/freezed/test/generics_refs_test.dart b/packages/freezed/test/generics_refs_test.dart index 4a13ca97..d74abeb9 100644 --- a/packages/freezed/test/generics_refs_test.dart +++ b/packages/freezed/test/generics_refs_test.dart @@ -21,7 +21,7 @@ void main() { ) as ErrorsResult; - expect(errorResult.errors, isEmpty); + expect(errorResult.diagnostics, isEmpty); }); test('handles lists', () async { diff --git a/packages/freezed/test/json_test.dart b/packages/freezed/test/json_test.dart index f3a6e255..f6ed6925 100644 --- a/packages/freezed/test/json_test.dart +++ b/packages/freezed/test/json_test.dart @@ -752,7 +752,7 @@ Future main() async { '/freezed/test/integration/json.freezed.dart', ) as ErrorsResult; - expect(errorResult.errors, isEmpty); + expect(errorResult.diagnostics, isEmpty); }, skip: true); test("single constructor fromJson doesn't require type", () { diff --git a/packages/freezed/test/map_test.dart b/packages/freezed/test/map_test.dart index 0949bd1f..95057deb 100644 --- a/packages/freezed/test/map_test.dart +++ b/packages/freezed/test/map_test.dart @@ -303,7 +303,7 @@ void main() { await main!.session.getErrors('/freezed/test/integration/main.dart') as ErrorsResult; - expect(errorResult.errors, isNotEmpty); + expect(errorResult.diagnostics, isNotEmpty); }); }); @@ -424,7 +424,7 @@ void main() { await main!.session.getErrors('/freezed/test/integration/main.dart') as ErrorsResult; - expect(errorResult.errors, isNotEmpty); + expect(errorResult.diagnostics, isNotEmpty); }); }); diff --git a/packages/freezed/test/multiple_constructors_test.dart b/packages/freezed/test/multiple_constructors_test.dart index 99b2d483..26cefe85 100644 --- a/packages/freezed/test/multiple_constructors_test.dart +++ b/packages/freezed/test/multiple_constructors_test.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:analyzer/dart/analysis/results.dart'; -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:build_test/build_test.dart'; import 'package:test/test.dart'; @@ -23,8 +23,8 @@ Future main() async { readAllSourcesFromFilesystem: true, ); - ClassElement2 _getClassElement(String elementName) { - return sources.classes.singleWhere((e) => e.name3 == elementName); + ClassElement _getClassElement(String elementName) { + return sources.classes.singleWhere((e) => e.name == elementName); } test('Response', () { @@ -37,14 +37,14 @@ Future main() async { test('recursive class does not generate dynamic', () async { final recursiveClass = _getClassElement('_RecursiveNext'); - expect(recursiveClass.getField2('value')!.type, isA()); + expect(recursiveClass.getField('value')!.type, isA()); }); test('recursive class with dollar generates correctly', () async { final recursiveClass = _getClassElement('_RecursiveWith\$DollarNext'); expect( - recursiveClass.getField2('value')!.type.getDisplayString(), + recursiveClass.getField('value')!.type.getDisplayString(), 'RecursiveWith\$DollarImpl', ); }); @@ -65,53 +65,53 @@ Future main() async { expect( complex.mixins.first.getters.first, - isA() - .having((e) => e.name3, 'name', 'a') + isA() + .having((e) => e.name, 'name', 'a') .having((e) => e.documentationComment, 'doc', '/// Hello'), ); expect( - complex0.fields2.where( - (e) => e.name3 != 'copyWith' && e.name3 != 'hashCode', + complex0.fields.where( + (e) => e.name != 'copyWith' && e.name != 'hashCode', ), [ - isA() - .having((e) => e.name3, 'name', 'a') + isA() + .having((e) => e.name, 'name', 'a') .having((e) => e.documentationComment, 'doc', '/// Hello'), ], ); expect( - complex1.fields2.where( - (e) => e.name3 != 'copyWith' && e.name3 != 'hashCode', + complex1.fields.where( + (e) => e.name != 'copyWith' && e.name != 'hashCode', ), [ - isA() - .having((e) => e.name3, 'name', 'a') + isA() + .having((e) => e.name, 'name', 'a') .having((e) => e.documentationComment, 'doc', '/// World'), - isA() - .having((e) => e.name3, 'name', 'b') + isA() + .having((e) => e.name, 'name', 'b') .having((e) => e.documentationComment, 'doc', '/// B'), - isA() - .having((e) => e.name3, 'name', 'd') + isA() + .having((e) => e.name, 'name', 'd') .having((e) => e.documentationComment, 'doc', null), ], ); expect( - complex2.fields2.where( - (e) => e.name3 != 'copyWith' && e.name3 != 'hashCode', + complex2.fields.where( + (e) => e.name != 'copyWith' && e.name != 'hashCode', ), [ - isA() - .having((e) => e.name3, 'name', 'a') + isA() + .having((e) => e.name, 'name', 'a') // The doc is inherited from `Complex` .having((e) => e.documentationComment, 'doc', null), - isA() - .having((e) => e.name3, 'name', 'c') + isA() + .having((e) => e.name, 'name', 'c') .having((e) => e.documentationComment, 'doc', '/// C'), - isA() - .having((e) => e.name3, 'name', 'd') + isA() + .having((e) => e.name, 'name', 'd') .having((e) => e.documentationComment, 'doc', null), ], ); @@ -181,7 +181,7 @@ void main() { ) as ErrorsResult; - expect(errorResult.errors, isEmpty); + expect(errorResult.diagnostics, isEmpty); }); test('can mutate unfreezed unions', () { @@ -574,7 +574,7 @@ void main() { final nestedListClass = _getClassElement('ShallowNestedList'); expect( - nestedListClass.getField2('children')!.type.getDisplayString(), + nestedListClass.getField('children')!.type.getDisplayString(), 'List', ); }); @@ -583,14 +583,14 @@ void main() { final nestedListClass = _getClassElement('DeepNestedList'); expect( - nestedListClass.getField2('children')!.type.getDisplayString(), + nestedListClass.getField('children')!.type.getDisplayString(), 'List', ); final nestedListItemClass = _getClassElement('InnerNestedListItem'); expect( - nestedListItemClass.getField2('children')!.type.getDisplayString(), + nestedListItemClass.getField('children')!.type.getDisplayString(), 'List', ); }); @@ -600,7 +600,7 @@ void main() { final nestedMapClass = _getClassElement('ShallowNestedMap'); expect( - nestedMapClass.getField2('children')!.type.getDisplayString(), + nestedMapClass.getField('children')!.type.getDisplayString(), 'Map', ); }); @@ -609,14 +609,14 @@ void main() { final nestedMapClass = _getClassElement('DeepNestedMap'); expect( - nestedMapClass.getField2('children')!.type.getDisplayString(), + nestedMapClass.getField('children')!.type.getDisplayString(), 'Map', ); final nestedMapItemClass = _getClassElement('InnerNestedMapItem'); expect( - nestedMapItemClass.getField2('children')!.type.getDisplayString(), + nestedMapItemClass.getField('children')!.type.getDisplayString(), 'Map', ); }); @@ -627,19 +627,19 @@ void main() { final nestedMapClass = _getClassElement('_UsesGenerated'); expect( - nestedMapClass.getField2('value')!.type.getDisplayString(), + nestedMapClass.getField('value')!.type.getDisplayString(), 'CodeGenerated', ); expect( - nestedMapClass.getField2('list')!.type.getDisplayString(), + nestedMapClass.getField('list')!.type.getDisplayString(), 'List', ); expect( - nestedMapClass.getField2('nestedList')!.type.getDisplayString(), + nestedMapClass.getField('nestedList')!.type.getDisplayString(), 'List>', ); expect( - nestedMapClass.getField2('map')!.type.getDisplayString(), + nestedMapClass.getField('map')!.type.getDisplayString(), 'Map', ); }); diff --git a/packages/freezed/test/optional_maybe_test.dart b/packages/freezed/test/optional_maybe_test.dart index fb55c1fc..2fd7432d 100644 --- a/packages/freezed/test/optional_maybe_test.dart +++ b/packages/freezed/test/optional_maybe_test.dart @@ -21,7 +21,7 @@ void main() { ) as ErrorsResult; - expect(errorResult.errors, isEmpty); + expect(errorResult.diagnostics, isEmpty); }); test('does not generates maybeMap', () async { diff --git a/packages/freezed/test/single_class_constructor_test.dart b/packages/freezed/test/single_class_constructor_test.dart index 475db64f..9164b407 100644 --- a/packages/freezed/test/single_class_constructor_test.dart +++ b/packages/freezed/test/single_class_constructor_test.dart @@ -1,6 +1,6 @@ // ignore_for_file: prefer_const_constructors, omit_local_variable_types, deprecated_member_use_from_same_package import 'package:analyzer/dart/analysis/results.dart'; -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:build_test/build_test.dart'; import 'package:test/test.dart'; @@ -25,7 +25,7 @@ class MyObject { } Future main() async { - Future analyze() { + Future analyze() { return resolveSources( { 'freezed|test/integration/single_class_constructor.dart': @@ -211,28 +211,28 @@ Future main() async { test('documentation', () async { final singleClassLibrary = await analyze(); - final doc = singleClassLibrary.classes.firstWhere((e) => e.name3 == 'Doc'); + final doc = singleClassLibrary.classes.firstWhere((e) => e.name == 'Doc'); expect( doc.mixins.first.getters.where( - (e) => e.name3 != 'copyWith' && e.name3 != 'hashCode', + (e) => e.name != 'copyWith' && e.name != 'hashCode', ), [ - isA() - .having((e) => e.name3, 'name', 'positional') + isA() + .having((e) => e.name, 'name', 'positional') .having((e) => e.documentationComment, 'doc', ''' /// Multi /// line /// positional'''), - isA() // - .having((e) => e.name3, 'name', 'named') + isA() // + .having((e) => e.name, 'name', 'named') .having( (e) => e.documentationComment, 'doc', '/// Single line named', ), - isA() // - .having((e) => e.name3, 'name', 'simple') + isA() // + .having((e) => e.name, 'name', 'simple') .having((e) => e.documentationComment, 'doc', null), ], ); @@ -379,7 +379,7 @@ void main() { ) as ErrorsResult; - expect(errorResult.errors, isEmpty); + expect(errorResult.diagnostics, isEmpty); }); test('toString includes the constructor name', () { @@ -651,7 +651,7 @@ void main() { as ErrorsResult; expect( - errorResult.errors.map((e) => e.toString()), + errorResult.diagnostics.map((e) => e.toString()), anyElement(contains("The named parameter 'a' is required")), ); }, diff --git a/packages/freezed/test/typedef_parameter_test.dart b/packages/freezed/test/typedef_parameter_test.dart index 5b417af2..d500e0c2 100644 --- a/packages/freezed/test/typedef_parameter_test.dart +++ b/packages/freezed/test/typedef_parameter_test.dart @@ -21,7 +21,7 @@ void main() { ) as ErrorsResult; - expect(errorResult.errors, isEmpty); + expect(errorResult.diagnostics, isEmpty); }); test('generates correct typedefs', () async { @@ -36,33 +36,33 @@ void main() { ); var freezedClass = main.classes.firstWhere( - (element) => element.name3 == '_ClassWithTypedef', + (element) => element.name == '_ClassWithTypedef', ); - var constructor = freezedClass.constructors2.firstWhere( - (element) => element.name3 == 'new', + var constructor = freezedClass.constructors.firstWhere( + (element) => element.name == 'new', ); var a = constructor.formalParameters.first.type; expect(a, isA()); - expect(a.alias!.element2.name3, equals('MyTypedef')); + expect(a.alias!.element.name, equals('MyTypedef')); var b = constructor.formalParameters[1].type; expect(b, isA()); - expect(b.alias!.element2.name3, equals('MyTypedef')); + expect(b.alias!.element.name, equals('MyTypedef')); expect(b.nullabilitySuffix, equals(NullabilitySuffix.question)); var c = constructor.formalParameters[2].type; expect(c, isA()); - expect(c.alias!.element2.name3, equals('ExternalTypedef')); + expect(c.alias!.element.name, equals('ExternalTypedef')); var d = constructor.formalParameters[3].type; expect(d, isA()); - expect(d.alias!.element2.name3, equals('ExternalTypedefTwo')); + expect(d.alias!.element.name, equals('ExternalTypedefTwo')); var e = constructor.formalParameters[4].type; expect(e, isA()); - expect(e.alias!.element2.name3, equals('GenericTypedef')); + expect(e.alias!.element.name, equals('GenericTypedef')); expect(e.alias!.typeArguments.toString(), equals('[int, bool]')); }); } diff --git a/packages/freezed/test/when_test.dart b/packages/freezed/test/when_test.dart index 441f7ba1..9777a8c7 100644 --- a/packages/freezed/test/when_test.dart +++ b/packages/freezed/test/when_test.dart @@ -302,7 +302,7 @@ void main() { await main!.session.getErrors('/freezed/test/integration/main.dart') as ErrorsResult; - expect(errorResult.errors, isNotEmpty); + expect(errorResult.diagnostics, isNotEmpty); }); }); diff --git a/packages/freezed_annotation/.gitignore b/packages/freezed_annotation/.gitignore index 220a573b..637a17cb 100644 --- a/packages/freezed_annotation/.gitignore +++ b/packages/freezed_annotation/.gitignore @@ -1,6 +1,3 @@ -/.dart_tool /test/**/*.g.dart /test/**/*.freezed.dart .packages -# Remove the following pattern if you wish to check in your lock file -pubspec.lock \ No newline at end of file diff --git a/packages/freezed_annotation/pubspec.yaml b/packages/freezed_annotation/pubspec.yaml index 945c965e..d93ba737 100644 --- a/packages/freezed_annotation/pubspec.yaml +++ b/packages/freezed_annotation/pubspec.yaml @@ -7,11 +7,12 @@ repository: https://github.com/rrousselGit/freezed issue_tracker: https://github.com/rrousselGit/freezed/issues environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.5.0 <4.0.0" +resolution: workspace dependencies: collection: ^1.15.0 - json_annotation: ^4.8.0 + json_annotation: ^4.9.0 meta: ^1.7.0 dev_dependencies: diff --git a/packages/freezed_annotation/pubspec_overrides.yaml b/packages/freezed_annotation/pubspec_overrides.yaml deleted file mode 100644 index 0e3d234a..00000000 --- a/packages/freezed_annotation/pubspec_overrides.yaml +++ /dev/null @@ -1,15 +0,0 @@ -dependency_overrides: - # pub downgrade: - # build_runner 2.2.0 => glob 2.0.0 => file 6.0.0 - # freezed requires file: ^6.1.3 - file: ^6.1.3 - # build_runner 2.3.3 => code_builder 4.2.0 => matcher 0.12.11 - # freezed requires matcher: ^0.12.14 - matcher: ^0.12.14 - # build_runner 2.3.3 => pub_semver 2.0.0 - # freezed requires pub_semver: ^2.1.3 - pub_semver: ^2.1.3 - # watcher 1.0.0 extends, implements, or mixens sealed class 'FileSystemEvent' - watcher: ^1.1.0 - # https://github.com/dart-lang/build/issues/3733#issuecomment-2272082820 - frontend_server_client: ^4.0.0 diff --git a/packages/freezed_lint/.gitignore b/packages/freezed_lint/.gitignore index 8ecd45da..2f8179aa 100644 --- a/packages/freezed_lint/.gitignore +++ b/packages/freezed_lint/.gitignore @@ -1,5 +1,2 @@ -/.dart_tool .packages -# Remove the following pattern if you wish to check in your lock file -pubspec.lock -custom_lint.log \ No newline at end of file +custom_lint.log diff --git a/packages/freezed_lint/example/analysis_options.yaml b/packages/freezed_lint/example/analysis_options.yaml index 1c31e2ac..16458d64 100644 --- a/packages/freezed_lint/example/analysis_options.yaml +++ b/packages/freezed_lint/example/analysis_options.yaml @@ -7,5 +7,11 @@ analyzer: strict-raw-types: true errors: invalid_annotation_target: ignore + + # Expected errors + uri_does_not_exist: ignore + redirect_to_non_class: ignore + mixin_of_non_class: ignore + unused_element: ignore plugins: - - custom_lint \ No newline at end of file + - custom_lint diff --git a/packages/freezed_lint/example/lib/missing_mixin.freezed.dart b/packages/freezed_lint/example/lib/missing_mixin.freezed.dart deleted file mode 100644 index 4e5f531f..00000000 --- a/packages/freezed_lint/example/lib/missing_mixin.freezed.dart +++ /dev/null @@ -1,404 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'missing_mixin.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -/// @nodoc -mixin _$MissingMixin {} - -/// @nodoc -abstract class $MissingMixinCopyWith<$Res> { - factory $MissingMixinCopyWith( - MissingMixin value, $Res Function(MissingMixin) then) = - _$MissingMixinCopyWithImpl<$Res, MissingMixin>; -} - -/// @nodoc -class _$MissingMixinCopyWithImpl<$Res, $Val extends MissingMixin> - implements $MissingMixinCopyWith<$Res> { - _$MissingMixinCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of MissingMixin - /// with the given fields replaced by the non-null parameter values. -} - -/// @nodoc -abstract class _$$MissingMixinImplCopyWith<$Res> { - factory _$$MissingMixinImplCopyWith( - _$MissingMixinImpl value, $Res Function(_$MissingMixinImpl) then) = - __$$MissingMixinImplCopyWithImpl<$Res>; -} - -/// @nodoc -class __$$MissingMixinImplCopyWithImpl<$Res> - extends _$MissingMixinCopyWithImpl<$Res, _$MissingMixinImpl> - implements _$$MissingMixinImplCopyWith<$Res> { - __$$MissingMixinImplCopyWithImpl( - _$MissingMixinImpl _value, $Res Function(_$MissingMixinImpl) _then) - : super(_value, _then); - - /// Create a copy of MissingMixin - /// with the given fields replaced by the non-null parameter values. -} - -/// @nodoc - -class _$MissingMixinImpl implements _MissingMixin { - const _$MissingMixinImpl(); - - @override - String toString() { - return 'MissingMixin()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$MissingMixinImpl); - } - - @override - int get hashCode => runtimeType.hashCode; -} - -abstract class _MissingMixin implements MissingMixin { - const factory _MissingMixin() = _$MissingMixinImpl; -} - -/// @nodoc -mixin _$WithMixin {} - -/// @nodoc -abstract class $WithMixinCopyWith<$Res> { - factory $WithMixinCopyWith(WithMixin value, $Res Function(WithMixin) then) = - _$WithMixinCopyWithImpl<$Res, WithMixin>; -} - -/// @nodoc -class _$WithMixinCopyWithImpl<$Res, $Val extends WithMixin> - implements $WithMixinCopyWith<$Res> { - _$WithMixinCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of WithMixin - /// with the given fields replaced by the non-null parameter values. -} - -/// @nodoc -abstract class _$$WithMixinImplCopyWith<$Res> { - factory _$$WithMixinImplCopyWith( - _$WithMixinImpl value, $Res Function(_$WithMixinImpl) then) = - __$$WithMixinImplCopyWithImpl<$Res>; -} - -/// @nodoc -class __$$WithMixinImplCopyWithImpl<$Res> - extends _$WithMixinCopyWithImpl<$Res, _$WithMixinImpl> - implements _$$WithMixinImplCopyWith<$Res> { - __$$WithMixinImplCopyWithImpl( - _$WithMixinImpl _value, $Res Function(_$WithMixinImpl) _then) - : super(_value, _then); - - /// Create a copy of WithMixin - /// with the given fields replaced by the non-null parameter values. -} - -/// @nodoc - -class _$WithMixinImpl implements _WithMixin { - const _$WithMixinImpl(); - - @override - String toString() { - return 'WithMixin()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$WithMixinImpl); - } - - @override - int get hashCode => runtimeType.hashCode; -} - -abstract class _WithMixin implements WithMixin { - const factory _WithMixin() = _$WithMixinImpl; -} - -/// @nodoc -mixin _$FooModel { - int get id => throw _privateConstructorUsedError; - - /// Create a copy of FooModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $FooModelCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $FooModelCopyWith<$Res> { - factory $FooModelCopyWith(FooModel value, $Res Function(FooModel) then) = - _$FooModelCopyWithImpl<$Res, FooModel>; - @useResult - $Res call({int id}); -} - -/// @nodoc -class _$FooModelCopyWithImpl<$Res, $Val extends FooModel> - implements $FooModelCopyWith<$Res> { - _$FooModelCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of FooModel - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - }) { - return _then(_value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$FooModelImplCopyWith<$Res> - implements $FooModelCopyWith<$Res> { - factory _$$FooModelImplCopyWith( - _$FooModelImpl value, $Res Function(_$FooModelImpl) then) = - __$$FooModelImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({int id}); -} - -/// @nodoc -class __$$FooModelImplCopyWithImpl<$Res> - extends _$FooModelCopyWithImpl<$Res, _$FooModelImpl> - implements _$$FooModelImplCopyWith<$Res> { - __$$FooModelImplCopyWithImpl( - _$FooModelImpl _value, $Res Function(_$FooModelImpl) _then) - : super(_value, _then); - - /// Create a copy of FooModel - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - }) { - return _then(_$FooModelImpl( - null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - )); - } -} - -/// @nodoc - -class _$FooModelImpl extends _FooModel { - const _$FooModelImpl(this.id) : super._(); - - @override - final int id; - - @override - String toString() { - return 'FooModel(id: $id)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$FooModelImpl && - (identical(other.id, id) || other.id == id)); - } - - @override - int get hashCode => Object.hash(runtimeType, id); - - /// Create a copy of FooModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$FooModelImplCopyWith<_$FooModelImpl> get copyWith => - __$$FooModelImplCopyWithImpl<_$FooModelImpl>(this, _$identity); -} - -abstract class _FooModel extends FooModel { - const factory _FooModel(final int id) = _$FooModelImpl; - const _FooModel._() : super._(); - - @override - int get id; - - /// Create a copy of FooModel - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$FooModelImplCopyWith<_$FooModelImpl> get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -mixin _$BarModel { - int get id => throw _privateConstructorUsedError; - - /// Create a copy of BarModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $BarModelCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $BarModelCopyWith<$Res> { - factory $BarModelCopyWith(BarModel value, $Res Function(BarModel) then) = - _$BarModelCopyWithImpl<$Res, BarModel>; - @useResult - $Res call({int id}); -} - -/// @nodoc -class _$BarModelCopyWithImpl<$Res, $Val extends BarModel> - implements $BarModelCopyWith<$Res> { - _$BarModelCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of BarModel - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - }) { - return _then(_value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$BarModelImplCopyWith<$Res> - implements $BarModelCopyWith<$Res> { - factory _$$BarModelImplCopyWith( - _$BarModelImpl value, $Res Function(_$BarModelImpl) then) = - __$$BarModelImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({int id}); -} - -/// @nodoc -class __$$BarModelImplCopyWithImpl<$Res> - extends _$BarModelCopyWithImpl<$Res, _$BarModelImpl> - implements _$$BarModelImplCopyWith<$Res> { - __$$BarModelImplCopyWithImpl( - _$BarModelImpl _value, $Res Function(_$BarModelImpl) _then) - : super(_value, _then); - - /// Create a copy of BarModel - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - }) { - return _then(_$BarModelImpl( - null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - )); - } -} - -/// @nodoc - -class _$BarModelImpl extends _BarModel { - const _$BarModelImpl(this.id) : super._(); - - @override - final int id; - - @override - String toString() { - return 'BarModel(id: $id)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$BarModelImpl && - (identical(other.id, id) || other.id == id)); - } - - @override - int get hashCode => Object.hash(runtimeType, id); - - /// Create a copy of BarModel - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$BarModelImplCopyWith<_$BarModelImpl> get copyWith => - __$$BarModelImplCopyWithImpl<_$BarModelImpl>(this, _$identity); -} - -abstract class _BarModel extends BarModel { - const factory _BarModel(final int id) = _$BarModelImpl; - const _BarModel._() : super._(); - - @override - int get id; - - /// Create a copy of BarModel - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$BarModelImplCopyWith<_$BarModelImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/packages/freezed_lint/example/pubspec.yaml b/packages/freezed_lint/example/pubspec.yaml index 5379bf58..dd61c9e4 100644 --- a/packages/freezed_lint/example/pubspec.yaml +++ b/packages/freezed_lint/example/pubspec.yaml @@ -1,7 +1,8 @@ # The pubspec.yaml of an application using our lints -name: example_app +name: lint_example environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.8.0 <4.0.0" +resolution: workspace publish_to: none dependencies: @@ -12,7 +13,3 @@ dev_dependencies: custom_lint: any freezed: any freezed_lint: any - -dependency_overrides: - freezed_lint: - path: ../ diff --git a/packages/freezed_lint/lib/src/missing_mixin.dart b/packages/freezed_lint/lib/src/missing_mixin.dart index f8374a02..788179dd 100644 --- a/packages/freezed_lint/lib/src/missing_mixin.dart +++ b/packages/freezed_lint/lib/src/missing_mixin.dart @@ -1,5 +1,5 @@ -import 'package:analyzer/error/error.dart' hide LintCode; -import 'package:analyzer/error/listener.dart' show ErrorReporter; +import 'package:analyzer/diagnostic/diagnostic.dart'; +import 'package:analyzer/error/listener.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; import 'package:freezed_lint/src/tools/freezed_annotation_checker.dart'; @@ -8,13 +8,13 @@ class MissingMixin extends DartLintRule { static const _code = LintCode( name: 'freezed_missing_mixin', - problemMessage: 'Freezed class should mixin with {0}', + problemMessage: 'Freezed class should mixin {0}', ); @override void run( CustomLintResolver resolver, - ErrorReporter reporter, + DiagnosticReporter reporter, CustomLintContext context, ) { context.registry.addClassDeclaration((node) { @@ -24,7 +24,7 @@ class MissingMixin extends DartLintRule { final annotation = freezedAnnotationChecker.hasAnnotationOfExact(element); if (!annotation) return; - final name = '_\$${element.name3}'; + final name = '_\$${element.name}'; final withClause = node.withClause; if (withClause == null) { reporter.atElement2(element, _code, arguments: [name]); @@ -32,7 +32,7 @@ class MissingMixin extends DartLintRule { } final mixins = withClause.mixinTypes; - if (mixins.any((m) => name == m.name2.lexeme)) return; + if (mixins.any((m) => name == m.name.lexeme)) return; reporter.atElement2(element, _code, arguments: [name]); }); } @@ -47,8 +47,8 @@ class _AddMixinFreezedClassFix extends DartFix { CustomLintResolver resolver, ChangeReporter reporter, CustomLintContext context, - AnalysisError analysisError, - List others, + Diagnostic analysisError, + List others, ) { context.registry.addClassDeclaration((node) { if (!analysisError.sourceRange.intersects(node.sourceRange)) return; diff --git a/packages/freezed_lint/lib/src/missing_private_empty_ctor.dart b/packages/freezed_lint/lib/src/missing_private_empty_ctor.dart index 23c11638..41f82551 100644 --- a/packages/freezed_lint/lib/src/missing_private_empty_ctor.dart +++ b/packages/freezed_lint/lib/src/missing_private_empty_ctor.dart @@ -1,5 +1,6 @@ +import 'package:analyzer/diagnostic/diagnostic.dart'; import 'package:analyzer/error/error.dart' hide LintCode; -import 'package:analyzer/error/listener.dart' show ErrorReporter; +import 'package:analyzer/error/listener.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; import 'package:freezed_lint/src/tools/element_extensions.dart'; import 'package:freezed_lint/src/tools/freezed_annotation_checker.dart'; @@ -11,15 +12,15 @@ class MissingPrivateEmptyCtor extends DartLintRule { name: 'freezed_missing_private_empty_constructor', problemMessage: 'Private empty constructor required', correctionMessage: - 'Freezed classes containing methods, fields or accessors,' + 'Freezed classes containing methods, fields or accessors, ' 'requires a {0}', - errorSeverity: ErrorSeverity.ERROR, + severity: DiagnosticSeverity.ERROR, ); @override void run( CustomLintResolver resolver, - ErrorReporter reporter, + DiagnosticReporter reporter, CustomLintContext context, ) { context.registry.addClassDeclaration((node) { @@ -29,17 +30,17 @@ class MissingPrivateEmptyCtor extends DartLintRule { final annotation = freezedAnnotationChecker.hasAnnotationOfExact(element); if (!annotation) return; - final methods = element.methods2.where((method) => !method.isStatic); - final fields = element.fields2.where((field) => !field.isStatic); + final methods = element.methods.where((method) => !method.isStatic); + final fields = element.fields.where((field) => !field.isStatic); final accessors = [ - ...element.getters2, - ...element.setters2, + ...element.getters, + ...element.setters, ].where((accessor) => !accessor.isStatic); if (methods.isEmpty && fields.isEmpty && accessors.isEmpty) return; - final ctors = element.constructors2.where((ctor) => - ctor.isPrivate && ctor.formalParameters.isEmpty && ctor.name3 == '_'); + final ctors = element.constructors.where((ctor) => + ctor.isPrivate && ctor.formalParameters.isEmpty && ctor.name == '_'); if (ctors.isNotEmpty) return; final constToken = element.constToken(); @@ -58,8 +59,8 @@ class _AddPrivateEmptyCtorFix extends DartFix { CustomLintResolver resolver, ChangeReporter reporter, CustomLintContext context, - AnalysisError analysisError, - List others, + Diagnostic analysisError, + List others, ) { context.registry.addClassDeclaration((node) { if (!analysisError.sourceRange.intersects(node.sourceRange)) return; diff --git a/packages/freezed_lint/lib/src/tools/element_extensions.dart b/packages/freezed_lint/lib/src/tools/element_extensions.dart index 683e84cd..8c47fca8 100644 --- a/packages/freezed_lint/lib/src/tools/element_extensions.dart +++ b/packages/freezed_lint/lib/src/tools/element_extensions.dart @@ -1,13 +1,13 @@ -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/type.dart'; extension DartTypeExt on DartType { bool hasName(String name) => getDisplayString() == name; } -extension ClassElementExt on ClassElement2 { +extension ClassElementExt on ClassElement { String? constToken() { - if (constructors2.any((c) => c.isConst)) return 'const '; + if (constructors.any((c) => c.isConst)) return 'const '; return null; } } diff --git a/packages/freezed_lint/pubspec.yaml b/packages/freezed_lint/pubspec.yaml index b8522d8f..2600e7bf 100644 --- a/packages/freezed_lint/pubspec.yaml +++ b/packages/freezed_lint/pubspec.yaml @@ -6,13 +6,14 @@ repository: https://github.com/rrousselGit/freezed issue_tracker: https://github.com/rrousselGit/freezed/issues environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.5.0 <4.0.0" +resolution: workspace dependencies: - analyzer: ^7.0.0 - analyzer_plugin: ^0.13.0 + analyzer: ^8.0.0 + analyzer_plugin: ^0.13.4 custom_lint_builder: ^0.8.0 - freezed_annotation: 3.1.0 + freezed_annotation: ^3.1.0 dev_dependencies: custom_lint: ^0.8.0 diff --git a/packages/freezed_lint/pubspec_overrides.yaml b/packages/freezed_lint/pubspec_overrides.yaml deleted file mode 100644 index b055cd3e..00000000 --- a/packages/freezed_lint/pubspec_overrides.yaml +++ /dev/null @@ -1,3 +0,0 @@ -dependency_overrides: - freezed_annotation: - path: ../freezed_annotation diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 00000000..da0ac36a --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,753 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: f0bb5d1648339c8308cc0b9838d8456b3cfe5c91f9dc1a735b4d003269e5da9a + url: "https://pub.dev" + source: hosted + version: "88.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: "0b7b9c329d2879f8f05d6c05b32ee9ec025f39b077864bdb5ac9a7b63418a98f" + url: "https://pub.dev" + source: hosted + version: "8.1.1" + analyzer_plugin: + dependency: transitive + description: + name: analyzer_plugin + sha256: dd574a0ab77de88b7d9c12bc4b626109a5ca9078216a79041a5c24c3a1bd103c + url: "https://pub.dev" + source: hosted + version: "0.13.7" + args: + dependency: "direct overridden" + description: + name: args + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.dev" + source: hosted + version: "2.7.0" + async: + dependency: transitive + description: + name: async + sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + url: "https://pub.dev" + source: hosted + version: "2.13.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + build: + dependency: transitive + description: + name: build + sha256: "5b887c55a0f734b433b3b2d89f9cd1f99eb636b17e268a5b4259258bc916504b" + url: "https://pub.dev" + source: hosted + version: "4.0.0" + build_config: + dependency: transitive + description: + name: build_config + sha256: "4f64382b97504dc2fcdf487d5aae33418e08b4703fc21249e4db6d804a4d0187" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: "8e928697a82be082206edb0b9c99c5a4ad6bc31c9e9b8b2f291ae65cd4a25daa" + url: "https://pub.dev" + source: hosted + version: "4.0.4" + build_runner: + dependency: transitive + description: + name: build_runner + sha256: "804c47c936df75e1911c19a4fb8c46fa8ff2b3099b9f2b2aa4726af3774f734b" + url: "https://pub.dev" + source: hosted + version: "2.8.0" + build_test: + dependency: transitive + description: + name: build_test + sha256: "472beec8c5fe3c733b59348d57dfd2d51f0af8f4901ca61d8f8e418933a502b2" + url: "https://pub.dev" + source: hosted + version: "3.4.0" + build_verify: + dependency: transitive + description: + name: build_verify + sha256: "3b17b59b6d66f9d3e6014996f089902d56cec5760e051c353cc387b9da577652" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: a30f0a0e38671e89a492c44d005b5545b830a961575bbd8336d42869ff71066d + url: "https://pub.dev" + source: hosted + version: "8.12.0" + characters: + dependency: transitive + description: + name: characters + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: "959525d3162f249993882720d52b7e0c833978df229be20702b33d48d91de70f" + url: "https://pub.dev" + source: hosted + version: "2.0.4" + ci: + dependency: transitive + description: + name: ci + sha256: "145d095ce05cddac4d797a158bc4cf3b6016d1fe63d8c3d2fbd7212590adca13" + url: "https://pub.dev" + source: hosted + version: "0.1.0" + cli_config: + dependency: transitive + description: + name: cli_config + sha256: ac20a183a07002b700f0c25e61b7ee46b23c309d76ab7b7640a028f18e4d99ec + url: "https://pub.dev" + source: hosted + version: "0.2.0" + cli_util: + dependency: transitive + description: + name: cli_util + sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c + url: "https://pub.dev" + source: hosted + version: "0.4.2" + clock: + dependency: transitive + description: + name: clock + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" + source: hosted + version: "1.1.2" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: "0ec10bf4a89e4c613960bf1e8b42c64127021740fb21640c29c909826a5eea3e" + url: "https://pub.dev" + source: hosted + version: "4.10.1" + collection: + dependency: transitive + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" + source: hosted + version: "1.19.1" + convert: + dependency: transitive + description: + name: convert + sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68 + url: "https://pub.dev" + source: hosted + version: "3.1.2" + coverage: + dependency: transitive + description: + name: coverage + sha256: "5da775aa218eaf2151c721b16c01c7676fbfdd99cebba2bf64e8b807a28ff94d" + url: "https://pub.dev" + source: hosted + version: "1.15.0" + crypto: + dependency: transitive + description: + name: crypto + sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855" + url: "https://pub.dev" + source: hosted + version: "3.0.6" + csslib: + dependency: transitive + description: + name: csslib + sha256: "09bad715f418841f976c77db72d5398dc1253c21fb9c0c7f0b0b985860b2d58e" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + custom_lint: + dependency: "direct overridden" + description: + path: "packages/custom_lint" + ref: analyzer-8 + resolved-ref: "3e2501bb738c7c9ddbcc3c3b37be7a28c78a4ed2" + url: "https://github.com/lishaduck/dart_custom_lint.git" + source: git + version: "0.8.0" + custom_lint_builder: + dependency: "direct overridden" + description: + path: "packages/custom_lint_builder" + ref: analyzer-8 + resolved-ref: "3e2501bb738c7c9ddbcc3c3b37be7a28c78a4ed2" + url: "https://github.com/lishaduck/dart_custom_lint.git" + source: git + version: "0.8.0" + custom_lint_core: + dependency: "direct overridden" + description: + path: "packages/custom_lint_core" + ref: analyzer-8 + resolved-ref: "3e2501bb738c7c9ddbcc3c3b37be7a28c78a4ed2" + url: "https://github.com/lishaduck/dart_custom_lint.git" + source: git + version: "0.8.0" + custom_lint_visitor: + dependency: "direct overridden" + description: + path: "packages/custom_lint_visitor" + ref: analyzer-8 + resolved-ref: "3e2501bb738c7c9ddbcc3c3b37be7a28c78a4ed2" + url: "https://github.com/lishaduck/dart_custom_lint.git" + source: git + version: "1.0.0+8.1.0" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: c87dfe3d56f183ffe9106a18aebc6db431fc7c98c31a54b952a77f3d54a85697 + url: "https://pub.dev" + source: hosted + version: "3.1.2" + expect_error: + dependency: transitive + description: + name: expect_error + sha256: f72d8aa656d571dd94d0d7b1b63e68ca8f8b8bdf43011f5b0db4064e7fb572d9 + url: "https://pub.dev" + source: hosted + version: "1.0.11" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + url: "https://pub.dev" + source: hosted + version: "1.3.3" + file: + dependency: "direct overridden" + description: + name: file + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" + source: hosted + version: "6.1.4" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.dev" + source: hosted + version: "1.1.1" + flutter: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + flutter_test: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + frontend_server_client: + dependency: "direct overridden" + description: + name: frontend_server_client + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 + url: "https://pub.dev" + source: hosted + version: "4.0.0" + glob: + dependency: transitive + description: + name: glob + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de + url: "https://pub.dev" + source: hosted + version: "2.1.3" + graphs: + dependency: transitive + description: + name: graphs + sha256: "741bbf84165310a68ff28fe9e727332eef1407342fca52759cb21ad8177bb8d0" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + hotreloader: + dependency: transitive + description: + name: hotreloader + sha256: bc167a1163807b03bada490bfe2df25b0d744df359227880220a5cbd04e5734b + url: "https://pub.dev" + source: hosted + version: "4.3.0" + html: + dependency: transitive + description: + name: html + sha256: "6d1264f2dffa1b1101c25a91dff0dc2daee4c18e87cd8538729773c073dbf602" + url: "https://pub.dev" + source: hosted + version: "0.15.6" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: aa6199f908078bb1c5efb8d8638d4ae191aac11b311132c3ef48ce352fb52ef8 + url: "https://pub.dev" + source: hosted + version: "3.2.2" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.dev" + source: hosted + version: "4.1.2" + io: + dependency: transitive + description: + name: io + sha256: dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b + url: "https://pub.dev" + source: hosted + version: "1.0.5" + js: + dependency: transitive + description: + name: js + sha256: "53385261521cc4a0c4658fd0ad07a7d14591cf8fc33abbceae306ddb974888dc" + url: "https://pub.dev" + source: hosted + version: "0.7.2" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" + source: hosted + version: "4.9.0" + json_serializable: + dependency: transitive + description: + name: json_serializable + sha256: "33a040668b31b320aafa4822b7b1e177e163fc3c1e835c6750319d4ab23aa6fe" + url: "https://pub.dev" + source: hosted + version: "6.11.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "8dcda04c3fc16c14f48a7bb586d4be1f0d1572731b6d81d51772ef47c02081e0" + url: "https://pub.dev" + source: hosted + version: "11.0.1" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" + url: "https://pub.dev" + source: hosted + version: "3.0.10" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" + matcher: + dependency: "direct overridden" + description: + name: matcher + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + url: "https://pub.dev" + source: hosted + version: "0.12.17" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" + source: hosted + version: "0.11.1" + meta: + dependency: transitive + description: + name: meta + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + url: "https://pub.dev" + source: hosted + version: "1.16.0" + mime: + dependency: transitive + description: + name: mime + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + node_preamble: + dependency: transitive + description: + name: node_preamble + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + package_config: + dependency: transitive + description: + name: package_config + sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc + url: "https://pub.dev" + source: hosted + version: "2.2.0" + path: + dependency: transitive + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" + pub_semver: + dependency: "direct overridden" + description: + name: pub_semver + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + quiver: + dependency: "direct overridden" + description: + name: quiver + sha256: ea0b925899e64ecdfbf9c7becb60d5b50e706ade44a85b2363be2a22d88117d2 + url: "https://pub.dev" + source: hosted + version: "3.2.2" + rxdart: + dependency: transitive + description: + name: rxdart + sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962" + url: "https://pub.dev" + source: hosted + version: "0.28.0" + shelf: + dependency: transitive + description: + name: shelf + sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12 + url: "https://pub.dev" + source: hosted + version: "1.4.2" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + shelf_static: + dependency: transitive + description: + name: shelf_static + sha256: c87c3875f91262785dade62d135760c2c69cb217ac759485334c5857ad89f6e3 + url: "https://pub.dev" + source: hosted + version: "1.1.3" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "3632775c8e90d6c9712f883e633716432a27758216dfb61bd86a8321c0580925" + url: "https://pub.dev" + source: hosted + version: "3.0.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: ccf30b0c9fbcd79d8b6f5bfac23199fb354938436f62475e14aea0f29ee0f800 + url: "https://pub.dev" + source: hosted + version: "4.0.1" + source_gen_test: + dependency: transitive + description: + name: source_gen_test + sha256: ea04702ef212a71cf7dcf321cdd4af994aabafe8f09ab7c285aef2770a4449c9 + url: "https://pub.dev" + source: hosted + version: "1.3.2" + source_helper: + dependency: transitive + description: + name: source_helper + sha256: "6a3c6cc82073a8797f8c4dc4572146114a39652851c157db37e964d9c7038723" + url: "https://pub.dev" + source: hosted + version: "1.3.8" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + sha256: c0713a43e323c3302c2abe2a1cc89aa057a387101ebd280371d6a6c9fa68516b + url: "https://pub.dev" + source: hosted + version: "2.1.2" + source_maps: + dependency: transitive + description: + name: source_maps + sha256: "190222579a448b03896e0ca6eca5998fa810fda630c1d65e2f78b3f638f54812" + url: "https://pub.dev" + source: hosted + version: "0.10.13" + source_span: + dependency: transitive + description: + name: source_span + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" + url: "https://pub.dev" + source: hosted + version: "1.10.1" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.dev" + source: hosted + version: "7.0.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" + source: hosted + version: "1.12.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: ad47125e588cfd37a9a7f86c7d6356dde8dfe89d071d293f80ca9e9273a33871 + url: "https://pub.dev" + source: hosted + version: "2.1.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" + source: hosted + version: "1.4.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.dev" + source: hosted + version: "1.2.2" + test: + dependency: transitive + description: + name: test + sha256: "75906bf273541b676716d1ca7627a17e4c4070a3a16272b7a3dc7da3b9f3f6b7" + url: "https://pub.dev" + source: hosted + version: "1.26.3" + test_api: + dependency: "direct overridden" + description: + name: test_api + sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 + url: "https://pub.dev" + source: hosted + version: "0.7.7" + test_core: + dependency: transitive + description: + name: test_core + sha256: "0cc24b5ff94b38d2ae73e1eb43cc302b77964fbf67abad1e296025b78deb53d0" + url: "https://pub.dev" + source: hosted + version: "0.6.12" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + uuid: + dependency: transitive + description: + name: uuid + sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff + url: "https://pub.dev" + source: hosted + version: "4.5.1" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + url: "https://pub.dev" + source: hosted + version: "2.2.0" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60" + url: "https://pub.dev" + source: hosted + version: "15.0.2" + watcher: + dependency: "direct overridden" + description: + name: watcher + sha256: "5bf046f41320ac97a469d506261797f35254fa61c641741ef32dacda98b7d39c" + url: "https://pub.dev" + source: hosted + version: "1.1.3" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + web_socket: + dependency: transitive + description: + name: web_socket + sha256: "34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d645757fb0f4773d602444000a8131ff5d48c9e47adfe9772652dd1a4f2d45c8 + url: "https://pub.dev" + source: hosted + version: "3.0.3" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.dev" + source: hosted + version: "3.1.3" +sdks: + dart: ">=3.8.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 00000000..3a854ee8 --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,12 @@ +name: freezed_workspace + +environment: + sdk: "^3.8.0" + +workspace: + - benchmarks/ + - packages/freezed + - packages/freezed/example + - packages/freezed_annotation + - packages/freezed_lint + - packages/freezed_lint/example diff --git a/pubspec_overrides.yaml b/pubspec_overrides.yaml new file mode 100644 index 00000000..bd703fea --- /dev/null +++ b/pubspec_overrides.yaml @@ -0,0 +1,46 @@ +dependency_overrides: + # pub downgrade: + # build_runner 2.2.0 => glob 2.0.0 => file 6.0.0 + # freezed requires file: ^6.1.3 + file: ^6.1.3 + # https://github.com/dart-lang/build/issues/3733#issuecomment-2272082820 + frontend_server_client: ^4.0.0 + # build_runner 2.3.3 => code_builder 4.2.0 => matcher 0.12.11 + # freezed requires matcher: ^0.12.15 + matcher: ^0.12.15 + # build_runner 2.3.3 => pub_semver 2.0.0 + # freezed requires pub_semver: ^2.1.3 + pub_semver: ^2.1.3 + # expect_error 1.0.4 => pubspec 2.0.1 => uri 1.0.0 => quiver 3.0.0 + # freezed requires quiver: ^3.2.0 + quiver: ^3.2.0 + # watcher 1.0.0 extends, implements, or mixins sealed class 'FileSystemEvent' + watcher: ^1.1.0 + args: ^2.5.0 + + custom_lint: + git: + url: https://github.com/lishaduck/dart_custom_lint.git + ref: analyzer-8 + path: packages/custom_lint + # path: ../dart_custom_lint/packages/custom_lint + custom_lint_builder: + git: + url: https://github.com/lishaduck/dart_custom_lint.git + ref: analyzer-8 + path: packages/custom_lint_builder + # path: ../dart_custom_lint/packages/custom_lint_builder + custom_lint_core: + git: + url: https://github.com/lishaduck/dart_custom_lint.git + ref: analyzer-8 + path: packages/custom_lint_core + # path: ../dart_custom_lint/packages/custom_lint_core + custom_lint_visitor: + git: + url: https://github.com/lishaduck/dart_custom_lint.git + ref: analyzer-8 + path: packages/custom_lint_visitor + # path: ../dart_custom_lint/packages/custom_lint_visitor + + test_api: ^0.7.7