resolveModuleMember method
DependencyConfig
resolveModuleMember(
- ClassElement moduleClazz,
- ExecutableElement executableElement
Implementation
DependencyConfig resolveModuleMember(
ClassElement moduleClazz,
ExecutableElement executableElement,
) {
var moduleType = _typeResolver.resolveType(moduleClazz.thisType);
var initializerName = executableElement.name;
var isAbstract = false;
final returnType = executableElement.returnType;
throwIf(
returnType.element2 is! ClassElement,
'${returnType.getDisplayString(withNullability: false)} is not a class element',
element: returnType.element2,
);
Element? clazz;
var type = returnType;
if (executableElement.isAbstract) {
clazz = returnType.element2;
isAbstract = true;
throwIf(
executableElement.parameters.isNotEmpty,
'Abstract methods can not have injectable or factory parameters',
element: executableElement,
);
} else {
if (returnType.isDartAsyncFuture) {
final typeArg = returnType as ParameterizedType;
clazz = typeArg.typeArguments.first.element2;
type = typeArg.typeArguments.first;
} else {
clazz = returnType.element2;
}
}
this._moduleConfig = ModuleConfig(
isAbstract: isAbstract,
isMethod: executableElement is MethodElement,
type: moduleType,
initializerName: initializerName,
);
this._type = _typeResolver.resolveType(type);
return _resolveActualType(clazz as ClassElement, executableElement);
}