Skip to content

Commit

Permalink
build: release 1.0.2
Browse files Browse the repository at this point in the history
fix: bug when annotated classes also use mixins
  • Loading branch information
BreX900 committed Feb 3, 2023
1 parent bb91d62 commit e1db905
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 52 deletions.
12 changes: 12 additions & 0 deletions class_to_string/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# IntelliJ related
.idea/
*.iml
*.ipr
*.iws

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/


# Files and directories created by pub.
.dart_tool/
.packages
Expand Down
14 changes: 0 additions & 14 deletions class_to_string/class_to_string.iml

This file was deleted.

12 changes: 10 additions & 2 deletions example/lib/inheritance_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract class Animal with _$Animal {
}

@DataClass(changeable: true, copyable: true)
class Dog extends Animal with _$Dog {
class Dog extends Animal with Action, _$Dog {
@override
final String getterField;

Expand All @@ -34,7 +34,7 @@ class Dog extends Animal with _$Dog {
}

@DataClass(changeable: true, copyable: true)
class Cat extends Animal with _$Cat {
class Cat extends Animal with Action, _$Cat {
@override
final String getterField;

Expand All @@ -49,3 +49,11 @@ class Cat extends Animal with _$Cat {
@override
String say() => 'Meow!';
}

mixin Action {
String get name;

String say();

String get action => '$name say ${say()}';
}
12 changes: 12 additions & 0 deletions mek_data_class/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# IntelliJ related
.idea/
*.iml
*.ipr
*.iws

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/


# Files and directories created by pub.
.dart_tool/
.packages
Expand Down
14 changes: 0 additions & 14 deletions mek_data_class/mek_data_class.iml

This file was deleted.

12 changes: 12 additions & 0 deletions mek_data_class_generator/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# IntelliJ related
.idea/
*.iml
*.ipr
*.iws

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/


# Files and directories created by pub.
.dart_tool/
.packages
Expand Down
3 changes: 3 additions & 0 deletions mek_data_class_generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.0.2
- fix: bug when annotated classes also use mixins

## 1.0.1
- fix: InconsistentAnalysisException

Expand Down
13 changes: 7 additions & 6 deletions mek_data_class_generator/lib/src/field_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class _FieldSet implements Comparable<_FieldSet> {
int compareTo(_FieldSet other) => _sortByLocation(sortField, other.sortField);

static int _sortByLocation(FieldElement a, FieldElement b) {
final checkerA = TypeChecker.fromStatic((a.enclosingElement3 as ClassElement).thisType);
final checkerA = TypeChecker.fromStatic((a.enclosingElement3 as InterfaceElement).thisType);

if (!checkerA.isExactly(b.enclosingElement3)) {
// in this case, you want to prioritize the enclosingElement that is more
Expand All @@ -41,7 +41,7 @@ class _FieldSet implements Comparable<_FieldSet> {
return -1;
}

final checkerB = TypeChecker.fromStatic((b.enclosingElement3 as ClassElement).thisType);
final checkerB = TypeChecker.fromStatic((b.enclosingElement3 as InterfaceElement).thisType);

if (checkerB.isAssignableFrom(a.enclosingElement3)) {
return 1;
Expand All @@ -61,13 +61,14 @@ class _FieldSet implements Comparable<_FieldSet> {
}
}

/// Returns a [Set] of all instance [FieldElement] items for [element] and
/// Returns a [List] of all instance [FieldElement] items for [element] and
/// super classes, sorted first by their location in the inheritance hierarchy
/// (super first) and then by their location in the source file.
Iterable<FieldElement> createSortedFieldSet(ClassElement element) {
List<FieldElement> createSortedFieldSet(ClassElement element) {
// Get all of the fields that need to be assigned
// TODO: support overriding the field set with an annotation option
final elementInstanceFields = Map.fromEntries(element.fields.map((e) => MapEntry(e.name, e)));
final elementInstanceFields =
Map.fromEntries(element.fields.where((e) => !e.isStatic).map((e) => MapEntry(e.name, e)));

final inheritedFields = <String, FieldElement>{};
final manager = InheritanceManager3();
Expand All @@ -94,7 +95,7 @@ Iterable<FieldElement> createSortedFieldSet(ClassElement element) {
.toList()
..sort();

return fields.map((fs) => fs.field);
return fields.map((fs) => fs.field).toList(growable: false);
}

const _dartCoreObjectChecker = TypeChecker.fromRuntime(Object);
14 changes: 0 additions & 14 deletions mek_data_class_generator/mek_data_class_generator.iml

This file was deleted.

4 changes: 2 additions & 2 deletions mek_data_class_generator/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: mek_data_class_generator
version: 1.0.1
version: 1.0.2
description: >
Code generator for data_class to generate `hashCode`, `==`, `toString`, `copyWith`
and `change` methods
Expand All @@ -16,7 +16,7 @@ scripts:
dependencies:
mek_data_class: ^1.0.0

analyzer: ">=4.0.0 <6.0.0"
analyzer: ">=4.6.0 <6.0.0"
build: ^2.0.0
source_gen: ^1.2.0
dart_style: ^2.2.0
Expand Down

0 comments on commit e1db905

Please sign in to comment.