From 3f5547316464bb26cccb43c9f03ea4c94819203b Mon Sep 17 00:00:00 2001 From: Tobe O Date: Fri, 24 Aug 2018 09:24:45 -0400 Subject: [PATCH] Ignore *.g.part --- angel_orm_generator/.gitignore | 1 + angel_orm_generator/build.yaml | 10 ++++++++++ .../lib/angel_orm_generator.dart | 3 +++ .../lib/src/orm_generator.dart | 20 +++++++++++++++++++ angel_orm_generator/test/models/order.dart | 2 +- 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 angel_orm_generator/build.yaml create mode 100644 angel_orm_generator/lib/src/orm_generator.dart diff --git a/angel_orm_generator/.gitignore b/angel_orm_generator/.gitignore index 99e7978e..79e7d7cf 100644 --- a/angel_orm_generator/.gitignore +++ b/angel_orm_generator/.gitignore @@ -54,3 +54,4 @@ com_crashlytics_export_strings.xml crashlytics.properties crashlytics-build.properties fabric.properties +*.g.part \ No newline at end of file diff --git a/angel_orm_generator/build.yaml b/angel_orm_generator/build.yaml new file mode 100644 index 00000000..469a5b3f --- /dev/null +++ b/angel_orm_generator/build.yaml @@ -0,0 +1,10 @@ +builders: + angel_orm: + import: "package:angel_orm_generator/angel_orm_generator.dart" + builder_factories: + - ormBuilder + auto_apply: root_package + build_to: source + build_extensions: + .dart: + - ".orm.g.dart" \ No newline at end of file diff --git a/angel_orm_generator/lib/angel_orm_generator.dart b/angel_orm_generator/lib/angel_orm_generator.dart index e69de29b..d4702aba 100644 --- a/angel_orm_generator/lib/angel_orm_generator.dart +++ b/angel_orm_generator/lib/angel_orm_generator.dart @@ -0,0 +1,3 @@ +export 'src/orm_build_context.dart'; +export 'src/orm_generator.dart'; +export 'src/readers.dart'; \ No newline at end of file diff --git a/angel_orm_generator/lib/src/orm_generator.dart b/angel_orm_generator/lib/src/orm_generator.dart new file mode 100644 index 00000000..4fc2461f --- /dev/null +++ b/angel_orm_generator/lib/src/orm_generator.dart @@ -0,0 +1,20 @@ +import 'package:analyzer/dart/element/element.dart'; +import 'package:angel_orm/angel_orm.dart'; +import 'package:build/build.dart'; +import 'package:source_gen/source_gen.dart'; + +Builder ormBuilder(_) { + return new LibraryBuilder(new OrmGenerator(), + generatedExtension: '.orm.g.dart'); +} + +class OrmGenerator extends GeneratorForAnnotation { + @override + generateForAnnotatedElement( + Element element, ConstantReader annotation, BuildStep buildStep) { + if (element is ClassElement) { + } else { + throw 'The @Orm() annotation can only be applied to classes.'; + } + } +} diff --git a/angel_orm_generator/test/models/order.dart b/angel_orm_generator/test/models/order.dart index 7f87f134..1125dd9f 100644 --- a/angel_orm_generator/test/models/order.dart +++ b/angel_orm_generator/test/models/order.dart @@ -9,7 +9,7 @@ part 'order.g.dart'; @orm @serializable class _Order extends Model { - @Join(Customer, 'id') + @CanJoin(Customer, 'id') int customerId; int employeeId; DateTime orderDate;