Java Code Examples for javax.annotation.processing.ProcessingEnvironment#getOptions()

The following examples show how to use javax.annotation.processing.ProcessingEnvironment#getOptions() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VenvyRouterBinderProcessor.java    From VideoOS-Android-SDK with GNU General Public License v3.0 6 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnvironment) {
    super.init(processingEnvironment);
    mElements = processingEnvironment.getElementUtils();
    mFiler = processingEnvironment.getFiler();
    mMessage = processingEnvironment.getMessager();
    if (mCurrentAnnotationMap == null) {
        mCurrentAnnotationMap = new HashMap<>();
    }
    Map<String, String> options = processingEnvironment.getOptions();
    if (options != null && options.size() > 0) {
        mModuleName = options.get("moduleName");
        if (null != mModuleName && !"".equals(mModuleName)) {
            mModuleName = mModuleName.replaceAll("[^0-9a-zA-Z_]+", "");
        }
    }
}
 
Example 2
Source File: RouterProcessor.java    From YCApt with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化方法
 * @param processingEnvironment                 获取信息
 */
@Override
public synchronized void init(ProcessingEnvironment processingEnvironment) {
    super.init(processingEnvironment);
    //节点工具类 (类、函数、属性都是节点)
    elementUtils = processingEnvironment.getElementUtils();
    //文件生成器 类/资源
    filer = processingEnvironment.getFiler();
    Messager messager = processingEnvironment.getMessager();
    log = RouterLog.newLog(messager);
    Map<String, String> options = processingEnvironment.getOptions();
    //type(类信息)工具类
    typeUtils = processingEnvironment.getTypeUtils();

    //参数是模块名 为了防止多模块/组件化开发的时候 生成相同的编译文件 xx$$ROOT$$文件
    if (!RouterUtils.isEmpty(options)) {
        moduleName = options.get(RouterConstants.ARGUMENTS_NAME);
    }
    if (RouterUtils.isEmpty(moduleName)) {
        throw new EmptyException("RouterProcessor Not set processor moduleName option !");
    }
    log.i("RouterProcessor init RouterProcessor " + moduleName + " success !");
}
 
Example 3
Source File: ComponentProcessor.java    From dagger2-sample with Apache License 2.0 6 votes vote down vote up
private static ValidationType validationTypeFor(ProcessingEnvironment processingEnv, String key,
    ValidationType defaultValue, Set<ValidationType> validValues) {
  Map<String, String> options = processingEnv.getOptions();
  if (options.containsKey(key)) {
    try {
      ValidationType type = ValidationType.valueOf(options.get(key).toUpperCase());
      if (!validValues.contains(type)) {
        throw new IllegalArgumentException(); // let handler below print out good msg.
      }
      return type;
    } catch (IllegalArgumentException e) {
      processingEnv.getMessager().printMessage(ERROR, "Processor option -A"
          + key + " may only have the values " + validValues
          + " (case insensitive), found: " + options.get(key));
    }
  }
  return defaultValue;
}
 
Example 4
Source File: ProcessorContextFactory.java    From jackdaw with Apache License 2.0 6 votes vote down vote up
public static ProcessorContext create(final ProcessingEnvironment env) {
    final Map<String, String> options = env.getOptions();

    return new ProcessorContext(env)
        .setAddSuppressWarningsAnnotation(
            getBool(
                options,
                OPT_ADD_SUPPRESS_WARNINGS_ANNOTATION,
                DEF_ADD_SUPPRESS_WARNINGS_ANNOTATION
            )
        )
        .setAddGeneratedAnnotation(
            getBool(options, OPT_ADD_GENERATED_ANNOTATION, DEF_ADD_GENERATED_ANNOTATION)
        )
        .setAddGeneratedDate(
            getBool(options, OPT_ADD_GENERATED_DATE, DEF_ADD_GENERATED_DATE)
        );
}
 
Example 5
Source File: RouterProcessor.java    From DDComponentForAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);

    routerNodes = new ArrayList<>();

    mFiler = processingEnv.getFiler();
    types = processingEnv.getTypeUtils();
    elements = processingEnv.getElementUtils();
    typeUtils = new TypeUtils(types, elements);

    type_String = elements.getTypeElement("java.lang.String").asType();

    logger = new Logger(processingEnv.getMessager());

    Map<String, String> options = processingEnv.getOptions();
    if (MapUtils.isNotEmpty(options)) {
        host = options.get(KEY_HOST_NAME);
        logger.info(">>> host is " + host + " <<<");
    }
    if (host == null || host.equals("")) {
        host = "default";
    }
    logger.info(">>> RouteProcessor init. <<<");
}
 
Example 6
Source File: RouterProcessor.java    From grouter-android with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    elementUtils = processingEnv.getElementUtils();
    this.messagerUtils = processingEnv.getMessager();
    Map<String, String> map = processingEnv.getOptions();
    Set<String> keys = map.keySet();

    for (String key : keys) {
        if ("MODULE_NAME".equals(key)) {
            this.MODULE_NAME = map.get(key);
        }
        if ("GROUTER_SOURCE_PATH".equals(key)) {
            this.GROUTER_SOURCE_PATH = map.get(key);
        }
        if ("GROUTER_SCHEME".equals(key)) {
            this.GROUTER_SCHEME = map.get(key);
        }
        if ("GROUTER_MULTI_PROJECT_NAME".equals(key)) {
            this.GROUTER_MULTI_PROJECT_NAME = map.get(key);
        }
        if ("ROOT_PROJECT_DIR".equals(key)) {
            this.ROOT_PROJECT_DIR = map.get(key);
        }
    }
}
 
Example 7
Source File: AutowireProcessor.java    From MRouter with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnvironment) {
    super.init(processingEnvironment);

    types = processingEnv.getTypeUtils();            // Get type utils.
    elements = processingEnv.getElementUtils();      // Get class meta.
    filter = processingEnvironment.getFiler();
    messager = processingEnvironment.getMessager();
    processingEnvironment.getOptions();
    Map<String, String> options = processingEnv.getOptions();
    if (options != null && !options.isEmpty()) {
        moduleName = options.get(Constant.KEY_MODULE_NAME);
        if (moduleName != null && moduleName.length() > 0) {
            moduleName = ProcessorUtils.filterModuleName(moduleName);
        }
    }
}
 
Example 8
Source File: RabbitsCompiler.java    From Rabbits with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    mFiler = processingEnv.getFiler();

    Elements elements = processingEnv.getElementUtils();
    types = processingEnv.getTypeUtils();

    activityType = elements.getTypeElement("android.app.Activity").asType();
    fragmentType = elements.getTypeElement("android.app.Fragment").asType();
    fragmentV4Type = elements.getTypeElement("android.support.v4.app.Fragment").asType();

    Map<String, String> options = processingEnv.getOptions();
    if (options != null && options.size() > 0) {
        mModuleName = options.get(OPTION_MODULE_NAME);
        String subModuleNames = options.get(OPTION_SUB_MODULES);
        if (subModuleNames != null && subModuleNames.length() > 0) {
            String[] names = subModuleNames.split(",");
            if (names.length > 0) {
                mSubModules = Arrays.asList(names);
            }
        }
    }
}
 
Example 9
Source File: FlapProcessor.java    From Flap with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void init(final ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    filer = processingEnv.getFiler();               // Generate class.
    types = processingEnv.getTypeUtils();            // Get type utils.
    elements = processingEnv.getElementUtils();      // Get class meta.
    messager = processingEnv.getMessager();
    messager.printMessage(Diagnostic.Kind.NOTE, "FlapProcessor init");

    Map<String, String> options = processingEnv.getOptions();
    if (options.containsKey(KEY_OPTION_AUTO_REGISTER)) {
        autoRegisterFactories = Boolean.parseBoolean(options.get(KEY_OPTION_AUTO_REGISTER));
    }
}
 
Example 10
Source File: AkatsukiProcessor.java    From Akatsuki with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
	super.init(processingEnv);
	processingEnv.getMessager().printMessage(Kind.NOTE, "Processor started");
	this.context = new ProcessorContext(processingEnv);
	Log.verbose(context, "Processor context created...");
	Map<String, String> options = processingEnv.getOptions();
	if (options != null && !options.isEmpty()) {
		this.options = options;
		Log.verbose(context, "Options received: " + options);
	}

}
 
Example 11
Source File: ModuleServiceProcessor.java    From FriendCircle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnvironment) {
    super.init(processingEnvironment);

    Map<String, String> options = processingEnvironment.getOptions();
    if (options == null || options.isEmpty()) return;
    moduleName = options.get(KEY_MODULE_NAME);
}
 
Example 12
Source File: MvpCompiler.java    From Moxy with MIT License 5 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
	super.init(processingEnv);

	sMessager = processingEnv.getMessager();
	sTypeUtils = processingEnv.getTypeUtils();
	sElementUtils = processingEnv.getElementUtils();
	sOptions = processingEnv.getOptions();
}
 
Example 13
Source File: InterceptorProcessor.java    From EasyRouter with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    elementUtils = processingEnv.getElementUtils();
    mMessager = processingEnv.getMessager();
    mFiler = processingEnv.getFiler();
    Map<String, String> options = processingEnv.getOptions();
    if (MapUtils.isNotEmpty(options)) {
        moduleName = options.get(CompilerConstant.KEY_MODULE_NAME);
    }
}
 
Example 14
Source File: DispatcherProcessor.java    From EasyRouter with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    mMessager = processingEnv.getMessager();
    mFiler = processingEnv.getFiler();
    elementUtils = processingEnv.getElementUtils();
    set = new HashSet<String>();

    Map<String, String> options = processingEnv.getOptions();
    if (MapUtils.isNotEmpty(options)) {
        moduleName = options.get(CompilerConstant.KEY_MODULE_NAME);
        set.add(moduleName);
    }
}
 
Example 15
Source File: XModuleProcessor.java    From XModulable with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnvironment) {
    super.init(processingEnvironment);
    mLogger = new Logger(processingEnvironment.getMessager());
    mElementUtils = processingEnvironment.getElementUtils();
    mFiler = processingEnvironment.getFiler();

    Map<String, String> options = processingEnvironment.getOptions();
    if (options != null && !options.isEmpty()) {
        mModuleName = options.get(Constants.KEY_XMODULE);
    }
    if (mModuleName != null && !mModuleName.isEmpty()) {
        mModuleName = mModuleName.replaceAll("[^0-9a-zA-Z_]+", "");
        mLogger.info("The user has configuration the XModule, it was [" + mModuleName + "]");
    } else {
        mLogger.error("These no XModule, at 'build.gradle', like :\n" +
                "javaCompileOptions {\n" +
                "            annotationProcessorOptions {\n" +
                "                arguments = [\n" +
                "                        XModule   : moduleName\n" +
                "                ]\n" +
                "            }\n" +
                "        }");
        throw new RuntimeException(Constants.PREFIX_OF_LOGGER + "No XModule, for more information, look at gradle log.");
    }

    mXModuleLoader = mElementUtils.getTypeElement(Constants.XMODULE_LOADER);
}
 
Example 16
Source File: AbstractComponentsProcessor.java    From litho with Apache License 2.0 5 votes vote down vote up
@Override
public void init(ProcessingEnvironment processingEnv) {
  super.init(processingEnv);

  Map<String, String> options = processingEnv.getOptions();
  boolean isGeneratingAbi =
      Boolean.valueOf(options.getOrDefault("com.facebook.buck.java.generating_abi", "false"));
  if (isGeneratingAbi) {
    mRunMode.add(RunMode.ABI);
  }
  if (Boolean.parseBoolean(options.getOrDefault("com.facebook.litho.testing", "false"))) {
    mRunMode.add(RunMode.TESTING);
  }
}
 
Example 17
Source File: NoOpProcessor.java    From compile-testing with Apache License 2.0 4 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
  super.init(processingEnv);
  options = processingEnv.getOptions();
}
 
Example 18
Source File: OptionsHelper.java    From ngAndroid with Apache License 2.0 4 votes vote down vote up
@Inject
public OptionsHelper(ProcessingEnvironment processingEnvironment) {
	options = processingEnvironment.getOptions();
}
 
Example 19
Source File: ModelSpecProcessor.java    From squidb with Apache License 2.0 4 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment env) {
    super.init(env);
    utils = new AptUtils(env);
    pluginEnv = new PluginEnvironment(utils, env.getOptions());
}
 
Example 20
Source File: Options.java    From doma with Apache License 2.0 4 votes vote down vote up
Options(Context ctx, ProcessingEnvironment env) {
  assertNotNull(ctx, env);
  this.ctx = ctx;
  this.options = env.getOptions();
}