feat(dart/transform): Use the render Compiler and the DirectiveParser

Update the `TemplateCompile` step to use the full render `Compiler`.

Provide `DirectiveMetadata` for `ViewDefinition` objects and use it to
run the `DirectiveParser` step of the render compile pipeline.
This commit is contained in:
Tim Blasi
2015-05-05 10:31:21 -07:00
committed by Misko Hevery
parent 401c9efad7
commit 44f829dbc6
24 changed files with 576 additions and 93 deletions
@@ -57,6 +57,8 @@ void allTests() {
outputs: {
'a|web/bar.ng_deps.dart':
'simple_annotation_files/expected/bar.ng_deps.dart',
'a|web/bar.ng_meta.json':
'simple_annotation_files/expected/bar.ng_meta.json',
'a|web/index.ng_deps.dart':
'simple_annotation_files/expected/index.ng_deps.dart'
}),
@@ -0,0 +1 @@
{"MyComponent":{"id":"MyComponent","selector":"[soup]","compileChildren":true,"hostListeners":{},"hostProperties":{},"properties":{},"readAttributes":[],"type":1,"version":1}}
@@ -58,6 +58,32 @@ void allTests() {
var output = await processTemplates(reader, new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
});
it('should parse `View` directives with a single dependency.', () async {
var inputPath = 'template_compiler/one_directive_files/hello.ng_deps.dart';
var expected = readFile(
'template_compiler/one_directive_files/expected/hello.ng_deps.dart');
var output = await processTemplates(reader, new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
});
it('should parse `View` directives with a single prefixed dependency.',
() async {
var inputPath = 'template_compiler/with_prefix_files/hello.ng_deps.dart';
var expected = readFile(
'template_compiler/with_prefix_files/expected/hello.ng_deps.dart');
var output = await processTemplates(reader, new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
inputPath = 'template_compiler/with_prefix_files/goodbye.ng_deps.dart';
expected = readFile(
'template_compiler/with_prefix_files/expected/goodbye.ng_deps.dart');
output = await processTemplates(reader, new AssetId('a', inputPath));
_formatThenExpectEquals(output, expected);
});
}
void _formatThenExpectEquals(String actual, String expected) {
@@ -0,0 +1,14 @@
{
"HelloCmp":
{
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"properties":{},
"readAttributes":[],
"type":1,
"version":1
}
}
@@ -0,0 +1,14 @@
{
"HelloCmp":
{
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"properties":{},
"readAttributes":[],
"type":1,
"version":1
}
}
@@ -0,0 +1,14 @@
{
"HelloCmp":
{
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"properties":{},
"readAttributes":[],
"type":1,
"version":1
}
}
@@ -0,0 +1,28 @@
library examples.hello_world.index_common_dart.ng_deps.dart;
import 'hello.dart';
import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement;
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(HelloCmp, {
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'),
const View(template: 'goodbye-app', directives: const [GoodbyeCmp])
]
})
..registerType(GoodbyeCmp, {
'factory': () => new GoodbyeCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'goodbye-app'),
const View(template: 'Goodbye')
]
});
}
@@ -0,0 +1,28 @@
library examples.hello_world.index_common_dart.ng_deps.dart;
import 'hello.dart';
import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement;
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(HelloCmp, {
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'),
const View(template: 'goodbye-app', directives: const [GoodbyeCmp])
]
})
..registerType(GoodbyeCmp, {
'factory': () => new GoodbyeCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'goodbye-app'),
const View(template: 'Goodbye')
]
});
}
@@ -0,0 +1,25 @@
{
"HelloCmp":
{
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"properties":{},
"readAttributes":[],
"type":1,
"version":1
},
"GoodbyeCmp":{
"id":"GoodbyeCmp",
"selector":"goodbye-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"properties":{},
"readAttributes":[],
"type":1,
"version":1
}
}
@@ -0,0 +1,14 @@
{
"HelloCmp":
{
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"properties":{},
"readAttributes":[],
"type":1,
"version":1
}
}
@@ -0,0 +1,14 @@
{
"HelloCmp":
{
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"properties":{},
"readAttributes":[],
"type":1,
"version":1
}
}
@@ -0,0 +1,22 @@
library examples.hello_world.index_common_dart.ng_deps.dart;
import 'goodbye.dart';
import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement;
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(GoodbyeCmp, {
'factory': () => new GoodbyeCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'goodbye-app'),
const View(template: 'Goodbye {{name}}')
]
})
..registerGetters({'name': (o) => o.name})
..registerSetters({'name': (o, v) => o.name = v});
}
@@ -0,0 +1,24 @@
library examples.hello_world.index_common_dart.ng_deps.dart;
import 'hello.dart';
import 'goodbye.dart' as prefix;
import 'goodbye.ng_deps.dart' as i0;
import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement;
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(HelloCmp, {
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'),
const View(
template: 'goodbye-app', directives: const [prefix.GoodbyeCmp])
]
});
i0.initReflector(reflector);
}
@@ -0,0 +1,20 @@
library examples.hello_world.index_common_dart.ng_deps.dart;
import 'goodbye.dart';
import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement;
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(GoodbyeCmp, {
'factory': () => new GoodbyeCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'goodbye-app'),
const View(template: 'Goodbye {{name}}')
]
});
}
@@ -0,0 +1,13 @@
{
"GoodbyeCmp":{
"id":"GoodbyeCmp",
"selector":"goodbye-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"properties":{},
"readAttributes":[],
"type":1,
"version":1
}
}
@@ -0,0 +1,24 @@
library examples.hello_world.index_common_dart.ng_deps.dart;
import 'hello.dart';
import 'goodbye.dart' as prefix;
import 'goodbye.ng_deps.dart' as i0;
import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement;
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(HelloCmp, {
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'),
const View(
template: 'goodbye-app', directives: const [prefix.GoodbyeCmp])
]
});
i0.initReflector(reflector);
}
@@ -0,0 +1,14 @@
{
"HelloCmp":
{
"id":"HelloCmp",
"selector":"hello-app",
"compileChildren":true,
"hostListeners":{},
"hostProperties":{},
"properties":{},
"readAttributes":[],
"type":1,
"version":1
}
}