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

Side by Side Diff: third_party/pkg/angular/lib/core/registry.dart

Issue 1058283006: Update pubspecs and dependencies to get pkgbuild tests working. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 part of angular.core;
2
3 abstract class AnnotationMap<K> {
4 final Map<K, Type> _map = {};
5
6 AnnotationMap(Injector injector, MetadataExtractor extractMetadata) {
7 injector.types.forEach((type) {
8 var meta = extractMetadata(type)
9 .where((annotation) => annotation is K)
10 .forEach((annotation) {
11 _map[annotation] = type;
12 });
13 });
14 }
15
16 Type operator[](K annotation) {
17 var value = _map[annotation];
18 if (value == null) throw 'No $annotation found!';
19 return value;
20 }
21
22 forEach(fn(K, Type)) => _map.forEach(fn);
23
24 List<K> annotationsFor(Type type) {
25 var res = <K>[];
26 forEach((ann, annType) {
27 if (annType == type) res.add(ann);
28 });
29 return res;
30 }
31 }
32
33 abstract class AnnotationsMap<K> {
34 final Map<K, List<Type>> map = {};
35
36 AnnotationsMap(Injector injector, MetadataExtractor extractMetadata) {
37 injector.types.forEach((type) {
38 var meta = extractMetadata(type)
39 .where((annotation) => annotation is K)
40 .forEach((annotation) {
41 map.putIfAbsent(annotation, () => []).add(type);
42 });
43 });
44 }
45
46 List operator[](K annotation) {
47 var value = map[annotation];
48 if (value == null) throw 'No $annotation found!';
49 return value;
50 }
51
52 forEach(fn(K, Type)) {
53 map.forEach((annotation, types) {
54 types.forEach((type) {
55 fn(annotation, type);
56 });
57 });
58 }
59
60 List<K> annotationsFor(Type type) {
61 var res = <K>[];
62 forEach((ann, annType) {
63 if (annType == type) res.add(ann);
64 });
65 return res;
66 }
67 }
68
69
70 @NgInjectableService()
71 class MetadataExtractor {
72 Iterable call(Type type) {
73 if (reflectType(type) is TypedefMirror) return [];
74 var metadata = reflectClass(type).metadata;
75 if (metadata == null) return [];
76 return metadata.map((InstanceMirror im) => im.reflectee);
77 }
78 }
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/core/parser/utils.dart ('k') | third_party/pkg/angular/lib/core/scope.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698