feat(transformers): updated transformers

This commit is contained in:
vsavkin 2015-06-04 13:45:23 -07:00
parent 69b75b7fd8
commit e5419febe4
4 changed files with 35 additions and 0 deletions

View File

@ -61,6 +61,7 @@ class _DirectiveMetadataVisitor extends Object
hostProperties: {},
hostAttributes: {},
readAttributes: [],
exportAs: null,
callOnDestroy: false,
callOnChange: false,
callOnCheck: false,
@ -136,6 +137,9 @@ class _DirectiveMetadataVisitor extends Object
case 'lifecycle':
_populateLifecycle(node.expression);
break;
case 'exportAs':
_populateExportAs(node.expression);
break;
}
return null;
}
@ -225,6 +229,11 @@ class _DirectiveMetadataVisitor extends Object
hostAttributeValue, meta.hostAttributes, 'Directive#hostAttributes');
}
void _populateExportAs(Expression exportAsValue) {
_checkMeta();
meta.exportAs = _expressionToString(exportAsValue, 'Directive#exportAs');
}
void _populateLifecycle(Expression lifecycleValue) {
_checkMeta();
if (lifecycleValue is! ListLiteral) {

View File

@ -67,6 +67,12 @@ void allTests() {
expect(metadata.properties).toContain('key2: val2');
});
it('should parse exportAs.', () async {
var metadata = await readMetadata('directive_metadata_extractor/'
'directive_metadata_files/directive_export_as.ng_deps.dart');
expect(metadata.exportAs).toEqual('exportAsName');
});
it('should parse host listeners.', () async {
var metadata = await readMetadata('directive_metadata_extractor/'
'directive_metadata_files/host_listeners.ng_deps.dart');

View File

@ -0,0 +1,19 @@
library examples.hello_world.index_common_dart.ng_deps.dart;
import 'hello.dart';
import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement, onChange, onDestroy, onInit, onCheck, onAllChangesDone;
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(HelloCmp, {
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Directive(exportAs: 'exportAsName')
]
});
}

View File

@ -10,6 +10,7 @@
"properties": [],
"readAttributes": [],
"type": 1,
"exportAs": null,
"callOnDestroy": false,
"callOnCheck": false,
"callOnInit": false,