Search in sources :

Example 11 with JavacProcessingEnvironment

use of com.sun.tools.javac.processing.JavacProcessingEnvironment in project antlr4 by antlr.

the class CommentHasStringValueProcessor method init.

@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    //		Messager messager = processingEnv.getMessager();
    //		messager.printMessage(Diagnostic.Kind.NOTE, "WOW INIT--------------------");
    JavacProcessingEnvironment javacProcessingEnv = (JavacProcessingEnvironment) processingEnv;
    utilities = javacProcessingEnv.getElementUtils();
    treeMaker = TreeMaker.instance(javacProcessingEnv.getContext());
}
Also used : JavacProcessingEnvironment(com.sun.tools.javac.processing.JavacProcessingEnvironment)

Example 12 with JavacProcessingEnvironment

use of com.sun.tools.javac.processing.JavacProcessingEnvironment in project ceylon-compiler by ceylon.

the class T7021650 method process.

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    round++;
    Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
    // verify items in context as expected
    check("Demo", Demo.instance(context), Demo.class);
    check("Attr", Attr.instance(context), MyAttr.class);
    // values in the context are correctly handled in subsequent processing rounds
    if (round <= MAX_ROUNDS) {
        String pkg = "p";
        String currClass = "Gen" + round;
        String curr = pkg + "." + currClass;
        String next = (pkg + ".Gen" + (round + 1));
        StringBuilder text = new StringBuilder();
        text.append("package ").append(pkg).append(";\n");
        text.append("public class ").append(currClass).append(" {\n");
        if (round < MAX_ROUNDS)
            text.append("    ").append(next).append(" x;\n");
        text.append("}\n");
        try {
            JavaFileObject fo = filer.createSourceFile(curr);
            Writer out = fo.openWriter();
            try {
                out.write(text.toString());
            } finally {
                out.close();
            }
        } catch (IOException e) {
            throw new Error(e);
        }
    }
    return true;
}
Also used : Context(com.sun.tools.javac.util.Context) JavacProcessingEnvironment(com.sun.tools.javac.processing.JavacProcessingEnvironment)

Example 13 with JavacProcessingEnvironment

use of com.sun.tools.javac.processing.JavacProcessingEnvironment in project ceylon-compiler by ceylon.

the class T6597678 method process.

//---------------
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
    Locale locale = context.get(Locale.class);
    JavacMessages messages = context.get(JavacMessages.messagesKey);
    round++;
    if (round == 1) {
        initialLocale = locale;
        initialMessages = messages;
    } else {
        checkEqual("locale", locale, initialLocale);
        checkEqual("messages", messages, initialMessages);
    }
    return true;
}
Also used : Context(com.sun.tools.javac.util.Context) JavacProcessingEnvironment(com.sun.tools.javac.processing.JavacProcessingEnvironment) JavacMessages(com.sun.tools.javac.util.JavacMessages)

Example 14 with JavacProcessingEnvironment

use of com.sun.tools.javac.processing.JavacProcessingEnvironment in project ceylon-compiler by ceylon.

the class T7018098 method process.

//---------------
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
    FSInfo fsInfo = context.get(FSInfo.class);
    round++;
    if (round == 1) {
        boolean expect = Boolean.valueOf(options.get("expect"));
        checkEqual("cache result", fsInfo.isDirectory(testDir), expect);
        initialFSInfo = fsInfo;
    } else {
        checkEqual("fsInfo", fsInfo, initialFSInfo);
    }
    return true;
}
Also used : Context(com.sun.tools.javac.util.Context) JavacProcessingEnvironment(com.sun.tools.javac.processing.JavacProcessingEnvironment) FSInfo(com.sun.tools.javac.file.FSInfo)

Example 15 with JavacProcessingEnvironment

use of com.sun.tools.javac.processing.JavacProcessingEnvironment in project ceylon-compiler by ceylon.

the class TestContext method process.

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    round++;
    JavacProcessingEnvironment jpe = (JavacProcessingEnvironment) processingEnv;
    Context c = jpe.getContext();
    check(c.get(JavacElements.class), eltUtils);
    check(c.get(JavacTypes.class), typeUtils);
    check(c.get(JavacTrees.class), treeUtils);
    final int MAXROUNDS = 3;
    if (round < MAXROUNDS)
        generateSource("Gen" + round);
    return true;
}
Also used : Context(com.sun.tools.javac.util.Context) JavacTypes(com.sun.tools.javac.model.JavacTypes) JavacTrees(com.sun.tools.javac.api.JavacTrees) JavacElements(com.sun.tools.javac.model.JavacElements) JavacProcessingEnvironment(com.sun.tools.javac.processing.JavacProcessingEnvironment)

Aggregations

JavacProcessingEnvironment (com.sun.tools.javac.processing.JavacProcessingEnvironment)16 Context (com.sun.tools.javac.util.Context)6 VariableTree (com.sun.source.tree.VariableTree)4 TreePath (com.sun.source.util.TreePath)4 Type (com.sun.tools.javac.code.Type)3 Nullable (javax.annotation.Nullable)3 WildcardType (javax.lang.model.type.WildcardType)3 LocalStore (com.google.errorprone.dataflow.LocalStore)2 ExpressionTree (com.sun.source.tree.ExpressionTree)2 Symtab (com.sun.tools.javac.code.Symtab)2 Types (com.sun.tools.javac.code.Types)2 JCAnnotatedType (com.sun.tools.javac.tree.JCTree.JCAnnotatedType)2 ArrayList (java.util.ArrayList)2 Analysis (org.checkerframework.dataflow.analysis.Analysis)2 ControlFlowGraph (org.checkerframework.dataflow.cfg.ControlFlowGraph)2 UnderlyingAST (org.checkerframework.dataflow.cfg.UnderlyingAST)2 MethodInvocationTreeMatcher (com.google.errorprone.bugpatterns.BugChecker.MethodInvocationTreeMatcher)1 NewClassTreeMatcher (com.google.errorprone.bugpatterns.BugChecker.NewClassTreeMatcher)1 Matcher (com.google.errorprone.matchers.Matcher)1 Tree (com.sun.source.tree.Tree)1