Exemplo n.º 1
0
  private InjectionNodeBuilderRepository buildVariableBuilderMap() {
    InjectionNodeBuilderRepository injectionNodeBuilderRepository =
        injectionNodeBuilderRepositoryProvider.get();

    injectionNodeBuilderRepository.putType(
        Context.class, injectionBindingBuilder.buildThis(Context.class));
    injectionNodeBuilderRepository.putType(
        android.app.Application.class,
        injectionBindingBuilder.buildThis((android.app.Application.class)));
    injectionNodeBuilderRepository.putType(
        ContextScopeHolder.class, injectionBindingBuilder.buildThis(ContextScopeHolder.class));

    variableBuilderRepositoryFactory.addApplicationInjections(injectionNodeBuilderRepository);

    variableBuilderRepositoryFactory.addModuleConfiguration(injectionNodeBuilderRepository);

    return injectionNodeBuilderRepository;
  }
  public void processType(ASTType astType) {
    ImplementedBy annotation = astType.getAnnotation(ImplementedBy.class);

    if (annotation != null) {
      TypeMirror implementedClass =
          getTypeMirror(new ImplementedByClassTypeMirrorRunnable(annotation));

      ASTType implAstType = implementedClass.accept(astTypeBuilderVisitor, null);

      if (!implAstType.inheritsFrom(astType)) {
        throw new TransfuseAnalysisException(
            "ImplementedBy configuration points to a class that doesn't inherit from the given base class");
      }

      injectionNodeBuilders.putModuleConfig(
          astType, variableInjectionBuilderFactory.buildVariableInjectionNodeBuilder(implAstType));
    }
  }
Exemplo n.º 3
0
 @Inject
 public InjectorGenerator(
     JCodeModel codeModel,
     InjectionFragmentGenerator injectionFragmentGenerator,
     ComponentBuilderFactory componentBuilderFactory,
     AnalysisContextFactory analysisContextFactory,
     InjectionNodeBuilderRepository injectionNodeBuilderRepository,
     InjectionNodeBuilderRepositoryFactory injectionNodeBuilderRepositoryFactory,
     InjectorRepositoryGenerator injectorRepositoryGenerator) {
   this.codeModel = codeModel;
   this.injectionFragmentGenerator = injectionFragmentGenerator;
   this.componentBuilderFactory = componentBuilderFactory;
   this.analysisContextFactory = analysisContextFactory;
   this.injectionNodeBuilderRepository = injectionNodeBuilderRepository;
   this.injectorRepositoryGenerator = injectorRepositoryGenerator;
   injectionNodeBuilderRepositoryFactory.addModuleConfiguration(
       this.injectionNodeBuilderRepository);
 }