platform/angel_serialize_generator/lib/context.dart

22 lines
746 B
Dart
Raw Normal View History

2017-06-20 22:13:04 +00:00
import 'package:analyzer/dart/element/element.dart';
2017-07-10 15:15:09 +00:00
import 'package:angel_serialize/angel_serialize.dart';
2017-06-20 22:13:04 +00:00
class BuildContext {
final Map<String, String> aliases = {};
final Map<String, bool> shimmed = {};
final String originalClassName, sourceFilename;
// Todo: We can use analyzer to copy straight from Model class
final List<FieldElement> fields = [];
final Serializable annotation;
String primaryKeyName = 'id';
BuildContext(this.annotation, {this.originalClassName, this.sourceFilename});
String get modelClassName => originalClassName.startsWith('_')
? originalClassName.substring(1)
: originalClassName;
String resolveFieldName(String name) =>
aliases.containsKey(name) ? aliases[name] : name;
}