chore(transfomer): code style in rewriter
This commit is contained in:
parent
29095766e6
commit
4893002408
|
@ -128,7 +128,8 @@ class _RewriterVisitor extends Object with RecursiveAstVisitor<Object> {
|
||||||
var args = node.argumentList.arguments;
|
var args = node.argumentList.arguments;
|
||||||
int numArgs = node.argumentList.arguments.length;
|
int numArgs = node.argumentList.arguments.length;
|
||||||
if (numArgs < 1 || numArgs > 2) {
|
if (numArgs < 1 || numArgs > 2) {
|
||||||
logger.warning('`bootstrap` does not support $numArgs arguments. Found bootstrap${node.argumentList}. Transform may not succeed.');
|
logger.warning('`bootstrap` does not support $numArgs arguments. '
|
||||||
|
'Found bootstrap${node.argumentList}. Transform may not succeed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
var reflectorInit = _setupAdded
|
var reflectorInit = _setupAdded
|
||||||
|
@ -136,17 +137,20 @@ class _RewriterVisitor extends Object with RecursiveAstVisitor<Object> {
|
||||||
: ', () { ${_getStaticReflectorInitBlock()} }';
|
: ', () { ${_getStaticReflectorInitBlock()} }';
|
||||||
|
|
||||||
// rewrite `bootstrap(...)` to `bootstrapStatic(...)`
|
// rewrite `bootstrap(...)` to `bootstrapStatic(...)`
|
||||||
buf.write('bootstrapStatic(');
|
buf.write('bootstrapStatic(${args[0]}');
|
||||||
buf.write(args[0]);
|
|
||||||
if (numArgs == 1) {
|
if (numArgs == 1) {
|
||||||
|
// bootstrap args are positional, so before we pass reflectorInit code
|
||||||
|
// we need to pass `null` for DI bindings.
|
||||||
if (reflectorInit.isNotEmpty) {
|
if (reflectorInit.isNotEmpty) {
|
||||||
buf.write(', null');
|
buf.write(', null');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// pass DI bindings
|
||||||
buf.write(', ${args[1]}');
|
buf.write(', ${args[1]}');
|
||||||
}
|
}
|
||||||
buf.write(reflectorInit);
|
buf.write(reflectorInit);
|
||||||
buf.write(')');
|
buf.write(')');
|
||||||
|
_setupAdded = true;
|
||||||
} else {
|
} else {
|
||||||
// leave it as is
|
// leave it as is
|
||||||
buf.write(_rewriter._code.substring(_currentIndex, node.end));
|
buf.write(_rewriter._code.substring(_currentIndex, node.end));
|
||||||
|
|
Loading…
Reference in New Issue