Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1613)

Unified Diff: third_party/pkg/angular/lib/core_dom/directive_map.dart

Issue 256553002: Revert "Update all Angular libs (run update_all.sh)." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/lib/core_dom/directive_map.dart
diff --git a/third_party/pkg/angular/lib/core_dom/directive_map.dart b/third_party/pkg/angular/lib/core_dom/directive_map.dart
index 0e92c21b272f962f9603828281bf9d8b016e62e7..aff3f8c1e8687df6b3f85b411faec79308272692 100644
--- a/third_party/pkg/angular/lib/core_dom/directive_map.dart
+++ b/third_party/pkg/angular/lib/core_dom/directive_map.dart
@@ -1,16 +1,65 @@
-part of angular.core.dom_internal;
+part of angular.core.dom;
-@Injectable()
-class DirectiveMap extends AnnotationsMap<Directive> {
- DirectiveSelectorFactory _directiveSelectorFactory;
- DirectiveSelector _selector;
- DirectiveSelector get selector {
- if (_selector != null) return _selector;
- return _selector = _directiveSelectorFactory.selector(this);
+@NgInjectableService()
+class DirectiveMap extends AnnotationsMap<NgAnnotation> {
+ DirectiveSelector selector;
+
+ DirectiveMap(Injector injector, MetadataExtractor metadataExtractor,
+ FieldMetadataExtractor fieldMetadataExtractor)
+ : super(injector, metadataExtractor) {
+ Map<NgAnnotation, List<Type>> directives = {};
+ forEach((NgAnnotation annotation, Type type) {
+ var match;
+ var fieldMetadata = fieldMetadataExtractor(type);
+ if (fieldMetadata.isNotEmpty) {
+ var newMap = annotation.map == null ? {} : new Map.from(annotation.map);
+ fieldMetadata.forEach((String fieldName, AttrFieldAnnotation ann) {
+ var attrName = ann.attrName;
+ if (newMap.containsKey(attrName)) {
+ throw 'Mapping for attribute $attrName is already defined (while '
+ 'processing annottation for field $fieldName of $type)';
+ }
+ newMap[attrName] = '${ann.mappingSpec}$fieldName';
+ });
+ annotation = annotation.cloneWithNewMap(newMap);
+ }
+ directives.putIfAbsent(annotation, () => []).add(type);
+ });
+ map.clear();
+ map.addAll(directives);
+
+ selector = directiveSelectorFactory(this);
}
+}
- DirectiveMap(Injector injector,
- MetadataExtractor metadataExtractor,
- this._directiveSelectorFactory)
- : super(injector, metadataExtractor);
+@NgInjectableService()
+class FieldMetadataExtractor {
+ List<TypeMirror> _fieldAnnotations = [reflectType(NgAttr),
+ reflectType(NgOneWay), reflectType(NgOneWayOneTime),
+ reflectType(NgTwoWay), reflectType(NgCallback)];
+
+ Map<String, AttrFieldAnnotation> call(Type type) {
+ ClassMirror cm = reflectType(type);
+ Map<String, AttrFieldAnnotation> fields = <String, AttrFieldAnnotation>{};
+ cm.declarations.forEach((Symbol name, DeclarationMirror decl) {
+ if (decl is VariableMirror ||
+ (decl is MethodMirror && (decl.isGetter || decl.isSetter))) {
+ var fieldName = MirrorSystem.getName(name);
+ if (decl is MethodMirror && decl.isSetter) {
+ // Remove = from the end of the setter.
+ fieldName = fieldName.substring(0, fieldName.length - 1);
+ }
+ decl.metadata.forEach((InstanceMirror meta) {
+ if (_fieldAnnotations.contains(meta.type)) {
+ if (fields[fieldName] != null) {
+ throw 'Attribute annotation for $fieldName is defined more '
+ 'than once in $type';
+ }
+ fields[fieldName] = meta.reflectee as AttrFieldAnnotation;
+ }
+ });
+ }
+ });
+ return fields;
+ }
}
« no previous file with comments | « third_party/pkg/angular/lib/core_dom/directive.dart ('k') | third_party/pkg/angular/lib/core_dom/dom_util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698