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 {List, ListWrapper} from 'angular2/src/facade/collection';
import {Reflector} from './reflector';
export {Reflector} from './reflector';
export {Reflector, ReflectionInfo} from './reflector';
import {ReflectionCapabilities} from './reflection_capabilities';
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 {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 {
_injectableInfo: Map<any, StringMap<string, any>>;
_injectableInfo: Map<any, ReflectionInfo>;
_getters: Map<string, GetterFn>;
_setters: Map<string, SetterFn>;
_methods: Map<string, MethodFn>;
@ -29,11 +44,11 @@ export class Reflector {
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);
}
registerType(type: Type, typeInfo: StringMap<string, any>): void {
registerType(type: Type, typeInfo: ReflectionInfo): void {
this._injectableInfo.set(type, typeInfo);
}
@ -50,8 +65,9 @@ export class Reflector {
}
factory(type: Type): Function {
if (this._containsTypeInfo(type)) {
return this._getTypeInfoField(type, "factory", null);
if (this._containsReflectionInfo(type)) {
var res = this._injectableInfo.get(type)._factory;
return isPresent(res) ? res : null;
} else {
return this.reflectionCapabilities.factory(type);
}
@ -59,7 +75,8 @@ export class Reflector {
parameters(typeOrFunc: /*Type*/ any): List<any> {
if (this._injectableInfo.has(typeOrFunc)) {
return this._getTypeInfoField(typeOrFunc, "parameters", []);
var res = this._injectableInfo.get(typeOrFunc)._parameters;
return isPresent(res) ? res : [];
} else {
return this.reflectionCapabilities.parameters(typeOrFunc);
}
@ -67,7 +84,8 @@ export class Reflector {
annotations(typeOrFunc: /*Type*/ any): List<any> {
if (this._injectableInfo.has(typeOrFunc)) {
return this._getTypeInfoField(typeOrFunc, "annotations", []);
var res = this._injectableInfo.get(typeOrFunc)._annotations;
return isPresent(res) ? res : [];
} else {
return this.reflectionCapabilities.annotations(typeOrFunc);
}
@ -75,7 +93,8 @@ export class Reflector {
interfaces(type: Type): List<any> {
if (this._injectableInfo.has(type)) {
return this._getTypeInfoField(type, "interfaces", []);
var res = this._injectableInfo.get(type)._interfaces;
return isPresent(res) ? res : [];
} else {
return this.reflectionCapabilities.interfaces(type);
}
@ -105,12 +124,7 @@ export class Reflector {
}
}
_getTypeInfoField(typeOrFunc, key, defaultValue) {
var res = this._injectableInfo.get(typeOrFunc)[key];
return isPresent(res) ? res : defaultValue;
}
_containsTypeInfo(typeOrFunc) { return this._injectableInfo.has(typeOrFunc); }
_containsReflectionInfo(typeOrFunc) { return this._injectableInfo.has(typeOrFunc); }
}
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);
dynamic setZoned(BuildLogger logger, _SimpleCallback fn,
{String errorMessage: ''}) => runZoned(fn,
zoneValues: {_key: logger}, onError: (e, stackTrace) {
{String errorMessage}) {
var onError;
if (errorMessage != null) {
onError = (e, stackTrace) {
logger.error('$errorMessage\n'
'Exception: $e\n'
'Stack Trace: $stackTrace');
});
};
}
return runZoned(fn, zoneValues: {_key: logger}, onError: onError);
}
/// The logger for the current {@link Zone}.
BuildLogger get logger {

View File

@ -63,26 +63,22 @@ class _ParseRegisterTypeVisitor extends Object
typeName = node.argumentList.arguments[0] is Identifier
? node.argumentList.arguments[0]
: 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;
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -35,14 +35,14 @@ void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(HelloCmp, {
'factory': () => new HelloCmp(),
'parameters': const [const []],
'annotations': const [
..registerType(HelloCmp, new ReflectionInfo(
const [
const Component(selector: 'hello-app'),
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 {Reflector} from 'angular2/src/reflection/reflection';
import {Reflector, ReflectionInfo} from 'angular2/src/reflection/reflection';
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';
import {ClassDecorator, ParamDecorator, classDecorator, paramDecorator} from './reflector_common';
import {List} from 'angular2/src/facade/collection';
@ -88,7 +88,7 @@ export function main() {
() => { expect(() => reflector.factory(TestObjWith21Args)).toThrowError(); });
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");
});
});
@ -105,12 +105,12 @@ export function main() {
});
it("should return registered parameters if available", () => {
reflector.registerType(TestObj, {"parameters": [1, 2]});
expect(reflector.parameters(TestObj)).toEqual([1, 2]);
reflector.registerType(TestObj, new ReflectionInfo(null, [[1], [2]]));
expect(reflector.parameters(TestObj)).toEqual([[1], [2]]);
});
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([]);
});
});
@ -122,7 +122,7 @@ export function main() {
});
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]);
});

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,14 +11,10 @@ void initReflector() {
if (_visited) return;
_visited = true;
_ngRef.reflector
..registerType(HelloCmp, {
'factory': () => new HelloCmp(),
'parameters': const [],
'annotations': const [
..registerType(HelloCmp, new _ngRef.RegistrationInfo(const [
const Component(selector: 'hello-app'),
const View(
template: r'''{{greeting}}''',
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();
main() => allTests();
void allTests() {
var reader = new TestAssetReader();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,10 +11,9 @@ void initReflector() {
if (_visited) return;
_visited = true;
_ngRef.reflector
..registerType(MyComponent, {
'factory':
(prefix.MyContext c, String inValue) => new MyComponent(c, inValue),
'parameters': const [const [prefix.MyContext], const [String]],
'annotations': const [const Component(selector: 'soup')]
});
..registerType(MyComponent, new _ngRef.ReflectionInfo(
const [const Component(selector: 'soup')], const [
const [prefix.MyContext],
const [String]
], (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 '../common/read_file.dart';
main() => allTests();
void allTests() {
var codegen = new Codegen('web/index.dart', ['web/index.ng_deps.dart']);
var code = readFile('reflection_remover/index.dart').replaceAll('\r\n', '\n');

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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