From ecfd99e8651179f3197e031b8c0fd357d0d0a4e3 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Fri, 24 Aug 2018 09:03:31 -0400 Subject: [PATCH] Add basic annotation reader --- .../lib/src/builder/orm/lib_core.dart | 5 ----- angel_orm_generator/lib/src/readers.dart | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) delete mode 100644 angel_orm_generator/lib/src/builder/orm/lib_core.dart create mode 100644 angel_orm_generator/lib/src/readers.dart diff --git a/angel_orm_generator/lib/src/builder/orm/lib_core.dart b/angel_orm_generator/lib/src/builder/orm/lib_core.dart deleted file mode 100644 index 254d3678..00000000 --- a/angel_orm_generator/lib/src/builder/orm/lib_core.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:code_builder/code_builder.dart'; - -final TypeReference $void = new TypeReference((b) => b.symbol = 'void'); - -final Expression override = new CodeExpression(new Code('override')); \ No newline at end of file diff --git a/angel_orm_generator/lib/src/readers.dart b/angel_orm_generator/lib/src/readers.dart new file mode 100644 index 00000000..bba74bd4 --- /dev/null +++ b/angel_orm_generator/lib/src/readers.dart @@ -0,0 +1,19 @@ +import 'package:analyzer/dart/constant/value.dart'; +import 'package:angel_orm/angel_orm.dart'; +import 'package:source_gen/source_gen.dart'; + +ORM reviveORMAnnotation(ConstantReader reader) { + return ORM(reader.peek('tableName')?.stringValue); +} + +class ColumnReader { + final ConstantReader reader; + + ColumnReader(this.reader); + + bool get isNullable => reader.peek('isNullable')?.boolValue ?? true; + + int get length => reader.peek('length')?.intValue; + + DartObject get defaultValue => reader.peek('defaultValue')?.objectValue; +}