7.基于Dagger2.38.1的hilt源码-@DisableInstallInCheck、@EarlyEntryPoint、@GeneratesRootInput和@OriginatingElem

源码很短

IncrementalAnnotationProcessor

IncrementalAnnotationProcessor校验使用@DisableInstallInCheck注解的节点必须使用@Module注解。

就这么一句话,完了!!!

EarlyEntryPointProcessor

EarlyEntryPointProcessor类处理使用@EarlyEntryPoint注解的earlyEntryPoint节点生成类;

可以先回顾一下AggregatedDepsProcessor。

生成的类在dagger.hilt.android.internal.earlyentrypoint.codegen包下:

//This class should only be referenced by generated code!
//This class aggregates information across multiple compilations.
@AggregatedEarlyEntryPoint(earlyEntryPoint = earlyEntryPoint节点名)
@Generated("AggregatedEarlyEntryPointGenerator")
public class earlyEntryPoint节点全路径以"_"拼接{
}

OriginatingElementProcessor

该类用于校验@OriginatingElement注解,规则如下:

  1. @OriginatingElement修饰的节点必须是顶级类或接口,顶级-表示再上一级就是包了;

  2. OriginatingElement#topLevelClass中的节点也必须是顶级类或接口。

GeneratesRootInputProcessor

使用@GeneratesRootInput修饰的注解生成@GeneratesRootInputPropagatedData修饰的节点。也是以源码中的代码为例:

在这里插入图片描述

在这里插入图片描述

但是这里的@GeneratesRootInputPropagatedData修饰的节点并没有做进一步处理。反正我从源码中没有找到进一步的处理代码!!!

UninstallModulesProcessor

处理@UninstallModules注解。当前注解用于测试。

校验规则:

  1. @UninstallModules修饰的节点必须是类或接口,还必须同时使用@HiltAndroidTest修饰;

  2. @UninstallModules#value里面的节点必须使用@Module 和 @InstallIn 同时修饰;

  3. @UninstallModules#value中的节点所在顶级节点(当前节点如果在上面是包,那么当前节点就是顶级节点)不允许使用@HiltAndroidTest修饰;

生成的类在dagger.hilt.android.internal.uninstallmodules.codegen包下:

//This class should only be referenced by generated code!This class aggregates information across multiple compilations.
@AggregatedUninstallModules(test = $Class名,uninstallModules = @UninstallModules#value中的节点名称)
@Generated("AggregatedUninstallModulesGenerator")
public class 包"_"拼接$Class{}

总结

到这里为止说的还都是比较零散的东西。都是一次处理、二次处理乃至三次处理。我们继续往下看。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值