@@ -38,58 +38,6 @@ class CompileDataResults {
3838 this .ngMeta, this .viewDefinitions, this .directiveMetadatas);
3939}
4040
41- class _PrefixedDirectiveName {
42- final String prefix;
43- final String directiveName;
44-
45- _PrefixedDirectiveName (String prefix, this .directiveName)
46- : this .prefix = prefix == null ? '' : prefix;
47-
48- @override
49- String toString () {
50- if (prefix.isEmpty) {
51- return directiveName;
52- } else {
53- return '${prefix }.${directiveName }' ;
54- }
55- }
56- }
57-
58- String _directivesValue (ReflectionInfoModel model, bool test (AnnotationModel )) {
59- final viewAnnotation = model.annotations.firstWhere (test, orElse: () => null );
60- if (viewAnnotation == null ) return null ;
61- final directivesParam = viewAnnotation.namedParameters
62- .firstWhere ((p) => p.name == 'directives' , orElse: () => null );
63- return directivesParam != null ? directivesParam.value : null ;
64- }
65-
66- // TODO(kegluneq): Parse this value when creating [NgDepsModel]?
67- /// Find the `directives` parameter on the @View annotation and make sure that
68- /// all necessary [CompileDirectiveMetadata] objects are available.
69- Iterable <_PrefixedDirectiveName > _getDirectiveDeps (ReflectionInfoModel model) {
70- var directives = _directivesValue (model, (m) => m.isView);
71- if (directives == null ) {
72- directives = _directivesValue (model, (m) => m.isComponent);
73- }
74- if (directives == null ) return const [];
75- directives = directives.trim ();
76- for (var toTrim in ['const [' , '[' ]) {
77- if (directives.startsWith (toTrim) && directives.endsWith (']' )) {
78- directives =
79- directives.substring (toTrim.length, directives.length - 1 ).trim ();
80- }
81- }
82- if (directives.length == 0 ) return const [];
83- return directives.split (',' ).map ((p) {
84- var parts = p.trim ().split ('.' );
85- if (parts.length == 1 ) {
86- return new _PrefixedDirectiveName (null , parts[0 ]);
87- } else {
88- return new _PrefixedDirectiveName (parts[0 ], parts[1 ]);
89- }
90- });
91- }
92-
9341/// Creates [ViewDefinition] objects for all `View` `Directive` s defined in
9442/// `entryPoint` .
9543class _CompileDataCreator {
@@ -127,7 +75,7 @@ class _CompileDataCreator {
12775 if (compileDirectiveMetadata.template != null ) {
12876 final compileDatum = new NormalizedComponentWithViewDirectives (
12977 compileDirectiveMetadata, < CompileDirectiveMetadata > []);
130- for (var dep in _getDirectiveDeps ( reflectable) ) {
78+ for (var dep in reflectable.directives ) {
13179 if (! ngMetaMap.containsKey (dep.prefix)) {
13280 logger.warning (
13381 'Missing prefix "${dep .prefix }" '
@@ -137,11 +85,10 @@ class _CompileDataCreator {
13785 }
13886 final depNgMeta = ngMetaMap[dep.prefix];
13987
140- if (depNgMeta.types.containsKey (dep.directiveName)) {
141- compileDatum.directives.add (depNgMeta.types[dep.directiveName]);
142- } else if (depNgMeta.aliases.containsKey (dep.directiveName)) {
143- compileDatum.directives
144- .addAll (depNgMeta.flatten (dep.directiveName));
88+ if (depNgMeta.types.containsKey (dep.name)) {
89+ compileDatum.directives.add (depNgMeta.types[dep.name]);
90+ } else if (depNgMeta.aliases.containsKey (dep.name)) {
91+ compileDatum.directives.addAll (depNgMeta.flatten (dep.name));
14592 } else {
14693 logger.warning ('Could not find Directive entry for $dep . '
14794 'Please be aware that Dart transformers have limited support for '
0 commit comments