ServiceAutoScan class

服务扫描代码生成器

基于@AutoScan注解的include、exclude、annotations配置,扫描所有@Service标注的类, 生成自动注册和依赖注入逻辑作为被标注类的part文件

Constructors

ServiceAutoScan({bool debug = false})

Properties

debug bool
finalinherited
hashCode int
The hash code for this object.
no setterinherited
inPackage String?
Annotation package for TypeChecker.typeNamed.
finalinherited
inSdk bool?
Annotation package type for TypeChecker.typeNamed.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
throwOnUnresolved bool
finalinherited
typeChecker → TypeChecker
no setterinherited

Methods

genAddImport(List<ServiceInfo> services, Element element, ConstantReader annotation, BuildStep buildStep, List<Directive> imports) → void
inherited
genClassExtend(String className, List<Method> methods, List<Directive> imports) Object
生成Class或Extension对象
genClassFile(List<ServiceInfo> services, Element element, ConstantReader annotation, BuildStep buildStep) String
步骤3:生成Class文件
inherited
generate(LibraryReader library, BuildStep buildStep) FutureOr<String>
Generates Dart code for an input Dart library.
inherited
generateForAnnotatedDirective(ElementDirective directive, ConstantReader annotation, BuildStep buildStep) → dynamic
Implement to return source code to generate for directive:
inherited
generateForAnnotatedElement(Element element, ConstantReader annotation, BuildStep buildStep) FutureOr<String>
步骤1:读取@AutoScan注解参数
inherited
genImport(List<ServiceInfo> services, Element element, ConstantReader annotation, BuildStep buildStep) List<Directive>
4个子方法:生成导入语句
inherited
genInject(List<ServiceInfo> services, Element element, ConstantReader annotation, BuildStep buildStep, List<Directive> imports) → Method
统一的注入方法
inherited
genInjectBody(List<ServiceInfo> services, Element element, ConstantReader annotation, BuildStep buildStep, List<Directive> imports) String
生成注入方法的方法体
genRegister(List<ServiceInfo> services, Element element, ConstantReader annotation, BuildStep buildStep, List<Directive> imports) → Method
统一的注册方法
inherited
genRegisterBody(List<ServiceInfo> services, Element element, ConstantReader annotation, BuildStep buildStep, List<Directive> imports) String
生成注册方法的方法体
getAdditionalImports(ServiceInfo service, String relativePath, Element element, ConstantReader annotation, BuildStep buildStep) List<String>
获取特定服务的额外导入路径
isExcluded(String filePath, List<String> excludePatterns) bool
检查文件路径是否被exclude模式排除
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
process(ClassElement element, ConstantReader annotation, BuildStep buildStep) List<ServiceInfo>
处理单个ClassElement,返回对应的服务信息对象列表
scanAndProcess(BuildStep buildStep, List<String> includePatterns, List<String> excludePatterns, List<TypeChecker> typeCheckers) Future<List<ServiceInfo>>
步骤2:根据annotations扫描符合条件的文件并处理
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited