refactor(transformer): apply properties/events rename

This commit is contained in:
Tobias Bosch
2015-10-01 11:46:16 -07:00
parent 841f8789fd
commit 30ca0434a2
34 changed files with 91 additions and 91 deletions

View File

@ -72,7 +72,7 @@ Future<String> createNgSettersAndGetters(
NgDeps ngDeps = await NgDeps.parse(reader, entryPoint);
String code = ngDeps.code;
var setters = _generateSetters(_createPropertiesMap(ngDeps));
var setters = _generateSetters(_createInputPropertiesMap(ngDeps));
ngDeps.registeredTypes.forEach((t) {
final fromAnnotation = new _ExtractQueryFieldsFromAnnotation();
@ -99,7 +99,7 @@ Future<String> createNgSettersAndGetters(
// TODO(kegluneq): De-dupe from template_compiler/generator.dart, #3589.
/// Consumes the map generated by {@link _createPropertiesMap} to codegen
/// Consumes the map generated by {@link _createInputPropertiesMap} to codegen
/// setters.
List<String> _generateSetters(Map<String, String> bindMap) {
var setters = [];
@ -116,18 +116,18 @@ List<String> _generateSetters(Map<String, String> bindMap) {
return setters;
}
/// Collapses all `properties` in {@link ngDeps} into a map where the keys are
/// the bind properties and the values are either the one and only type
/// Collapses all `inputs` in {@link ngDeps} into a map where the keys are
/// the bind inputs 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');
Map<String, String> _createInputPropertiesMap(NgDeps ngDeps) {
var visitor = new ExtractNamedExpressionVisitor('inputs');
var bindMap = {};
ngDeps.registeredTypes.forEach((RegisteredType t) {
visitor.bindConfig.clear();
t.annotations.accept(visitor);
visitor.bindConfig.forEach((String config) {
// See comments for `Directive` in annotations_impl/annotations.ts for
// details on how `properties` is specified.
// details on how `inputs` is specified.
var prop;
var idx = config.indexOf(':');
if (idx > 0) {

View File

@ -137,8 +137,8 @@ class _DirectiveMetadataVisitor extends Object
String _selector;
String _exportAs;
ChangeDetectionStrategy _changeDetection;
List<String> _properties;
List<String> _events;
List<String> _inputs;
List<String> _outputs;
Map<String, String> _host;
List<LifecycleHooks> _lifecycleHooks;
CompileTemplateMetadata _template;
@ -153,8 +153,8 @@ class _DirectiveMetadataVisitor extends Object
_selector = '';
_exportAs = null;
_changeDetection = ChangeDetectionStrategy.Default;
_properties = <String>[];
_events = <String>[];
_inputs = <String>[];
_outputs = <String>[];
_host = <String, String>{};
_lifecycleHooks = null;
_template = null;
@ -169,8 +169,8 @@ class _DirectiveMetadataVisitor extends Object
selector: _selector,
exportAs: _exportAs,
changeDetection: _changeDetection,
properties: _properties,
events: _events,
inputs: _inputs,
outputs: _outputs,
host: _host,
lifecycleHooks: _lifecycleHooks,
template: _template);
@ -232,7 +232,7 @@ class _DirectiveMetadataVisitor extends Object
case 'selector':
_populateSelector(node.expression);
break;
case 'properties':
case 'inputs':
_populateProperties(node.expression);
break;
case 'host':
@ -244,7 +244,7 @@ class _DirectiveMetadataVisitor extends Object
case 'changeDetection':
_populateChangeDetection(node.expression);
break;
case 'events':
case 'outputs':
_populateEvents(node.expression);
break;
}
@ -264,9 +264,9 @@ class _DirectiveMetadataVisitor extends Object
}
}
void _populateProperties(Expression propertiesValue) {
void _populateProperties(Expression inputsValue) {
_checkMeta();
_populateList(propertiesValue, _properties, 'Directive#properties');
_populateList(inputsValue, _inputs, 'Directive#inputs');
}
void _populateHost(Expression hostValue) {
@ -279,9 +279,9 @@ class _DirectiveMetadataVisitor extends Object
_exportAs = _expressionToString(exportAsValue, 'Directive#exportAs');
}
void _populateEvents(Expression eventsValue) {
void _populateEvents(Expression outputsValue) {
_checkMeta();
_populateList(eventsValue, _events, 'Directive#events');
_populateList(outputsValue, _outputs, 'Directive#outputs');
}
void _populateChangeDetection(Expression value) {

View File

@ -15,7 +15,7 @@ class Processor implements CodegenModel {
final Set<ReflectiveAccessor> methodNames = new Set<ReflectiveAccessor>();
void process(CompileDirectiveMetadata meta) {
meta.events.keys.forEach((eventName) {
meta.outputs.keys.forEach((eventName) {
getterNames.add(new ReflectiveAccessor(eventName));
});
}