chore(transformer): Use class for reflection info instead of a map

closes https://github.com/angular/angular/issues/906
This commit is contained in:
Jacob MacDonald 2015-07-23 15:18:30 -07:00
parent a8b75c3d41
commit 5b5de6662f
95 changed files with 550 additions and 890 deletions

View File

@ -1,7 +1,7 @@
import {Type, isPresent} from 'angular2/src/facade/lang'; import {Type, isPresent} from 'angular2/src/facade/lang';
import {List, ListWrapper} from 'angular2/src/facade/collection'; import {List, ListWrapper} from 'angular2/src/facade/collection';
import {Reflector} from './reflector'; import {Reflector} from './reflector';
export {Reflector} from './reflector'; export {Reflector, ReflectionInfo} from './reflector';
import {ReflectionCapabilities} from './reflection_capabilities'; import {ReflectionCapabilities} from './reflection_capabilities';
export var reflector = new Reflector(new ReflectionCapabilities()); export var reflector = new Reflector(new ReflectionCapabilities());

View File

@ -12,8 +12,23 @@ import {PlatformReflectionCapabilities} from './platform_reflection_capabilities
export {SetterFn, GetterFn, MethodFn} from './types'; export {SetterFn, GetterFn, MethodFn} from './types';
export {PlatformReflectionCapabilities} from './platform_reflection_capabilities'; export {PlatformReflectionCapabilities} from './platform_reflection_capabilities';
export class ReflectionInfo {
_factory: Function;
_annotations: List<any>;
_parameters: List<List<any>>;
_interfaces: List<any>;
constructor(annotations?: List<any>, parameters?: List<List<any>>, factory?: Function,
interfaces?: List<any>) {
this._annotations = annotations;
this._parameters = parameters;
this._factory = factory;
this._interfaces = interfaces;
}
}
export class Reflector { export class Reflector {
_injectableInfo: Map<any, StringMap<string, any>>; _injectableInfo: Map<any, ReflectionInfo>;
_getters: Map<string, GetterFn>; _getters: Map<string, GetterFn>;
_setters: Map<string, SetterFn>; _setters: Map<string, SetterFn>;
_methods: Map<string, MethodFn>; _methods: Map<string, MethodFn>;
@ -29,11 +44,11 @@ export class Reflector {
isReflectionEnabled(): boolean { return this.reflectionCapabilities.isReflectionEnabled(); } isReflectionEnabled(): boolean { return this.reflectionCapabilities.isReflectionEnabled(); }
registerFunction(func: Function, funcInfo: StringMap<string, any>): void { registerFunction(func: Function, funcInfo: ReflectionInfo): void {
this._injectableInfo.set(func, funcInfo); this._injectableInfo.set(func, funcInfo);
} }
registerType(type: Type, typeInfo: StringMap<string, any>): void { registerType(type: Type, typeInfo: ReflectionInfo): void {
this._injectableInfo.set(type, typeInfo); this._injectableInfo.set(type, typeInfo);
} }
@ -50,8 +65,9 @@ export class Reflector {
} }
factory(type: Type): Function { factory(type: Type): Function {
if (this._containsTypeInfo(type)) { if (this._containsReflectionInfo(type)) {
return this._getTypeInfoField(type, "factory", null); var res = this._injectableInfo.get(type)._factory;
return isPresent(res) ? res : null;
} else { } else {
return this.reflectionCapabilities.factory(type); return this.reflectionCapabilities.factory(type);
} }
@ -59,7 +75,8 @@ export class Reflector {
parameters(typeOrFunc: /*Type*/ any): List<any> { parameters(typeOrFunc: /*Type*/ any): List<any> {
if (this._injectableInfo.has(typeOrFunc)) { if (this._injectableInfo.has(typeOrFunc)) {
return this._getTypeInfoField(typeOrFunc, "parameters", []); var res = this._injectableInfo.get(typeOrFunc)._parameters;
return isPresent(res) ? res : [];
} else { } else {
return this.reflectionCapabilities.parameters(typeOrFunc); return this.reflectionCapabilities.parameters(typeOrFunc);
} }
@ -67,7 +84,8 @@ export class Reflector {
annotations(typeOrFunc: /*Type*/ any): List<any> { annotations(typeOrFunc: /*Type*/ any): List<any> {
if (this._injectableInfo.has(typeOrFunc)) { if (this._injectableInfo.has(typeOrFunc)) {
return this._getTypeInfoField(typeOrFunc, "annotations", []); var res = this._injectableInfo.get(typeOrFunc)._annotations;
return isPresent(res) ? res : [];
} else { } else {
return this.reflectionCapabilities.annotations(typeOrFunc); return this.reflectionCapabilities.annotations(typeOrFunc);
} }
@ -75,7 +93,8 @@ export class Reflector {
interfaces(type: Type): List<any> { interfaces(type: Type): List<any> {
if (this._injectableInfo.has(type)) { if (this._injectableInfo.has(type)) {
return this._getTypeInfoField(type, "interfaces", []); var res = this._injectableInfo.get(type)._interfaces;
return isPresent(res) ? res : [];
} else { } else {
return this.reflectionCapabilities.interfaces(type); return this.reflectionCapabilities.interfaces(type);
} }
@ -105,12 +124,7 @@ export class Reflector {
} }
} }
_getTypeInfoField(typeOrFunc, key, defaultValue) { _containsReflectionInfo(typeOrFunc) { return this._injectableInfo.has(typeOrFunc); }
var res = this._injectableInfo.get(typeOrFunc)[key];
return isPresent(res) ? res : defaultValue;
}
_containsTypeInfo(typeOrFunc) { return this._injectableInfo.has(typeOrFunc); }
} }
function _mergeMaps(target: Map<any, any>, config: StringMap<string, Function>): void { function _mergeMaps(target: Map<any, any>, config: StringMap<string, Function>): void {

View File

@ -15,12 +15,17 @@ dynamic initZoned(Transform t, _SimpleCallback fn, {String errorMessage: ''}) =>
setZoned(new BuildLogger(t), fn, errorMessage: errorMessage); setZoned(new BuildLogger(t), fn, errorMessage: errorMessage);
dynamic setZoned(BuildLogger logger, _SimpleCallback fn, dynamic setZoned(BuildLogger logger, _SimpleCallback fn,
{String errorMessage: ''}) => runZoned(fn, {String errorMessage}) {
zoneValues: {_key: logger}, onError: (e, stackTrace) { var onError;
if (errorMessage != null) {
onError = (e, stackTrace) {
logger.error('$errorMessage\n' logger.error('$errorMessage\n'
'Exception: $e\n' 'Exception: $e\n'
'Stack Trace: $stackTrace'); 'Stack Trace: $stackTrace');
}); };
}
return runZoned(fn, zoneValues: {_key: logger}, onError: onError);
}
/// The logger for the current {@link Zone}. /// The logger for the current {@link Zone}.
BuildLogger get logger { BuildLogger get logger {

View File

@ -63,26 +63,22 @@ class _ParseRegisterTypeVisitor extends Object
typeName = node.argumentList.arguments[0] is Identifier typeName = node.argumentList.arguments[0] is Identifier
? node.argumentList.arguments[0] ? node.argumentList.arguments[0]
: null; : null;
return super.visitMethodInvocation(node);
// The second argument to a `registerType` call is the RegistrationInfo
// object creation.
var info = node.argumentList.arguments[1] as InstanceCreationExpression;
var args = info.argumentList.arguments;
for (int i = 0; i < args.length; i++) {
var arg = args[i];
if (i == 0) {
annotations = arg;
} else if (i == 1) {
parameters = arg;
} else if (i == 2) {
factoryFn = arg;
}
} }
@override
Object visitMapLiteralEntry(MapLiteralEntry node) {
if (node.key is StringLiteral) {
var key = stringLiteralToString(node.key);
switch (key) {
case 'annotations':
annotations = node.value;
break;
case 'factory':
factoryFn = node.value;
break;
case 'parameters':
parameters = node.value;
break;
}
}
// Do not need to descend any further.
return null; return null;
} }
} }

View File

@ -30,14 +30,9 @@ Future<String> createNgDeps(AssetReader reader, AssetId assetId,
// TODO(kegluneq): Shortcut if we can determine that there are no // TODO(kegluneq): Shortcut if we can determine that there are no
// [Directive]s present, taking into account `export`s. // [Directive]s present, taking into account `export`s.
var writer = new AsyncStringWriter(); var writer = new AsyncStringWriter();
var visitor = new CreateNgDepsVisitor( var visitor = new CreateNgDepsVisitor(writer, assetId,
writer, new XhrImpl(reader, assetId), annotationMatcher, _interfaceMatcher,
assetId, ngMeta, inlineViews: inlineViews);
new XhrImpl(reader, assetId),
annotationMatcher,
_interfaceMatcher,
ngMeta,
inlineViews: inlineViews);
var code = await reader.readAsString(assetId); var code = await reader.readAsString(assetId);
parseCompilationUnit(code, name: assetId.path).accept(visitor); parseCompilationUnit(code, name: assetId.path).accept(visitor);
@ -81,14 +76,9 @@ class CreateNgDepsVisitor extends Object with SimpleAstVisitor<Object> {
/// The assetId for the file which we are parsing. /// The assetId for the file which we are parsing.
final AssetId assetId; final AssetId assetId;
CreateNgDepsVisitor( CreateNgDepsVisitor(AsyncStringWriter writer, AssetId assetId, XHR xhr,
AsyncStringWriter writer, AnnotationMatcher annotationMatcher, InterfaceMatcher interfaceMatcher,
AssetId assetId, this.ngMeta, {bool inlineViews})
XHR xhr,
AnnotationMatcher annotationMatcher,
InterfaceMatcher interfaceMatcher,
this.ngMeta,
{bool inlineViews})
: writer = writer, : writer = writer,
_copyVisitor = new ToSourceVisitor(writer), _copyVisitor = new ToSourceVisitor(writer),
_factoryVisitor = new FactoryTransformVisitor(writer), _factoryVisitor = new FactoryTransformVisitor(writer),
@ -215,31 +205,31 @@ class CreateNgDepsVisitor extends Object with SimpleAstVisitor<Object> {
_maybeWriteReflector(); _maybeWriteReflector();
writer.print('..registerType('); writer.print('..registerType(');
node.name.accept(this); node.name.accept(this);
writer.print(''', {'factory': '''); writer.print(', new ${_REF_PREFIX}.ReflectionInfo(');
if (ctor == null) { node.accept(_metaVisitor);
_generateEmptyFactory(node.name.toString()); writer.print(', ');
} else {
ctor.accept(_factoryVisitor);
}
writer.print(''', 'parameters': ''');
if (ctor == null) { if (ctor == null) {
_generateEmptyParams(); _generateEmptyParams();
} else { } else {
ctor.accept(_paramsVisitor); ctor.accept(_paramsVisitor);
} }
writer.print(''', 'annotations': '''); writer.print(', ');
node.accept(_metaVisitor); if (ctor == null) {
_generateEmptyFactory(node.name.toString());
} else {
ctor.accept(_factoryVisitor);
}
if (node.implementsClause != null && if (node.implementsClause != null &&
node.implementsClause.interfaces != null && node.implementsClause.interfaces != null &&
node.implementsClause.interfaces.isNotEmpty) { node.implementsClause.interfaces.isNotEmpty) {
writer writer
..print(''', 'interfaces': const [''') ..print(', const [')
..print(node.implementsClause.interfaces ..print(node.implementsClause.interfaces
.map((interface) => interface.name) .map((interface) => interface.name)
.join(', ')) .join(', '))
..print(']'); ..print(']');
} }
writer.print('})'); writer.print('))');
return null; return null;
} }
@ -307,11 +297,11 @@ class CreateNgDepsVisitor extends Object with SimpleAstVisitor<Object> {
_maybeWriteReflector(); _maybeWriteReflector();
writer.print('..registerFunction('); writer.print('..registerFunction(');
node.name.accept(this); node.name.accept(this);
writer.print(''', {'parameters': const ['''); writer.print(', new ${_REF_PREFIX}.ReflectionInfo(');
node.functionExpression.parameters.accept(_paramsVisitor);
writer.print('''], 'annotations': ''');
node.metadata.accept(_metaVisitor); node.metadata.accept(_metaVisitor);
writer.print('})'); writer.print(', const [');
node.functionExpression.parameters.accept(_paramsVisitor);
writer.print(']))');
return null; return null;
} }

View File

@ -31,12 +31,12 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(ToolTip, { ..registerType(ToolTip, new ReflectionInfo(
'factory': () => new ToolTip(), const [
'parameters': const [],
'annotations': const [
const Decorator( const Decorator(
selector: '[tool-tip]', bind: const {'text': 'tool-tip'}) selector: '[tool-tip]', bind: const {'text': 'tool-tip'})
] ],
}); const [],
() => new ToolTip()
));
}'''; }''';

View File

@ -46,11 +46,11 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(DependencyComponent, { ..registerType(DependencyComponent, new ReflectionInfo(
'factory': () => new DependencyComponent(), const [const Component(selector: '[salad]')],
'parameters': const [], const [],
'annotations': const [const Component(selector: '[salad]')] () => new DependencyComponent()
}); ));
} }
'''; ''';
@ -66,12 +66,12 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(MyComponent, { ..registerType(MyComponent, new ReflectionInfo(
'factory': () => new MyComponent(), const [
'parameters': const [],
'annotations': const [
const Component( const Component(
selector: '[soup]', services: const [dep.DependencyComponent]) selector: '[soup]', services: const [dep.DependencyComponent])
] ],
}); const [],
() => new MyComponent()
));
}'''; }''';

View File

@ -32,14 +32,14 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(
'factory': () => new HelloCmp(), const [
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const Template( const Template(
inline: '<button (click)="action()">go</button>{{greeting}}') inline: '<button (click)="action()">go</button>{{greeting}}')
] ],
}); const [const []],
() => new HelloCmp()
));
} }
'''; ''';

View File

@ -35,14 +35,14 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(
'factory': () => new HelloCmp(), const [
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const Template(url: 'template.html') const Template(url: 'template.html')
] ],
}); const [const []],
() => new HelloCmp()
));
} }
'''; ''';

View File

@ -1,5 +1,5 @@
import {describe, it, iit, ddescribe, expect, beforeEach, IS_DARTIUM} from 'angular2/test_lib'; import {describe, it, iit, ddescribe, expect, beforeEach, IS_DARTIUM} from 'angular2/test_lib';
import {Reflector} from 'angular2/src/reflection/reflection'; import {Reflector, ReflectionInfo} from 'angular2/src/reflection/reflection';
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';
import {ClassDecorator, ParamDecorator, classDecorator, paramDecorator} from './reflector_common'; import {ClassDecorator, ParamDecorator, classDecorator, paramDecorator} from './reflector_common';
import {List} from 'angular2/src/facade/collection'; import {List} from 'angular2/src/facade/collection';
@ -88,7 +88,7 @@ export function main() {
() => { expect(() => reflector.factory(TestObjWith21Args)).toThrowError(); }); () => { expect(() => reflector.factory(TestObjWith21Args)).toThrowError(); });
it("should return a registered factory if available", () => { it("should return a registered factory if available", () => {
reflector.registerType(TestObj, {"factory": () => "fake"}); reflector.registerType(TestObj, new ReflectionInfo(null, null, () => "fake"));
expect(reflector.factory(TestObj)()).toEqual("fake"); expect(reflector.factory(TestObj)()).toEqual("fake");
}); });
}); });
@ -105,12 +105,12 @@ export function main() {
}); });
it("should return registered parameters if available", () => { it("should return registered parameters if available", () => {
reflector.registerType(TestObj, {"parameters": [1, 2]}); reflector.registerType(TestObj, new ReflectionInfo(null, [[1], [2]]));
expect(reflector.parameters(TestObj)).toEqual([1, 2]); expect(reflector.parameters(TestObj)).toEqual([[1], [2]]);
}); });
it("should return an empty list when no paramters field in the stored type info", () => { it("should return an empty list when no paramters field in the stored type info", () => {
reflector.registerType(TestObj, {}); reflector.registerType(TestObj, new ReflectionInfo());
expect(reflector.parameters(TestObj)).toEqual([]); expect(reflector.parameters(TestObj)).toEqual([]);
}); });
}); });
@ -122,7 +122,7 @@ export function main() {
}); });
it("should return registered annotations if available", () => { it("should return registered annotations if available", () => {
reflector.registerType(TestObj, {"annotations": [1, 2]}); reflector.registerType(TestObj, new ReflectionInfo([1, 2]));
expect(reflector.annotations(TestObj)).toEqual([1, 2]); expect(reflector.annotations(TestObj)).toEqual([1, 2]);
}); });

View File

@ -8,12 +8,8 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(ToolTip, { ..registerType(ToolTip, new ReflectionInfo(const [
'factory': () => new ToolTip(),
'parameters': const [],
'annotations': const [
const Directive( const Directive(
selector: '[tool-tip]', properties: const ['text: tool-tip']) selector: '[tool-tip]', properties: const ['text: tool-tip'])
] ], const [], () => new ToolTip()));
});
} }

View File

@ -8,13 +8,9 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(ToolTip, { ..registerType(ToolTip, new ReflectionInfo(const [
'factory': () => new ToolTip(),
'parameters': const [],
'annotations': const [
const Directive( const Directive(
selector: '[tool-tip]', properties: const ['text: tool-tip']) selector: '[tool-tip]', properties: const ['text: tool-tip'])
] ], const [], () => new ToolTip()))
})
..registerSetters({'text': (o, v) => o.text = v}); ..registerSetters({'text': (o, v) => o.text = v});
} }

View File

@ -8,19 +8,12 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(SoupComponent, { ..registerType(SoupComponent, new ReflectionInfo(const [
'factory': () => new SoupComponent(),
'parameters': const [],
'annotations': const [
const Component( const Component(
componentServices: const [SaladComponent], componentServices: const [SaladComponent], properties: const ['menu'])
properties: const ['menu']) ], const [], () => new SoupComponent()))
] ..registerType(SaladComponent, new ReflectionInfo(
}) const [const Component(properties: const ['menu'])], const [],
..registerType(SaladComponent, { () => new SaladComponent()))
'factory': () => new SaladComponent(),
'parameters': const [],
'annotations': const [const Component(properties: const ['menu'])]
})
..registerSetters({'menu': (o, v) => o.menu = v}); ..registerSetters({'menu': (o, v) => o.menu = v});
} }

View File

@ -8,18 +8,11 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(SoupComponent, { ..registerType(SoupComponent, new ReflectionInfo(const [
'factory': () => new SoupComponent(),
'parameters': const [],
'annotations': const [
const Component( const Component(
componentServices: const [SaladComponent], componentServices: const [SaladComponent], properties: const ['menu'])
properties: const ['menu']) ], const [], () => new SoupComponent()))
] ..registerType(SaladComponent, new ReflectionInfo(
}) const [const Component(properties: const ['menu'])], const [],
..registerType(SaladComponent, { () => new SaladComponent()));
'factory': () => new SaladComponent(),
'parameters': const [],
'annotations': const [const Component(properties: const ['menu'])]
});
} }

View File

@ -8,12 +8,8 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(ToolTip, { ..registerType(ToolTip, new ReflectionInfo(const [
'factory': () => new ToolTip(),
'parameters': const [],
'annotations': const [
const Directive( const Directive(
selector: '[tool-tip]', events: const ['onOpen', 'close: onClose']) selector: '[tool-tip]', events: const ['onOpen', 'close: onClose'])
] ], const [], () => new ToolTip()));
});
} }

View File

@ -8,13 +8,9 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(ToolTip, { ..registerType(ToolTip, new ReflectionInfo(const [
'factory': () => new ToolTip(),
'parameters': const [],
'annotations': const [
const Directive( const Directive(
selector: '[tool-tip]', events: const ['onOpen', 'close: onClose']) selector: '[tool-tip]', events: const ['onOpen', 'close: onClose'])
] ], const [], () => new ToolTip()))
})
..registerGetters({'onOpen': (o) => o.onOpen, 'close': (o) => o.close}); ..registerGetters({'onOpen': (o) => o.onOpen, 'close': (o) => o.close});
} }

View File

@ -11,14 +11,10 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new _ngRef.ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View( const View(
template: r'''{{greeting}}''', template: r'''{{greeting}}''',
templateUrl: r'package:other_package/template.html') templateUrl: r'package:other_package/template.html')
] ], const [], () => new HelloCmp()));
});
} }

View File

@ -11,14 +11,10 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new _ngRef.RegistrationInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View( const View(
template: r'''{{greeting}}''', template: r'''{{greeting}}''',
templateUrl: r'package:other_package/template.html') templateUrl: r'package:other_package/template.html')
] ], const [], () => new HelloCmp()));
});
} }

View File

@ -9,6 +9,8 @@ import '../common/read_file.dart';
var formatter = new DartFormatter(); var formatter = new DartFormatter();
main() => allTests();
void allTests() { void allTests() {
var reader = new TestAssetReader(); var reader = new TestAssetReader();

View File

@ -11,9 +11,7 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(MyComponent, { ..registerType(MyComponent, new _ngRef.ReflectionInfo(
'factory': () => new MyComponent(), const [const Component(selector: '[soup]')], const [],
'parameters': const [], () => new MyComponent()));
'annotations': const [const Component(selector: '[soup]')]
});
} }

View File

@ -12,10 +12,8 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(MyComponent, { ..registerType(MyComponent, new _ngRef.ReflectionInfo(
'factory': () => new MyComponent(), const [const Component(selector: '[soup]')], const [],
'parameters': const [], () => new MyComponent()));
'annotations': const [const Component(selector: '[soup]')]
});
i0.initReflector(); i0.initReflector();
} }

View File

@ -10,9 +10,7 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(DependencyComponent, { ..registerType(DependencyComponent, new _ngRef.ReflectionInfo(
'factory': () => new DependencyComponent(), const [const Component(selector: '[salad]')], const [],
'parameters': const [], () => new DependencyComponent()));
'annotations': const [const Component(selector: '[salad]')]
});
} }

View File

@ -10,9 +10,7 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(DependencyComponent, { ..registerType(DependencyComponent, new _ngRef.ReflectionInfo(
'factory': () => new DependencyComponent(), const [const Component(selector: '[salad]')], const [],
'parameters': const [], () => new DependencyComponent()));
'annotations': const [const Component(selector: '[salad]')]
});
} }

View File

@ -11,12 +11,8 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(MyComponent, { ..registerType(MyComponent, new ReflectionInfo(const [
'factory': () => new MyComponent(),
'parameters': const [],
'annotations': const [
const Component( const Component(
selector: '[soup]', viewInjector: const [dep.DependencyComponent]) selector: '[soup]', viewInjector: const [dep.DependencyComponent])
] ], const [], () => new MyComponent()));
});
} }

View File

@ -12,13 +12,9 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(MyComponent, { ..registerType(MyComponent, new ReflectionInfo(const [
'factory': () => new MyComponent(),
'parameters': const [],
'annotations': const [
const Component( const Component(
selector: '[soup]', viewInjector: const [dep.DependencyComponent]) selector: '[soup]', viewInjector: const [dep.DependencyComponent])
] ], const [], () => new MyComponent()));
});
i0.initReflector(); i0.initReflector();
} }

View File

@ -10,9 +10,7 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(DependencyComponent, { ..registerType(DependencyComponent, new _ngRef.ReflectionInfo(
'factory': () => new DependencyComponent(), const [const Component(selector: '[salad]')], const [],
'parameters': const [], () => new DependencyComponent()));
'annotations': const [const Component(selector: '[salad]')]
});
} }

View File

@ -10,9 +10,7 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(DependencyComponent, { ..registerType(DependencyComponent, new _ngRef.ReflectionInfo(
'factory': () => new DependencyComponent(), const [const Component(selector: '[salad]')], const [],
'parameters': const [], () => new DependencyComponent()));
'annotations': const [const Component(selector: '[salad]')]
});
} }

View File

@ -8,9 +8,7 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(BarComponent, { ..registerType(BarComponent, new ReflectionInfo(
'factory': () => new BarComponent(), const [const Component(selector: '[bar]')], const [],
'parameters': const [], () => new BarComponent()));
'annotations': const [const Component(selector: '[bar]')]
});
} }

View File

@ -11,10 +11,8 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(FooComponent, { ..registerType(FooComponent, new ReflectionInfo(
'factory': () => new FooComponent(), const [const Component(selector: '[foo]')], const [],
'parameters': const [], () => new FooComponent()));
'annotations': const [const Component(selector: '[foo]')]
});
i0.initReflector(reflector); i0.initReflector(reflector);
} }

View File

@ -8,9 +8,7 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(FooComponent, { ..registerType(FooComponent, new ReflectionInfo(
'factory': () => new FooComponent(), const [const Component(selector: '[fo' 'o]')], const [],
'parameters': const [], () => new FooComponent()));
'annotations': const [const Component(selector: '[fo' 'o]')]
});
} }

View File

@ -16,6 +16,8 @@ import '../common/read_file.dart';
var formatter = new DartFormatter(); var formatter = new DartFormatter();
main() => allTests();
void allTests() { void allTests() {
TestAssetReader reader = null; TestAssetReader reader = null;
@ -37,10 +39,7 @@ void allTests() {
}); });
it('should parse compile children values', () async { it('should parse compile children values', () async {
var ngDeps = await NgDeps.parse( var ngDeps = await NgDeps.parse(reader, new AssetId('a',
reader,
new AssetId(
'a',
'directive_metadata_extractor/' 'directive_metadata_extractor/'
'directive_metadata_files/compile_children.ng_deps.dart')); 'directive_metadata_files/compile_children.ng_deps.dart'));
var it = ngDeps.registeredTypes.iterator; var it = ngDeps.registeredTypes.iterator;
@ -125,38 +124,28 @@ void allTests() {
it('should fail when a class is annotated with multiple Directives.', it('should fail when a class is annotated with multiple Directives.',
() async { () async {
var ngDeps = await NgDeps.parse( var ngDeps = await NgDeps.parse(reader, new AssetId('a',
reader,
new AssetId(
'a',
'directive_metadata_extractor/' 'directive_metadata_extractor/'
'directive_metadata_files/too_many_directives.ng_deps.dart')); 'directive_metadata_files/too_many_directives.ng_deps.dart'));
expect(() => ngDeps.registeredTypes.first.directiveMetadata) expect(() => ngDeps.registeredTypes.first.directiveMetadata).toThrowWith(
.toThrowWith(anInstanceOf: PrintLoggerError); anInstanceOf: PrintLoggerError);
}); });
}); });
describe('extractMetadata', () { describe('extractMetadata', () {
it('should generate `DirectiveMetadata` from .ng_deps.dart files.', it('should generate `DirectiveMetadata` from .ng_deps.dart files.',
() async { () async {
var extracted = await extractDirectiveMetadata( var extracted = await extractDirectiveMetadata(reader, new AssetId(
reader, 'a', 'directive_metadata_extractor/simple_files/foo.ng_deps.dart'));
new AssetId('a',
'directive_metadata_extractor/simple_files/foo.ng_deps.dart'));
expect(extracted.types).toContain('FooComponent'); expect(extracted.types).toContain('FooComponent');
var extractedMeta = extracted.types['FooComponent']; var extractedMeta = extracted.types['FooComponent'];
expect(extractedMeta.selector).toEqual('[foo]'); expect(extractedMeta.selector).toEqual('[foo]');
}); });
it( it('should generate `DirectiveMetadata` from .ng_deps.dart files that use '
'should generate `DirectiveMetadata` from .ng_deps.dart files that use ' 'automatic adjacent string concatenation.', () async {
'automatic adjacent string concatenation.', var extracted = await extractDirectiveMetadata(reader, new AssetId('a',
() async {
var extracted = await extractDirectiveMetadata(
reader,
new AssetId(
'a',
'directive_metadata_extractor/adjacent_strings_files/' 'directive_metadata_extractor/adjacent_strings_files/'
'foo.ng_deps.dart')); 'foo.ng_deps.dart'));
expect(extracted.types).toContain('FooComponent'); expect(extracted.types).toContain('FooComponent');
@ -166,10 +155,8 @@ void allTests() {
}); });
it('should include `DirectiveMetadata` from exported files.', () async { it('should include `DirectiveMetadata` from exported files.', () async {
var extracted = await extractDirectiveMetadata( var extracted = await extractDirectiveMetadata(reader, new AssetId(
reader, 'a', 'directive_metadata_extractor/export_files/foo.ng_deps.dart'));
new AssetId('a',
'directive_metadata_extractor/export_files/foo.ng_deps.dart'));
expect(extracted.types).toContain('FooComponent'); expect(extracted.types).toContain('FooComponent');
expect(extracted.types).toContain('BarComponent'); expect(extracted.types).toContain('BarComponent');
@ -179,9 +166,7 @@ void allTests() {
it('should include `DirectiveMetadata` recursively from exported files.', it('should include `DirectiveMetadata` recursively from exported files.',
() async { () async {
var extracted = await extractDirectiveMetadata( var extracted = await extractDirectiveMetadata(reader, new AssetId('a',
reader,
new AssetId('a',
'directive_metadata_extractor/recursive_export_files/foo.ng_deps.dart')); 'directive_metadata_extractor/recursive_export_files/foo.ng_deps.dart'));
expect(extracted.types).toContain('FooComponent'); expect(extracted.types).toContain('FooComponent');
expect(extracted.types).toContain('BarComponent'); expect(extracted.types).toContain('BarComponent');
@ -192,18 +177,12 @@ void allTests() {
expect(extracted.types['BazComponent'].selector).toEqual('[baz]'); expect(extracted.types['BazComponent'].selector).toEqual('[baz]');
}); });
it( it('should include `DirectiveMetadata` from exported files '
'should include `DirectiveMetadata` from exported files ' 'expressed as absolute uris', () async {
'expressed as absolute uris', reader.addAsset(new AssetId('bar', 'lib/bar.ng_deps.dart'), readFile(
() async {
reader.addAsset(
new AssetId('bar', 'lib/bar.ng_deps.dart'),
readFile(
'directive_metadata_extractor/absolute_export_files/bar.ng_deps.dart')); 'directive_metadata_extractor/absolute_export_files/bar.ng_deps.dart'));
var extracted = await extractDirectiveMetadata( var extracted = await extractDirectiveMetadata(reader, new AssetId('a',
reader,
new AssetId('a',
'directive_metadata_extractor/absolute_export_files/foo.ng_deps.dart')); 'directive_metadata_extractor/absolute_export_files/foo.ng_deps.dart'));
expect(extracted.types).toContain('FooComponent'); expect(extracted.types).toContain('FooComponent');
expect(extracted.types).toContain('BarComponent'); expect(extracted.types).toContain('BarComponent');
@ -213,14 +192,10 @@ void allTests() {
}); });
it('should include directive aliases', () async { it('should include directive aliases', () async {
reader.addAsset( reader.addAsset(new AssetId('bar', 'lib/bar.ng_deps.dart'), readFile(
new AssetId('bar', 'lib/bar.ng_deps.dart'),
readFile(
'directive_metadata_extractor/directive_aliases_files/bar.ng_deps.dart')); 'directive_metadata_extractor/directive_aliases_files/bar.ng_deps.dart'));
var extracted = await extractDirectiveMetadata( var extracted = await extractDirectiveMetadata(reader, new AssetId('a',
reader,
new AssetId('a',
'directive_metadata_extractor/directive_aliases_files/foo.ng_deps.dart')); 'directive_metadata_extractor/directive_aliases_files/foo.ng_deps.dart'));
expect(extracted.aliases).toContain('alias1'); expect(extracted.aliases).toContain('alias1');
expect(extracted.aliases).toContain('alias2'); expect(extracted.aliases).toContain('alias2');

View File

@ -8,9 +8,7 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(BarComponent, { ..registerType(BarComponent, new ReflectionInfo(
'factory': () => new BarComponent(), const [const Component(selector: '[bar]')], const [],
'parameters': const [], () => new BarComponent()));
'annotations': const [const Component(selector: '[bar]')]
});
} }

View File

@ -11,10 +11,8 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(FooComponent, { ..registerType(FooComponent, new ReflectionInfo(
'factory': () => new FooComponent(), const [const Component(selector: '[foo]')], const [],
'parameters': const [], () => new FooComponent()));
'annotations': const [const Component(selector: '[foo]')]
});
i0.initReflector(reflector); i0.initReflector(reflector);
} }

View File

@ -9,9 +9,7 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(
'factory': () => new HelloCmp(), const [const Component(changeDetection: 'CHECK_ONCE')],
'parameters': const [const []], const [const []], () => new HelloCmp()));
'annotations': const [const Component(changeDetection: 'CHECK_ONCE')]
});
} }

View File

@ -8,19 +8,12 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(UnsetComp, { ..registerType(UnsetComp, new ReflectionInfo(
'factory': () => new UnsetComp(), const [const Directive()], const [const []], () => new UnsetComp()))
'parameters': const [const []], ..registerType(FalseComp, new ReflectionInfo(
'annotations': const [const Directive()] const [const Directive(compileChildren: false)], const [const []],
}) () => new FalseComp()))
..registerType(FalseComp, { ..registerType(TrueComp, new ReflectionInfo(
'factory': () => new FalseComp(), const [const Directive(compileChildren: true)], const [const []],
'parameters': const [const []], () => new TrueComp()));
'annotations': const [const Directive(compileChildren: false)]
})
..registerType(TrueComp, {
'factory': () => new TrueComp(),
'parameters': const [const []],
'annotations': const [const Directive(compileChildren: true)]
});
} }

View File

@ -9,9 +9,7 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(
'factory': () => new HelloCmp(), const [const Directive(exportAs: 'exportAsName')], const [const []],
'parameters': const [const []], () => new HelloCmp()));
'annotations': const [const Directive(exportAs: 'exportAsName')]
});
} }

View File

@ -9,9 +9,7 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(
'factory': () => new HelloCmp(), const [const Component(events: ['onFoo', 'onBar'])], const [const []],
'parameters': const [const []], () => new HelloCmp()));
'annotations': const [const Component(events: ['onFoo', 'onBar'])]
});
} }

View File

@ -9,10 +9,7 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component( const Component(
host: const { host: const {
'(change)': 'onChange(\$event)', '(change)': 'onChange(\$event)',
@ -20,6 +17,5 @@ void initReflector(reflector) {
'@actionName': 'actionValue', '@actionName': 'actionValue',
'attName': 'attValue' 'attName': 'attValue'
}) })
] ], const [const []], () => new HelloCmp()));
});
} }

View File

@ -9,10 +9,7 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component( const Component(
lifecycle: [ lifecycle: [
LifecycleEvent.onChange, LifecycleEvent.onChange,
@ -21,6 +18,5 @@ void initReflector(reflector) {
LifecycleEvent.onCheck, LifecycleEvent.onCheck,
LifecycleEvent.onAllChangesDone LifecycleEvent.onAllChangesDone
]) ])
] ], const [const []], () => new HelloCmp()));
});
} }

View File

@ -9,11 +9,7 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(
'factory': () => new HelloCmp(), const [const Component(properties: const ['key1: val1', 'key2: val2'])],
'parameters': const [const []], const [const []], () => new HelloCmp()));
'annotations': const [
const Component(properties: const ['key1: val1', 'key2: val2'])
]
});
} }

View File

@ -9,9 +9,7 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(
'factory': () => new HelloCmp(), const [const Component(selector: 'hello-app')], const [const []],
'parameters': const [const []], () => new HelloCmp()));
'annotations': const [const Component(selector: 'hello-app')]
});
} }

View File

@ -9,12 +9,8 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const Component(selector: 'goodbye-app') const Component(selector: 'goodbye-app')
] ], const [const []], () => new HelloCmp()));
});
} }

View File

@ -8,9 +8,7 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(BarComponent, { ..registerType(BarComponent, new ReflectionInfo(
'factory': () => new BarComponent(), const [const Component(selector: '[bar]')], const [],
'parameters': const [], () => new BarComponent()));
'annotations': const [const Component(selector: '[bar]')]
});
} }

View File

@ -11,10 +11,8 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(FooComponent, { ..registerType(FooComponent, new ReflectionInfo(
'factory': () => new FooComponent(), const [const Component(selector: '[foo]')], const [],
'parameters': const [], () => new FooComponent()));
'annotations': const [const Component(selector: '[foo]')]
});
i0.initReflector(reflector); i0.initReflector(reflector);
} }

View File

@ -11,10 +11,8 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(BarComponent, { ..registerType(BarComponent, new ReflectionInfo(
'factory': () => new BarComponent(), const [const Component(selector: '[bar]')], const [],
'parameters': const [], () => new BarComponent()));
'annotations': const [const Component(selector: '[bar]')]
});
i0.initReflector(reflector); i0.initReflector(reflector);
} }

View File

@ -8,9 +8,7 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(BazComponent, { ..registerType(BazComponent, new ReflectionInfo(
'factory': () => new BazComponent(), const [const Component(selector: '[baz]')], const [],
'parameters': const [], () => new BazComponent()));
'annotations': const [const Component(selector: '[baz]')]
});
} }

View File

@ -11,10 +11,8 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(FooComponent, { ..registerType(FooComponent, new ReflectionInfo(
'factory': () => new FooComponent(), const [const Component(selector: '[foo]')], const [],
'parameters': const [], () => new FooComponent()));
'annotations': const [const Component(selector: '[foo]')]
});
i0.initReflector(reflector); i0.initReflector(reflector);
} }

View File

@ -8,9 +8,7 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(FooComponent, { ..registerType(FooComponent, new ReflectionInfo(
'factory': () => new FooComponent(), const [const Component(selector: '[foo]')], const [],
'parameters': const [], () => new FooComponent()));
'annotations': const [const Component(selector: '[foo]')]
});
} }

View File

@ -11,15 +11,11 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new _ngRef.ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View( const View(
template: r'''{{greeting}}''', template: r'''{{greeting}}''',
templateUrl: r'package:other_package/template.html', templateUrl: r'package:other_package/template.html',
styles: const [r'''.greeting { .color: blue; }''',]) styles: const [r'''.greeting { .color: blue; }''',])
] ], const [], () => new HelloCmp()));
});
} }

View File

@ -50,18 +50,14 @@ void allTests() {
'should inline `templateUrl` values.', 'url_expression_files/hello.dart'); 'should inline `templateUrl` values.', 'url_expression_files/hello.dart');
var absoluteReader = new TestAssetReader(); var absoluteReader = new TestAssetReader();
absoluteReader.addAsset( absoluteReader.addAsset(new AssetId('other_package', 'lib/template.html'),
new AssetId('other_package', 'lib/template.html'),
readFile( readFile(
'directive_processor/absolute_url_expression_files/template.html')); 'directive_processor/absolute_url_expression_files/template.html'));
absoluteReader.addAsset( absoluteReader.addAsset(new AssetId('other_package', 'lib/template.css'),
new AssetId('other_package', 'lib/template.css'),
readFile( readFile(
'directive_processor/absolute_url_expression_files/template.css')); 'directive_processor/absolute_url_expression_files/template.css'));
_testProcessor( _testProcessor('should inline `templateUrl` and `styleUrls` values expressed'
'should inline `templateUrl` and `styleUrls` values expressed' ' as absolute urls.', 'absolute_url_expression_files/hello.dart',
' as absolute urls.',
'absolute_url_expression_files/hello.dart',
reader: absoluteReader); reader: absoluteReader);
_testProcessor( _testProcessor(
@ -72,16 +68,12 @@ void allTests() {
readFile('directive_processor/multiple_style_urls_files/template.html')); readFile('directive_processor/multiple_style_urls_files/template.html'));
absoluteReader.addAsset(new AssetId('a', 'lib/template.css'), absoluteReader.addAsset(new AssetId('a', 'lib/template.css'),
readFile('directive_processor/multiple_style_urls_files/template.css')); readFile('directive_processor/multiple_style_urls_files/template.css'));
absoluteReader.addAsset( absoluteReader.addAsset(new AssetId('a', 'lib/template_other.css'), readFile(
new AssetId('a', 'lib/template_other.css'),
readFile(
'directive_processor/multiple_style_urls_files/template_other.css')); 'directive_processor/multiple_style_urls_files/template_other.css'));
_testProcessor( _testProcessor(
'shouldn\'t inline multiple `styleUrls` values expressed as absolute ' 'shouldn\'t inline multiple `styleUrls` values expressed as absolute '
'urls.', 'urls.', 'multiple_style_urls_not_inlined_files/hello.dart',
'multiple_style_urls_not_inlined_files/hello.dart', inlineViews: false, reader: absoluteReader);
inlineViews: false,
reader: absoluteReader);
_testProcessor('should inline `templateUrl`s expressed as adjacent strings.', _testProcessor('should inline `templateUrl`s expressed as adjacent strings.',
'split_url_expression_files/hello.dart'); 'split_url_expression_files/hello.dart');
@ -126,16 +118,12 @@ void allTests() {
'static_function_files/hello.dart'); 'static_function_files/hello.dart');
_testProcessor('should find direcive aliases patterns.', _testProcessor('should find direcive aliases patterns.',
'directive_aliases_files/hello.dart', 'directive_aliases_files/hello.dart', reader: absoluteReader);
reader: absoluteReader);
} }
void _testProcessor(String name, String inputPath, void _testProcessor(String name, String inputPath,
{List<AnnotationDescriptor> customDescriptors: const [], {List<AnnotationDescriptor> customDescriptors: const [], AssetId assetId,
AssetId assetId, AssetReader reader, List<String> expectedLogs, bool inlineViews: true,
AssetReader reader,
List<String> expectedLogs,
bool inlineViews: true,
bool isolate: false}) { bool isolate: false}) {
var testFn = isolate ? iit : it; var testFn = isolate ? iit : it;
testFn(name, () async { testFn(name, () async {
@ -161,8 +149,7 @@ void _testProcessor(String name, String inputPath,
..addAll(customDescriptors); ..addAll(customDescriptors);
var ngMeta = new NgMeta.empty(); var ngMeta = new NgMeta.empty();
var output = await createNgDeps( var output = await createNgDeps(
reader, inputId, annotationMatcher, ngMeta, reader, inputId, annotationMatcher, ngMeta, inlineViews: inlineViews);
inlineViews: inlineViews);
if (output == null) { if (output == null) {
expect(await reader.hasInput(expectedNgDepsId)).toBeFalse(); expect(await reader.hasInput(expectedNgDepsId)).toBeFalse();
} else { } else {

View File

@ -10,9 +10,6 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(PackageSoup, { ..registerType(PackageSoup, new _ngRef.ReflectionInfo(
'factory': () => new PackageSoup(), const [const Soup()], const [], () => new PackageSoup()));
'parameters': const [],
'annotations': const [const Soup()]
});
} }

View File

@ -10,9 +10,6 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(RelativeSoup, { ..registerType(RelativeSoup, new _ngRef.ReflectionInfo(
'factory': () => new RelativeSoup(), const [const Soup()], const [], () => new RelativeSoup()));
'parameters': const [],
'annotations': const [const Soup()]
});
} }

View File

@ -13,15 +13,11 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new _ngRef.ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View( const View(
template: r'''{{greeting}}''', template: r'''{{greeting}}''',
templateUrl: r'template.html', templateUrl: r'template.html',
styles: const [r'''.greeting { .color: blue; }''',]) styles: const [r'''.greeting { .color: blue; }''',])
] ], const [], () => new HelloCmp()));
});
} }

View File

@ -11,10 +11,7 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new _ngRef.ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View( const View(
template: r'''{{greeting}}''', template: r'''{{greeting}}''',
@ -23,6 +20,5 @@ void initReflector() {
r'''.greeting { .color: blue; }''', r'''.greeting { .color: blue; }''',
r'''.hello { .color: red; }''', r'''.hello { .color: red; }''',
]) ])
] ], const [], () => new HelloCmp()));
});
} }

View File

@ -10,10 +10,7 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(ChangingSoupComponent, { ..registerType(ChangingSoupComponent, new _ngRef.ReflectionInfo(
'factory': () => new ChangingSoupComponent(), const [const Component(selector: '[soup]')], const [],
'parameters': const [], () => new ChangingSoupComponent(), const [PrimaryInterface]));
'annotations': const [const Component(selector: '[soup]')],
'interfaces': const [PrimaryInterface]
});
} }

View File

@ -10,50 +10,27 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(OnChangeSoupComponent, { ..registerType(OnChangeSoupComponent, new _ngRef.ReflectionInfo(const [
'factory': () => new OnChangeSoupComponent(),
'parameters': const [],
'annotations': const [
const Component( const Component(
selector: '[soup]', lifecycle: const [LifecycleEvent.onChange]) selector: '[soup]', lifecycle: const [LifecycleEvent.onChange])
], ], const [], () => new OnChangeSoupComponent(), const [OnChange]))
'interfaces': const [OnChange] ..registerType(OnDestroySoupComponent, new _ngRef.ReflectionInfo(const [
})
..registerType(OnDestroySoupComponent, {
'factory': () => new OnDestroySoupComponent(),
'parameters': const [],
'annotations': const [
const Component( const Component(
selector: '[soup]', lifecycle: const [LifecycleEvent.onDestroy]) selector: '[soup]', lifecycle: const [LifecycleEvent.onDestroy])
], ], const [], () => new OnDestroySoupComponent(), const [OnDestroy]))
'interfaces': const [OnDestroy] ..registerType(OnCheckSoupComponent, new _ngRef.ReflectionInfo(const [
})
..registerType(OnCheckSoupComponent, {
'factory': () => new OnCheckSoupComponent(),
'parameters': const [],
'annotations': const [
const Component( const Component(
selector: '[soup]', lifecycle: const [LifecycleEvent.onCheck]) selector: '[soup]', lifecycle: const [LifecycleEvent.onCheck])
], ], const [], () => new OnCheckSoupComponent(), const [OnCheck]))
'interfaces': const [OnCheck] ..registerType(OnInitSoupComponent, new _ngRef.ReflectionInfo(const [
})
..registerType(OnInitSoupComponent, {
'factory': () => new OnInitSoupComponent(),
'parameters': const [],
'annotations': const [
const Component( const Component(
selector: '[soup]', lifecycle: const [LifecycleEvent.onInit]) selector: '[soup]', lifecycle: const [LifecycleEvent.onInit])
], ], const [], () => new OnInitSoupComponent(), const [OnInit]))
'interfaces': const [OnInit] ..registerType(OnAllChangesDoneSoupComponent, new _ngRef.ReflectionInfo(
}) const [
..registerType(OnAllChangesDoneSoupComponent, {
'factory': () => new OnAllChangesDoneSoupComponent(),
'parameters': const [],
'annotations': const [
const Component( const Component(
selector: '[soup]', selector: '[soup]',
lifecycle: const [LifecycleEvent.onAllChangesDone]) lifecycle: const [LifecycleEvent.onAllChangesDone])
], ], const [], () => new OnAllChangesDoneSoupComponent(),
'interfaces': const [OnAllChangesDone] const [OnAllChangesDone]));
});
} }

View File

@ -10,10 +10,7 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(ChangingSoupComponent, { ..registerType(ChangingSoupComponent, new _ngRef.ReflectionInfo(
'factory': () => new ChangingSoupComponent(), const [const Component(selector: '[soup]')], const [],
'parameters': const [], () => new ChangingSoupComponent(), const [OnChange, AnotherInterface]));
'annotations': const [const Component(selector: '[soup]')],
'interfaces': const [OnChange, AnotherInterface]
});
} }

View File

@ -11,15 +11,11 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new _ngRef.ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View( const View(
template: r'''''', template: r'''''',
templateUrl: r'/bad/absolute/url.html', templateUrl: r'/bad/absolute/url.html',
styles: const [r'''''', r'''''',]) styles: const [r'''''', r'''''',])
] ], const [], () => new HelloCmp()));
});
} }

View File

@ -10,10 +10,7 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(MultiSoupComponent, { ..registerType(MultiSoupComponent, new _ngRef.ReflectionInfo(const [
'factory': () => new MultiSoupComponent(),
'parameters': const [],
'annotations': const [
const Component( const Component(
selector: '[soup]', selector: '[soup]',
lifecycle: const [ lifecycle: const [
@ -21,7 +18,9 @@ void initReflector() {
LifecycleEvent.onDestroy, LifecycleEvent.onDestroy,
LifecycleEvent.onInit LifecycleEvent.onInit
]) ])
], ], const [], () => new MultiSoupComponent(), const [
'interfaces': const [OnChange, OnDestroy, OnInit] OnChange,
}); OnDestroy,
OnInit
]));
} }

View File

@ -11,10 +11,7 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new _ngRef.ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View( const View(
template: r'''{{greeting}}''', template: r'''{{greeting}}''',
@ -23,6 +20,5 @@ void initReflector() {
r'''.greeting { .color: blue; }''', r'''.greeting { .color: blue; }''',
r'''.hello { .color: red; }''', r'''.hello { .color: red; }''',
]) ])
] ], const [], () => new HelloCmp()));
});
} }

View File

@ -11,10 +11,7 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new _ngRef.ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View( const View(
templateUrl: 'package:a/template.html', templateUrl: 'package:a/template.html',
@ -22,6 +19,5 @@ void initReflector() {
'package:a/template.css', 'package:a/template.css',
'package:a/template_other.css' 'package:a/template_other.css'
]) ])
] ], const [], () => new HelloCmp()));
});
} }

View File

@ -10,10 +10,9 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(SoupComponent, { ..registerType(SoupComponent, new _ngRef.ReflectionInfo(
'factory': const [const Component(selector: '[soup]')], const [
(String description, salt) => new SoupComponent(description, salt), const [String, Tasty],
'parameters': const [const [String, Tasty], const [const Inject(Salt)]], const [const Inject(Salt)]
'annotations': const [const Component(selector: '[soup]')] ], (String description, salt) => new SoupComponent(description, salt)));
});
} }

View File

@ -10,14 +10,8 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(OnChangeSoupComponent, { ..registerType(OnChangeSoupComponent, new _ngRef.ReflectionInfo(const [
'factory': () => new OnChangeSoupComponent(),
'parameters': const [],
'annotations': const [
const prefix.Component( const prefix.Component(
selector: '[soup]', selector: '[soup]', lifecycle: const [prefix.LifecycleEvent.onChange])
lifecycle: const [prefix.LifecycleEvent.onChange]) ], const [], () => new OnChangeSoupComponent(), const [prefix.OnChange]));
],
'interfaces': const [prefix.OnChange]
});
} }

View File

@ -11,12 +11,8 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new _ngRef.ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(template: r'''{{greeting}}''', templateUrl: r'template.html') const View(template: r'''{{greeting}}''', templateUrl: r'template.html')
] ], const [], () => new HelloCmp()));
});
} }

View File

@ -10,13 +10,8 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerFunction(getMessage, { ..registerFunction(getMessage, new _ngRef.ReflectionInfo(
'parameters': const [const [const Inject(Message)]], const Injectable(), const [const [const Inject(Message)]]))
'annotations': const Injectable() ..registerType(Message, new _ngRef.ReflectionInfo(
}) const [const Injectable()], const [], () => new Message()));
..registerType(Message, {
'factory': () => new Message(),
'parameters': const [],
'annotations': const [const Injectable()]
});
} }

View File

@ -10,9 +10,7 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(ChangingSoupComponent, { ..registerType(ChangingSoupComponent, new _ngRef.ReflectionInfo(
'factory': () => new ChangingSoupComponent(), const [const Component(selector: '[soup]')], const [],
'parameters': const [], () => new ChangingSoupComponent()));
'annotations': const [const Component(selector: '[soup]')]
});
} }

View File

@ -10,12 +10,8 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(OnChangeSoupComponent, { ..registerType(OnChangeSoupComponent, new _ngRef.ReflectionInfo(const [
'factory': () => new OnChangeSoupComponent(),
'parameters': const [],
'annotations': const [
const Component( const Component(
selector: '[soup]', lifecycle: const [LifecycleEvent.onChange]) selector: '[soup]', lifecycle: const [LifecycleEvent.onChange])
] ], const [], () => new OnChangeSoupComponent()));
});
} }

View File

@ -11,12 +11,8 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new _ngRef.ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(template: r'''{{greeting}}''', templateUrl: r'template.html') const View(template: r'''{{greeting}}''', templateUrl: r'template.html')
] ], const [], () => new HelloCmp()));
});
} }

View File

@ -11,10 +11,7 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(MyComponent, { ..registerType(MyComponent, new _ngRef.ReflectionInfo(
'factory': (MyContext c) => new MyComponent(c), const [const Component(componentServices: const [MyContext])],
'parameters': const [const [MyContext]], const [const [MyContext]], (MyContext c) => new MyComponent(c)));
'annotations':
const [const Component(componentServices: const [MyContext])]
});
} }

View File

@ -10,9 +10,7 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(MyComponent, { ..registerType(MyComponent, new _ngRef.ReflectionInfo(
'factory': () => new MyComponent(), const [const Component(selector: '[soup]')], const [],
'parameters': const [], () => new MyComponent()));
'annotations': const [const Component(selector: '[soup]')]
});
} }

View File

@ -10,9 +10,7 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(MyComponent, { ..registerType(MyComponent, new _ngRef.ReflectionInfo(
'factory': () => new MyComponent(), const [const Component(selector: '[soup]')], const [],
'parameters': const [], () => new MyComponent()));
'annotations': const [const Component(selector: '[soup]')]
});
} }

View File

@ -14,14 +14,10 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(MyComponent, { ..registerType(MyComponent, new _ngRef.ReflectionInfo(const [
'factory': () => new MyComponent(),
'parameters': const [],
'annotations': const [
const Component(selector: '[soup]'), const Component(selector: '[soup]'),
const View(template: 'Salad: {{myNum}} is awesome') const View(template: 'Salad: {{myNum}} is awesome')
] ], const [], () => new MyComponent()))
})
..registerGetters({'myNum': (o) => o.myNum}) ..registerGetters({'myNum': (o) => o.myNum})
..registerSetters({'myNum': (o, v) => o.myNum = v}); ..registerSetters({'myNum': (o, v) => o.myNum = v});
_gen.preGeneratedProtoDetectors['MyComponent_comp_0'] = _gen.preGeneratedProtoDetectors['MyComponent_comp_0'] =

View File

@ -11,10 +11,9 @@ void initReflector() {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
_ngRef.reflector _ngRef.reflector
..registerType(MyComponent, { ..registerType(MyComponent, new _ngRef.ReflectionInfo(
'factory': const [const Component(selector: 'soup')], const [
(prefix.MyContext c, String inValue) => new MyComponent(c, inValue), const [prefix.MyContext],
'parameters': const [const [prefix.MyContext], const [String]], const [String]
'annotations': const [const Component(selector: 'soup')] ], (prefix.MyContext c, String inValue) => new MyComponent(c, inValue)));
});
} }

View File

@ -12,6 +12,8 @@ import 'log_mirrors_files/expected/index.dart' as log_mirrors;
import 'verbose_files/expected/index.dart' as verbose_mirrors; import 'verbose_files/expected/index.dart' as verbose_mirrors;
import '../common/read_file.dart'; import '../common/read_file.dart';
main() => allTests();
void allTests() { void allTests() {
var codegen = new Codegen('web/index.dart', ['web/index.ng_deps.dart']); var codegen = new Codegen('web/index.dart', ['web/index.ng_deps.dart']);
var code = readFile('reflection_remover/index.dart').replaceAll('\r\n', '\n'); var code = readFile('reflection_remover/index.dart').replaceAll('\r\n', '\n');

View File

@ -9,20 +9,12 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(template: 'goodbye-app', directives: const [alias1]) const View(template: 'goodbye-app', directives: const [alias1])
] ], const [const []], () => new HelloCmp()))
}) ..registerType(GoodbyeCmp, new ReflectionInfo(const [
..registerType(GoodbyeCmp, {
'factory': () => new GoodbyeCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'goodbye-app'), const Component(selector: 'goodbye-app'),
const View(template: 'Goodbye') const View(template: 'Goodbye')
] ], const [const []], () => new GoodbyeCmp()));
});
} }

View File

@ -9,20 +9,12 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(template: 'goodbye-app', directives: const [GoodbyeCmp]) const View(template: 'goodbye-app', directives: const [GoodbyeCmp])
] ], const [const []], () => new HelloCmp()))
}) ..registerType(GoodbyeCmp, new ReflectionInfo(const [
..registerType(GoodbyeCmp, {
'factory': () => new GoodbyeCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'goodbye-app'), const Component(selector: 'goodbye-app'),
const View(template: 'Goodbye') const View(template: 'Goodbye')
] ], const [const []], () => new GoodbyeCmp()));
});
} }

View File

@ -9,14 +9,10 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(template: '{{greeting}}, {{greeting}}') const View(template: '{{greeting}}, {{greeting}}')
] ], const [const []], () => new HelloCmp()))
})
..registerGetters({'greeting': (o) => o.greeting}) ..registerGetters({'greeting': (o) => o.greeting})
..registerSetters({'greeting': (o, v) => o.greeting = v}); ..registerSetters({'greeting': (o, v) => o.greeting = v});
} }

View File

@ -9,12 +9,8 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(template: '{{greeting}}, {{greeting}}') const View(template: '{{greeting}}, {{greeting}}')
] ], const [const []], () => new HelloCmp()));
});
} }

View File

@ -9,14 +9,10 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(template: '<div [a]="b">{{greeting}}</div>') const View(template: '<div [a]="b">{{greeting}}</div>')
] ], const [const []], () => new HelloCmp()))
})
..registerGetters({'b': (o) => o.b, 'greeting': (o) => o.greeting}) ..registerGetters({'b': (o) => o.b, 'greeting': (o) => o.greeting})
..registerSetters( ..registerSetters(
{'b': (o, v) => o.b = v, 'greeting': (o, v) => o.greeting = v}); {'b': (o, v) => o.b = v, 'greeting': (o, v) => o.greeting = v});

View File

@ -9,12 +9,8 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(template: '<div [a]="b">{{greeting}}</div>') const View(template: '<div [a]="b">{{greeting}}</div>')
] ], const [const []], () => new HelloCmp()));
});
} }

View File

@ -9,14 +9,10 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(template: '<button (click)=\"action()\">go</button>') const View(template: '<button (click)=\"action()\">go</button>')
] ], const [const []], () => new HelloCmp()))
})
..registerMethods( ..registerMethods(
{'action': (o, List args) => Function.apply(o.action, args)}); {'action': (o, List args) => Function.apply(o.action, args)});
} }

View File

@ -9,12 +9,8 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(template: '<button (click)=\"action()\">go</button>') const View(template: '<button (click)=\"action()\">go</button>')
] ], const [const []], () => new HelloCmp()));
});
} }

View File

@ -9,14 +9,10 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View( const View(
template: '<li *ng-for="#thing of things"><div>test</div></li>', template: '<li *ng-for="#thing of things"><div>test</div></li>',
directives: const [NgFor]) directives: const [NgFor])
] ], const [const []], () => new HelloCmp()));
});
} }

View File

@ -9,20 +9,12 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(template: 'goodbye-app', directives: const [GoodbyeCmp]) const View(template: 'goodbye-app', directives: const [GoodbyeCmp])
] ], const [const []], () => new HelloCmp()))
}) ..registerType(GoodbyeCmp, new ReflectionInfo(const [
..registerType(GoodbyeCmp, {
'factory': () => new GoodbyeCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'goodbye-app'), const Component(selector: 'goodbye-app'),
const View(template: 'Goodbye') const View(template: 'Goodbye')
] ], const [const []], () => new GoodbyeCmp()));
});
} }

View File

@ -9,20 +9,12 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(template: 'goodbye-app', directives: const [GoodbyeCmp]) const View(template: 'goodbye-app', directives: const [GoodbyeCmp])
] ], const [const []], () => new HelloCmp()))
}) ..registerType(GoodbyeCmp, new ReflectionInfo(const [
..registerType(GoodbyeCmp, {
'factory': () => new GoodbyeCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'goodbye-app'), const Component(selector: 'goodbye-app'),
const View(template: 'Goodbye') const View(template: 'Goodbye')
] ], const [const []], () => new GoodbyeCmp()));
});
} }

View File

@ -9,14 +9,10 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(templateUrl: 'template.html') const View(templateUrl: 'template.html')
] ], const [const []], () => new HelloCmp()))
})
..registerGetters({'greeting': (o) => o.greeting}) ..registerGetters({'greeting': (o) => o.greeting})
..registerSetters({'greeting': (o, v) => o.greeting = v}); ..registerSetters({'greeting': (o, v) => o.greeting = v});
} }

View File

@ -9,12 +9,8 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(templateUrl: 'template.html') const View(templateUrl: 'template.html')
] ], const [const []], () => new HelloCmp()));
});
} }

View File

@ -9,14 +9,10 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(templateUrl: 'template.html') const View(templateUrl: 'template.html')
] ], const [const []], () => new HelloCmp()))
})
..registerMethods( ..registerMethods(
{'action': (o, List args) => Function.apply(o.action, args)}); {'action': (o, List args) => Function.apply(o.action, args)});
} }

View File

@ -9,12 +9,8 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View(templateUrl: 'template.html') const View(templateUrl: 'template.html')
] ], const [const []], () => new HelloCmp()));
});
} }

View File

@ -9,14 +9,10 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(GoodbyeCmp, { ..registerType(GoodbyeCmp, new ReflectionInfo(const [
'factory': () => new GoodbyeCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'goodbye-app'), const Component(selector: 'goodbye-app'),
const View(template: 'Goodbye {{name}}') const View(template: 'Goodbye {{name}}')
] ], const [const []], () => new GoodbyeCmp()))
})
..registerGetters({'name': (o) => o.name}) ..registerGetters({'name': (o) => o.name})
..registerSetters({'name': (o, v) => o.name = v}); ..registerSetters({'name': (o, v) => o.name = v});
} }

View File

@ -11,14 +11,9 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View( const View(template: 'goodbye-app', directives: const [prefix.GoodbyeCmp])
template: 'goodbye-app', directives: const [prefix.GoodbyeCmp]) ], const [const []], () => new HelloCmp()));
]
});
i0.initReflector(reflector); i0.initReflector(reflector);
} }

View File

@ -9,14 +9,10 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(MyApp, { ..registerType(MyApp, new ReflectionInfo(const [
'factory': () => new MyApp(),
'parameters': const [const []],
'annotations': const [
const ng2.Component(selector: 'my-app'), const ng2.Component(selector: 'my-app'),
const ng2.View(template: 'MyApp {{name}}') const ng2.View(template: 'MyApp {{name}}')
] ], const [const []], () => new MyApp()))
})
..registerGetters({'name': (o) => o.name}) ..registerGetters({'name': (o) => o.name})
..registerSetters({'name': (o, v) => o.name = v}); ..registerSetters({'name': (o, v) => o.name = v});
} }

View File

@ -9,12 +9,8 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(GoodbyeCmp, { ..registerType(GoodbyeCmp, new ReflectionInfo(const [
'factory': () => new GoodbyeCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'goodbye-app'), const Component(selector: 'goodbye-app'),
const View(template: 'Goodbye {{name}}') const View(template: 'Goodbye {{name}}')
] ], const [const []], () => new GoodbyeCmp()));
});
} }

View File

@ -11,14 +11,9 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(HelloCmp, { ..registerType(HelloCmp, new ReflectionInfo(const [
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
const Component(selector: 'hello-app'), const Component(selector: 'hello-app'),
const View( const View(template: 'goodbye-app', directives: const [prefix.GoodbyeCmp])
template: 'goodbye-app', directives: const [prefix.GoodbyeCmp]) ], const [const []], () => new HelloCmp()));
]
});
i0.initReflector(reflector); i0.initReflector(reflector);
} }

View File

@ -9,12 +9,8 @@ void initReflector(reflector) {
if (_visited) return; if (_visited) return;
_visited = true; _visited = true;
reflector reflector
..registerType(MyApp, { ..registerType(MyApp, new ReflectionInfo(const [
'factory': () => new MyApp(),
'parameters': const [const []],
'annotations': const [
const ng2.Component(selector: 'my-app'), const ng2.Component(selector: 'my-app'),
const ng2.View(template: 'MyApp {{name}}') const ng2.View(template: 'MyApp {{name}}')
] ], const [const []], () => new MyApp()));
});
} }