Skip to content

Commit e5419fe

Browse files
committed
feat(transformers): updated transformers
1 parent 69b75b7 commit e5419fe

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

modules/angular2/src/transform/common/directive_metadata_reader.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class _DirectiveMetadataVisitor extends Object
6161
hostProperties: {},
6262
hostAttributes: {},
6363
readAttributes: [],
64+
exportAs: null,
6465
callOnDestroy: false,
6566
callOnChange: false,
6667
callOnCheck: false,
@@ -136,6 +137,9 @@ class _DirectiveMetadataVisitor extends Object
136137
case 'lifecycle':
137138
_populateLifecycle(node.expression);
138139
break;
140+
case 'exportAs':
141+
_populateExportAs(node.expression);
142+
break;
139143
}
140144
return null;
141145
}
@@ -225,6 +229,11 @@ class _DirectiveMetadataVisitor extends Object
225229
hostAttributeValue, meta.hostAttributes, 'Directive#hostAttributes');
226230
}
227231

232+
void _populateExportAs(Expression exportAsValue) {
233+
_checkMeta();
234+
meta.exportAs = _expressionToString(exportAsValue, 'Directive#exportAs');
235+
}
236+
228237
void _populateLifecycle(Expression lifecycleValue) {
229238
_checkMeta();
230239
if (lifecycleValue is! ListLiteral) {

modules/angular2/test/transform/directive_metadata_extractor/all_tests.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ void allTests() {
6767
expect(metadata.properties).toContain('key2: val2');
6868
});
6969

70+
it('should parse exportAs.', () async {
71+
var metadata = await readMetadata('directive_metadata_extractor/'
72+
'directive_metadata_files/directive_export_as.ng_deps.dart');
73+
expect(metadata.exportAs).toEqual('exportAsName');
74+
});
75+
7076
it('should parse host listeners.', () async {
7177
var metadata = await readMetadata('directive_metadata_extractor/'
7278
'directive_metadata_files/host_listeners.ng_deps.dart');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
library examples.hello_world.index_common_dart.ng_deps.dart;
2+
3+
import 'hello.dart';
4+
import 'package:angular2/angular2.dart'
5+
show bootstrap, Component, Directive, View, NgElement, onChange, onDestroy, onInit, onCheck, onAllChangesDone;
6+
7+
var _visited = false;
8+
void initReflector(reflector) {
9+
if (_visited) return;
10+
_visited = true;
11+
reflector
12+
..registerType(HelloCmp, {
13+
'factory': () => new HelloCmp(),
14+
'parameters': const [const []],
15+
'annotations': const [
16+
const Directive(exportAs: 'exportAsName')
17+
]
18+
});
19+
}

modules/angular2/test/transform/integration/simple_annotation_files/expected/bar.ng_meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"properties": [],
1111
"readAttributes": [],
1212
"type": 1,
13+
"exportAs": null,
1314
"callOnDestroy": false,
1415
"callOnCheck": false,
1516
"callOnInit": false,

0 commit comments

Comments
 (0)