All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.miracles.compiler.AnnotationProcessor Maven / Gradle / Ivy

The newest version!
package com.miracles.compiler;

import com.google.auto.service.AutoService;
import com.miracles.annotations.UpgradeInstance;
import com.miracles.compiler.processor.UpgradeProcessor;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Filer;
import javax.annotation.processing.Messager;
import javax.annotation.processing.Processor;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;

/**
 * Created by lxw
 */
@AutoService(Processor.class)
public class AnnotationProcessor extends AbstractProcessor {
    public Filer mFiler; //文件相关的辅助类
    public Elements mElements; //元素相关的辅助类
    public Messager mMessager; //日志相关的辅助类
    public Types mTypes;
    public Map options;

    @Override
    public boolean process(Set annotations, RoundEnvironment roundEnv) {
        mFiler = processingEnv.getFiler();
        mElements = processingEnv.getElementUtils();
        mMessager = processingEnv.getMessager();
        mTypes = processingEnv.getTypeUtils();
        options = processingEnv.getOptions();
        new UpgradeProcessor().process(roundEnv, this);
        return true;
    }

    @Override
    public Set getSupportedAnnotationTypes() {
        Set types = new HashSet<>();
        types.add(UpgradeInstance.class.getCanonicalName());
        return types;
    }

    @Override
    public SourceVersion getSupportedSourceVersion() {
        return SourceVersion.latest();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy