24 lines
837 B
Dart
24 lines
837 B
Dart
import 'package:analyzer/dart/element/element.dart';
|
|
import 'angel_serialize.dart';
|
|
|
|
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 get queryClassName => modelClassName + 'Query';
|
|
String get whereClassName => queryClassName + 'Where';
|
|
|
|
String resolveFieldName(String name) =>
|
|
aliases.containsKey(name) ? aliases[name] : name;
|
|
}
|