Пример #1
0
  public ComponentDescriptor analyze(ASTType astType) {
    Application applicationAnnotation = astType.getAnnotation(Application.class);

    PackageClass inputType = astType.getPackageClass();
    PackageClass applicationClassName;

    if (StringUtils.isBlank(applicationAnnotation.name())) {
      applicationClassName = inputType.append("Application");
    } else {
      applicationClassName = inputType.replaceName(applicationAnnotation.name());
    }

    ComponentDescriptor applicationDescriptor =
        new ComponentDescriptor(android.app.Application.class.getName(), applicationClassName);

    // analyze delegate
    AnalysisContext analysisContext =
        analysisContextFactory.buildAnalysisContext(buildVariableBuilderMap());

    // application generation profile
    setupApplicationProfile(applicationDescriptor, astType, analysisContext);

    // add manifest elements
    setupManifest(
        applicationAnnotation,
        applicationDescriptor.getPackageClass().getFullyQualifiedName(),
        applicationAnnotation.label());

    return applicationDescriptor;
  }
  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));
    }
  }