feat(core): renames Property into Input and Event into Output

BREACKING CHANGE:

Before: @Directive({properties: ['one'], events: ['two']})
After: @Directive({inputs: ['one'], outputs: ['two']})

Before: @Component({properties: ['one'], events: ['two']})
After: @Componet({inputs: ['one'], outputs: ['two']})

Before: class A {@Property() one; @Event() two;}
After: class A {@Input() one; @Output() two;}
This commit is contained in:
vsavkin
2015-09-30 20:59:23 -07:00
parent 33593cf8a2
commit adbfd29fd7
89 changed files with 405 additions and 423 deletions

View File

@ -105,7 +105,7 @@ class Component extends Directive {
injectables = injectables,
super(
selector: selector,
properties: properties,
inputs: properties,
events: events,
hostListeners: hostListeners,
lifecycle: lifecycle);

View File

@ -123,7 +123,7 @@ List<String> _generateSetters(Map<String, String> bindMap) {
/// the bind properties and the values are either the one and only type
/// binding to that property or the empty string.
Map<String, String> _createPropertiesMap(NgDeps ngDeps) {
var visitor = new ExtractNamedExpressionVisitor('properties');
var visitor = new ExtractNamedExpressionVisitor('inputs');
var bindMap = {};
ngDeps.registeredTypes.forEach((RegisteredType t) {
visitor.bindConfig.clear();
@ -167,7 +167,7 @@ List<String> _generateGetters(List<String> eventProperties) {
/// Collapses all `events` in {@link ngDeps} into a list of corresponding
/// property names.
List<String> _createEventPropertiesList(NgDeps ngDeps) {
var visitor = new ExtractNamedExpressionVisitor('events');
var visitor = new ExtractNamedExpressionVisitor('outputs');
var propertyNames = [];
ngDeps.registeredTypes.forEach((RegisteredType t) {
visitor.bindConfig.clear();

View File

@ -19,7 +19,7 @@ Map<String, dynamic> directiveMetadataToMap(RenderDirectiveMetadata meta) {
["hostProperties", _cloneIfPresent(meta.hostProperties)],
["hostListeners", _cloneIfPresent(meta.hostListeners)],
["hostAttributes", _cloneIfPresent(meta.hostAttributes)],
["properties", _cloneIfPresent(meta.properties)],
["inputs", _cloneIfPresent(meta.inputs)],
["readAttributes", _cloneIfPresent(meta.readAttributes)],
["type", meta.type],
["exportAs", meta.exportAs],
@ -31,7 +31,7 @@ Map<String, dynamic> directiveMetadataToMap(RenderDirectiveMetadata meta) {
["callAfterContentChecked", meta.callAfterContentChecked],
["callAfterViewInit", meta.callAfterViewInit],
["callAfterViewChecked", meta.callAfterViewChecked],
["events", meta.events],
["outputs", meta.outputs],
["changeDetection", meta.changeDetection == null ? null : meta.changeDetection.index],
["version", 1]
]);
@ -52,7 +52,7 @@ RenderDirectiveMetadata directiveMetadataFromMap(Map<String, dynamic> map) {
map["hostListeners"]) as Map<String, String>),
hostAttributes: (_cloneIfPresent(
map["hostAttributes"]) as Map<String, String>),
properties: (_cloneIfPresent(map["properties"]) as List<String>),
inputs: (_cloneIfPresent(map["inputs"]) as List<String>),
readAttributes: (_cloneIfPresent(map["readAttributes"]) as List<String>),
type: (map["type"] as num),
exportAs: (map["exportAs"] as String),
@ -64,7 +64,7 @@ RenderDirectiveMetadata directiveMetadataFromMap(Map<String, dynamic> map) {
callAfterContentChecked: (map["callAfterContentChecked"] as bool),
callAfterViewInit: (map["callAfterViewInit"] as bool),
callAfterViewChecked: (map["callAfterViewChecked"] as bool),
events: (_cloneIfPresent(map["events"]) as List<String>),
outputs: (_cloneIfPresent(map["outputs"]) as List<String>),
changeDetection: map["changeDetection"] == null ? null
: ChangeDetectionStrategy.values[map["changeDetection"] as int]);
}

View File

@ -132,7 +132,7 @@ class _DirectiveMetadataVisitor extends Object
num _type;
String _selector;
bool _compileChildren;
List<String> _properties;
List<String> _inputs;
Map<String, String> _host;
List<String> _readAttributes;
String _exportAs;
@ -145,7 +145,7 @@ class _DirectiveMetadataVisitor extends Object
bool _callAfterViewInit;
bool _callAfterViewChecked;
ChangeDetectionStrategy _changeDetection;
List<String> _events;
List<String> _outputs;
final ConstantEvaluator _evaluator = new ConstantEvaluator();
@ -155,7 +155,7 @@ class _DirectiveMetadataVisitor extends Object
_type = directiveType;
_selector = '';
_compileChildren = true;
_properties = [];
_inputs = [];
_host = {};
_readAttributes = [];
_exportAs = null;
@ -168,14 +168,14 @@ class _DirectiveMetadataVisitor extends Object
_callAfterViewInit = false;
_callAfterViewChecked = false;
_changeDetection = null;
_events = [];
_outputs = [];
}
RenderDirectiveMetadata get meta => RenderDirectiveMetadata.create(
type: _type,
selector: _selector,
compileChildren: _compileChildren,
properties: _properties,
inputs: _inputs,
host: _host,
readAttributes: _readAttributes,
exportAs: _exportAs,
@ -188,7 +188,7 @@ class _DirectiveMetadataVisitor extends Object
callAfterViewInit: _callAfterViewInit,
callAfterViewChecked: _callAfterViewChecked,
changeDetection: _changeDetection,
events: _events);
outputs: _outputs);
@override
Object visitAnnotation(Annotation node) {
@ -223,7 +223,7 @@ class _DirectiveMetadataVisitor extends Object
case 'compileChildren':
_populateCompileChildren(node.expression);
break;
case 'properties':
case 'inputs':
_populateProperties(node.expression);
break;
case 'host':
@ -235,7 +235,7 @@ class _DirectiveMetadataVisitor extends Object
case 'changeDetection':
_populateChangeDetection(node.expression);
break;
case 'events':
case 'outputs':
_populateEvents(node.expression);
break;
}
@ -312,7 +312,7 @@ class _DirectiveMetadataVisitor extends Object
void _populateProperties(Expression propertiesValue) {
_checkMeta();
_populateList(propertiesValue, _properties, 'Directive#properties');
_populateList(propertiesValue, _inputs, 'Directive#properties');
}
void _populateHost(Expression hostValue) {
@ -342,7 +342,7 @@ class _DirectiveMetadataVisitor extends Object
void _populateEvents(Expression eventsValue) {
_checkMeta();
_populateList(eventsValue, _events, 'Directive#events');
_populateList(eventsValue, _outputs, 'Directive#events');
}
void _populateChangeDetection(Expression value) {

View File

@ -32,8 +32,8 @@ class Processor implements CodegenModel {
void _processViewDefinition(ViewDefinitionEntry viewDefEntry) {
// These are necessary even with generated change detectors.
if (viewDefEntry.hostMetadata != null &&
viewDefEntry.hostMetadata.events != null) {
viewDefEntry.hostMetadata.events.forEach((eventName) {
viewDefEntry.hostMetadata.outputs != null) {
viewDefEntry.hostMetadata.outputs.forEach((eventName) {
getterNames.add(
new ReflectiveAccessor(eventName, isStaticallyNecessary: true));
});

View File

@ -12,6 +12,6 @@ void initReflector(reflector) {
ToolTip,
new ReflectionInfo(const [
const Directive(
selector: '[tool-tip]', properties: const ['text: tool-tip'])
selector: '[tool-tip]', inputs: const ['text: tool-tip'])
], const [], () => new ToolTip()));
}

View File

@ -12,7 +12,7 @@ void initReflector(reflector) {
ToolTip,
new ReflectionInfo(const [
const Directive(
selector: '[tool-tip]', properties: const ['text: tool-tip'])
selector: '[tool-tip]', inputs: const ['text: tool-tip'])
], const [], () => new ToolTip()))
..registerSetters({'text': (o, v) => o.text = v});
}

View File

@ -13,12 +13,12 @@ void initReflector(reflector) {
new ReflectionInfo(const [
const Component(
componentServices: const [SaladComponent],
properties: const ['menu'])
inputs: const ['menu'])
], const [], () => new SoupComponent()))
..registerType(
SaladComponent,
new ReflectionInfo(const [
const Component(properties: const ['menu'])
const Component(inputs: const ['menu'])
], const [], () => new SaladComponent()))
..registerSetters({'menu': (o, v) => o.menu = v});
}

View File

@ -13,11 +13,11 @@ void initReflector(reflector) {
new ReflectionInfo(const [
const Component(
componentServices: const [SaladComponent],
properties: const ['menu'])
inputs: const ['menu'])
], const [], () => new SoupComponent()))
..registerType(
SaladComponent,
new ReflectionInfo(const [
const Component(properties: const ['menu'])
const Component(inputs: const ['menu'])
], const [], () => new SaladComponent()));
}

View File

@ -13,6 +13,6 @@ void initReflector(reflector) {
new ReflectionInfo(const [
const Directive(
selector: '[tool-tip]',
events: const ['onOpen', 'close: onClose'])
outputs: const ['onOpen', 'close: onClose'])
], const [], () => new ToolTip()));
}

View File

@ -13,7 +13,7 @@ void initReflector(reflector) {
new ReflectionInfo(const [
const Directive(
selector: '[tool-tip]',
events: const ['onOpen', 'close: onClose'])
outputs: const ['onOpen', 'close: onClose'])
], const [], () => new ToolTip()))
..registerGetters({'onOpen': (o) => o.onOpen, 'close': (o) => o.close});
}

View File

@ -23,7 +23,7 @@ main() {
["AtKey", "AtVal"]
]),
id: "someComponent",
properties: ["propKey: propVal"],
inputs: ["propKey: propVal"],
readAttributes: ["read1", "read2"],
selector: "some-comp",
type: RenderDirectiveMetadata.COMPONENT_TYPE,
@ -36,7 +36,7 @@ main() {
callAfterContentChecked: true,
callAfterViewInit: true,
callAfterViewChecked: true,
events: ["onFoo", "onBar"],
outputs: ["onFoo", "onBar"],
changeDetection: ChangeDetectionStrategy.CheckOnce);
var map = directiveMetadataToMap(someComponent);
expect(map["compileChildren"]).toEqual(false);
@ -50,7 +50,7 @@ main() {
["AtKey", "AtVal"]
]));
expect(map["id"]).toEqual("someComponent");
expect(map["properties"]).toEqual(["propKey: propVal"]);
expect(map["inputs"]).toEqual(["propKey: propVal"]);
expect(map["readAttributes"]).toEqual(["read1", "read2"]);
expect(map["selector"]).toEqual("some-comp");
expect(map["type"]).toEqual(RenderDirectiveMetadata.COMPONENT_TYPE);
@ -63,7 +63,7 @@ main() {
expect(map["callAfterViewInit"]).toEqual(true);
expect(map["callAfterViewChecked"]).toEqual(true);
expect(map["exportAs"]).toEqual("aaa");
expect(map["events"]).toEqual(["onFoo", "onBar"]);
expect(map["outputs"]).toEqual(["onFoo", "onBar"]);
expect(map["changeDetection"])
.toEqual(ChangeDetectionStrategy.CheckOnce.index);
});
@ -90,7 +90,7 @@ main() {
],
["id", "testId"],
[
"properties",
"inputs",
["propKey: propVal"]
],
[
@ -109,7 +109,7 @@ main() {
["callAfterViewInit", true],
["callAfterViewChecked", true],
[
"events",
"outputs",
["onFoo", "onBar"]
],
["changeDetection", ChangeDetectionStrategy.CheckOnce.index]
@ -126,7 +126,7 @@ main() {
["AtKey", "testVal"]
]));
expect(meta.id).toEqual("testId");
expect(meta.properties).toEqual(["propKey: propVal"]);
expect(meta.inputs).toEqual(["propKey: propVal"]);
expect(meta.readAttributes).toEqual(["readTest1", "readTest2"]);
expect(meta.selector).toEqual("testSelector");
expect(meta.type).toEqual(RenderDirectiveMetadata.DIRECTIVE_TYPE);
@ -139,7 +139,7 @@ main() {
expect(meta.callAfterContentChecked).toEqual(true);
expect(meta.callAfterViewInit).toEqual(true);
expect(meta.callAfterViewChecked).toEqual(true);
expect(meta.events).toEqual(["onFoo", "onBar"]);
expect(meta.outputs).toEqual(["onFoo", "onBar"]);
expect(meta.changeDetection).toEqual(ChangeDetectionStrategy.CheckOnce);
});
});

View File

@ -65,13 +65,13 @@ void allTests() {
expect(trueComp.compileChildren).toBeTrue();
});
it('should parse properties.', () async {
it('should parse inputs.', () async {
var metadata = await readMetadata('directive_metadata_extractor/'
'directive_metadata_files/properties.ng_deps.dart');
expect(metadata.properties).toBeNotNull();
expect(metadata.properties.length).toBe(2);
expect(metadata.properties).toContain('key1: val1');
expect(metadata.properties).toContain('key2: val2');
expect(metadata.inputs).toBeNotNull();
expect(metadata.inputs.length).toBe(2);
expect(metadata.inputs).toContain('key1: val1');
expect(metadata.inputs).toContain('key2: val2');
});
it('should parse exportAs.', () async {
@ -112,10 +112,10 @@ void allTests() {
expect(metadata.callAfterViewChecked).toBe(true);
});
it('should parse events.', () async {
it('should parse outputs.', () async {
var metadata = await readMetadata('directive_metadata_extractor/'
'directive_metadata_files/events.ng_deps.dart');
expect(metadata.events).toEqual(['onFoo', 'onBar']);
expect(metadata.outputs).toEqual(['onFoo', 'onBar']);
});
it('should parse changeDetection.', () async {

View File

@ -12,7 +12,7 @@ void initReflector(reflector) {
..registerType(
HelloCmp,
new ReflectionInfo(const [
const Component(events: const ['onFoo', 'onBar'])
const Component(outputs: const ['onFoo', 'onBar'])
], const [
const []
], () => new HelloCmp()));

View File

@ -12,7 +12,7 @@ void initReflector(reflector) {
..registerType(
HelloCmp,
new ReflectionInfo(const [
const Component(properties: const ['key1: val1', 'key2: val2'])
const Component(inputs: const ['key1: val1', 'key2: val2'])
], const [
const []
], () => new HelloCmp()));

View File

@ -8,7 +8,7 @@
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"properties": [],
"inputs": [],
"readAttributes": [],
"type": 1,
"exportAs": null,
@ -20,7 +20,7 @@
"callAfterContentChecked": false,
"callAfterViewInit": false,
"callAfterViewChecked": false,
"events": [],
"outputs": [],
"changeDetection": null,
"version": 1
}

View File

@ -8,7 +8,7 @@
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"properties": null,
"inputs": null,
"readAttributes": null,
"type": null,
"exportAs": null,
@ -20,7 +20,7 @@
"callAfterContentChecked": null,
"callAfterViewInit": null,
"callAfterViewChecked": null,
"events": ["dependencyEventName"],
"outputs": ["dependencyEventName"],
"changeDetection": null,
"version": 1
}
@ -34,7 +34,7 @@
"hostProperties": {"hprop": "hprop"},
"hostListeners": {},
"hostAttributes": {},
"properties": ["prop"],
"inputs": ["prop"],
"readAttributes": null,
"type": null,
"exportAs": null,
@ -46,7 +46,7 @@
"callAfterContentChecked": null,
"callAfterViewInit": null,
"callAfterViewChecked": null,
"events": null,
"outpus": null,
"changeDetection": null,
"version": 1
}
@ -60,7 +60,7 @@
"hostProperties": {},
"hostListeners": {"subevent": "doAThing()"},
"hostAttributes": {},
"properties": [],
"inputs": [],
"readAttributes": null,
"type": null,
"exportAs": null,
@ -72,7 +72,7 @@
"callAfterContentChecked": null,
"callAfterViewInit": null,
"callAfterViewChecked": null,
"events": null,
"outputs": null,
"changeDetection": null,
"version": 1
}
@ -86,7 +86,7 @@
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"properties": ["ngForOf"],
"inputs": ["ngForOf"],
"readAttributes": null,
"type": null,
"exportAs": null,
@ -98,7 +98,7 @@
"callAfterContentChecked": null,
"callAfterViewInit": null,
"callAfterViewChecked": null,
"events": null,
"outputs": null,
"changeDetection": null,
"version": 1
}

View File

@ -30,7 +30,7 @@ void initReflector(reflector) {
..registerType(
EventsCmp,
new ReflectionInfo(const [
const Component(selector: 'events', events: const ['eventName']),
const Component(selector: 'events', outputs: const ['eventName']),
const View(template: 'Hi')
], const [
const []

View File

@ -30,7 +30,7 @@ void initReflector(reflector) {
..registerType(
EventsCmp,
new ReflectionInfo(const [
const Component(selector: 'events', events: const ['eventName']),
const Component(selector: 'events', outputs: const ['eventName']),
const View(template: 'Hi')
], const [
const []

View File

@ -8,7 +8,7 @@
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"properties": null,
"inputs": null,
"readAttributes": null,
"type": null,
"exportAs": null,
@ -20,7 +20,7 @@
"callAfterContentChecked": null,
"callAfterViewInit": null,
"callAfterViewChecked": null,
"events": null,
"outputs": null,
"changeDetection": null,
"version": 1
}
@ -34,7 +34,7 @@
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"properties": [],
"inputs": [],
"readAttributes": [],
"type": 0,
"exportAs": null,
@ -46,7 +46,7 @@
"callAfterContentChecked": false,
"callAfterViewInit": false,
"callAfterViewChecked": false,
"events": [],
"outputs": [],
"changeDetection": null,
"version": 1
}
@ -55,12 +55,12 @@
"kind": "type",
"value": {
"id": "EventsCmp",
"selector": "events",
"selector": "outputs",
"compileChildren": true,
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"properties": [],
"inputs": [],
"readAttributes": [],
"type": 1,
"exportAs": null,
@ -72,7 +72,7 @@
"callAfterContentChecked": false,
"callAfterViewInit": false,
"callAfterViewChecked": false,
"events": ["eventName"],
"outputs": ["eventName"],
"changeDetection": null,
"version": 1
}
@ -81,12 +81,12 @@
"kind": "type",
"value": {
"id": "SubEventsCmp",
"selector": "events",
"selector": "outputs",
"compileChildren": true,
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"properties": [],
"inputs": [],
"readAttributes": [],
"type": 1,
"exportAs": null,
@ -98,7 +98,7 @@
"callAfterContentChecked": false,
"callAfterViewInit": false,
"callAfterViewChecked": false,
"events": [],
"outputs": [],
"changeDetection": null,
"version": 1
}
@ -112,7 +112,7 @@
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"properties": [],
"inputs": [],
"readAttributes": [],
"type": 1,
"exportAs": null,
@ -124,7 +124,7 @@
"callAfterContentChecked": false,
"callAfterViewInit": false,
"callAfterViewChecked": false,
"events": [],
"outputs": [],
"changeDetection": null,
"version": 1
}
@ -138,7 +138,7 @@
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"properties": [],
"inputs": [],
"readAttributes": [],
"type": 1,
"exportAs": null,
@ -150,7 +150,7 @@
"callAfterContentChecked": false,
"callAfterViewInit": false,
"callAfterViewChecked": false,
"events": [],
"outputs": [],
"changeDetection": null,
"version": 1
}
@ -164,7 +164,7 @@
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"properties": [],
"inputs": [],
"readAttributes": [],
"type": 1,
"exportAs": null,
@ -176,7 +176,7 @@
"callAfterContentChecked": false,
"callAfterViewInit": false,
"callAfterViewChecked": false,
"events": [],
"outputs": [],
"changeDetection": null,
"version": 1
}
@ -190,7 +190,7 @@
"hostProperties": {},
"hostListeners": {},
"hostAttributes": {},
"properties": [],
"inputs": [],
"readAttributes": [],
"type": 1,
"exportAs": null,
@ -202,7 +202,7 @@
"callAfterContentChecked": false,
"callAfterViewInit": false,
"callAfterViewChecked": false,
"events": [],
"outputs": [],
"changeDetection": null,
"version": 1
}