fix(transformer): Put paramater data in the same order as the reflected version.
Previously it would be [@Inject(#thing), Thing], but it should be [Thing, @Inject(#thing)].
This commit is contained in:
parent
7986e7ce7e
commit
2b45bd2a63
|
@ -243,9 +243,7 @@ class CreateNgDepsVisitor extends Object with SimpleAstVisitor<Object> {
|
||||||
writer.print('..registerFunction(');
|
writer.print('..registerFunction(');
|
||||||
node.name.accept(this);
|
node.name.accept(this);
|
||||||
writer.print(''', {'parameters': const [''');
|
writer.print(''', {'parameters': const [''');
|
||||||
var parameters = node.childEntities
|
node.functionExpression.parameters.accept(_paramsVisitor);
|
||||||
.firstWhere((child) => child is FunctionExpression).parameters;
|
|
||||||
parameters.accept(_paramsVisitor);
|
|
||||||
writer.print('''], 'annotations': ''');
|
writer.print('''], 'annotations': ''');
|
||||||
node.metadata.accept(_metaVisitor);
|
node.metadata.accept(_metaVisitor);
|
||||||
writer.print('})');
|
writer.print('})');
|
||||||
|
|
|
@ -46,18 +46,9 @@ class _CtorTransformVisitor extends ToSourceVisitor {
|
||||||
/// `_withParameterNames` is true, this method outputs `node`'s identifier.
|
/// `_withParameterNames` is true, this method outputs `node`'s identifier.
|
||||||
Object _visitNormalFormalParameter(
|
Object _visitNormalFormalParameter(
|
||||||
NodeList<Annotation> metadata, TypeName type, SimpleIdentifier name) {
|
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;
|
var needCompileTimeConstants = !_withParameterNames;
|
||||||
if (_withParameterTypes && type != null) {
|
var needType = _withParameterTypes && type != null;
|
||||||
|
if (needType) {
|
||||||
_visitNodeWithSuffix(type.name, ' ');
|
_visitNodeWithSuffix(type.name, ' ');
|
||||||
if (!needCompileTimeConstants) {
|
if (!needCompileTimeConstants) {
|
||||||
// Types with arguments are not compile-time constants.
|
// Types with arguments are not compile-time constants.
|
||||||
|
@ -67,6 +58,15 @@ class _CtorTransformVisitor extends ToSourceVisitor {
|
||||||
if (_withParameterNames) {
|
if (_withParameterNames) {
|
||||||
_visitNode(name);
|
_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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ void initReflector(reflector) {
|
||||||
..registerType(SoupComponent, {
|
..registerType(SoupComponent, {
|
||||||
'factory':
|
'factory':
|
||||||
(String description, salt) => new SoupComponent(description, salt),
|
(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]')]
|
'annotations': const [const Component(selector: '[soup]')]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue