Skip to content

Commit

Permalink
fix(transformer): Put paramater data in the same order as the reflect…
Browse files Browse the repository at this point in the history
…ed version.

Previously it would be [@Inject(#thing), Thing], but it should be [Thing, @Inject(#thing)].
  • Loading branch information
jakemac53 committed Jul 6, 2015
1 parent 7986e7c commit 2b45bd2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ class CreateNgDepsVisitor extends Object with SimpleAstVisitor<Object> {
writer.print('..registerFunction(');
node.name.accept(this);
writer.print(''', {'parameters': const [''');
var parameters = node.childEntities
.firstWhere((child) => child is FunctionExpression).parameters;
parameters.accept(_paramsVisitor);
node.functionExpression.parameters.accept(_paramsVisitor);
writer.print('''], 'annotations': ''');
node.metadata.accept(_metaVisitor);
writer.print('})');
Expand Down
22 changes: 11 additions & 11 deletions modules/angular2/src/transform/directive_processor/visitors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,9 @@ class _CtorTransformVisitor extends ToSourceVisitor {
/// `_withParameterNames` is true, this method outputs `node`'s identifier.
Object _visitNormalFormalParameter(
NodeList<Annotation> metadata, TypeName type, SimpleIdentifier name) {
if (_withParameterAnnotations && metadata != null) {
assert(_withParameterTypes);
for (var i = 0, iLen = metadata.length; i < iLen; ++i) {
if (i != 0) {
writer.print(', ');
}
metadata[i].accept(this);
}
writer.print(type != null && metadata.isNotEmpty ? ', ' : '');
}
var needCompileTimeConstants = !_withParameterNames;
if (_withParameterTypes && type != null) {
var needType = _withParameterTypes && type != null;
if (needType) {
_visitNodeWithSuffix(type.name, ' ');
if (!needCompileTimeConstants) {
// Types with arguments are not compile-time constants.
Expand All @@ -67,6 +58,15 @@ class _CtorTransformVisitor extends ToSourceVisitor {
if (_withParameterNames) {
_visitNode(name);
}
if (_withParameterAnnotations && metadata != null) {
assert(_withParameterTypes);
for (var i = 0, iLen = metadata.length; i < iLen; ++i) {
if (i != 0 || needType) {
writer.print(', ');
}
metadata[i].accept(this);
}
}
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void initReflector(reflector) {
..registerType(SoupComponent, {
'factory':
(String description, salt) => new SoupComponent(description, salt),
'parameters': const [const [Tasty, String], const [const Inject(Salt)]],
'parameters': const [const [String, Tasty], const [const Inject(Salt)]],
'annotations': const [const Component(selector: '[soup]')]
});
}

0 comments on commit 2b45bd2

Please sign in to comment.