mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-24 05:25:19 +00:00
fix: fix module generator
This commit is contained in:
@@ -59,7 +59,6 @@ class ModuleGenerator extends GeneratorForAnnotation<ann.module> {
|
|||||||
|
|
||||||
// ЗДЕСЬ ЛОГИКА ДЛЯ ПАРАМЕТРОВ МЕТОДА
|
// ЗДЕСЬ ЛОГИКА ДЛЯ ПАРАМЕТРОВ МЕТОДА
|
||||||
final args = method.parameters.map((p) {
|
final args = method.parameters.map((p) {
|
||||||
// Ищем @named у параметра
|
|
||||||
ElementAnnotation? paramNamed;
|
ElementAnnotation? paramNamed;
|
||||||
try {
|
try {
|
||||||
paramNamed = p.metadata.firstWhere(
|
paramNamed = p.metadata.firstWhere(
|
||||||
@@ -75,17 +74,23 @@ class ModuleGenerator extends GeneratorForAnnotation<ann.module> {
|
|||||||
} catch (_) {
|
} catch (_) {
|
||||||
paramNamed = null;
|
paramNamed = null;
|
||||||
}
|
}
|
||||||
String namedArg = '';
|
|
||||||
|
String argExpr;
|
||||||
if (paramNamed != null) {
|
if (paramNamed != null) {
|
||||||
final cv = paramNamed.computeConstantValue();
|
final cv = paramNamed.computeConstantValue();
|
||||||
if (cv != null) {
|
final namedValue = cv?.getField('value')?.toStringValue();
|
||||||
final namedValue = cv.getField('value')?.toStringValue();
|
|
||||||
if (namedValue != null) {
|
if (namedValue != null) {
|
||||||
namedArg = "(named: '$namedValue')";
|
argExpr =
|
||||||
|
"currentScope.resolve<${p.type.getDisplayString(withNullability: false)}>(named: '$namedValue')";
|
||||||
|
} else {
|
||||||
|
argExpr =
|
||||||
|
"currentScope.resolve<${p.type.getDisplayString(withNullability: false)}>()";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
argExpr =
|
||||||
|
"currentScope.resolve<${p.type.getDisplayString(withNullability: false)}>()";
|
||||||
}
|
}
|
||||||
}
|
return argExpr;
|
||||||
return "currentScope.resolve<${p.type.getDisplayString(withNullability: false)}>$namedArg";
|
|
||||||
}).join(', ');
|
}).join(', ');
|
||||||
|
|
||||||
final returnType =
|
final returnType =
|
||||||
|
|||||||
Reference in New Issue
Block a user