Java Code Examples for com.sun.source.util.JavacTask#removeTaskListener()

The following examples show how to use com.sun.source.util.JavacTask#removeTaskListener() . 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: TestSimpleAddRemove.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
//            System.err.println("TestProcessor.process " + roundEnv);
            JavacTask task = JavacTask.instance(processingEnv);
            if (++round == 1) {
                switch (ak) {
                    case ADD_IN_PROCESSOR:
                        task.addTaskListener(listener);
                        break;
                    case ADD_IN_LISTENER:
                        addInListener(task, TaskEvent.Kind.ANALYZE, listener);
                        break;
                }
            } else if (roundEnv.processingOver()) {
                switch (rk) {
                    case REMOVE_IN_PROCESSOR:
                        task.removeTaskListener(listener);
                        break;
                    case REMOVE_IN_LISTENER:
                        removeInListener(task, TaskEvent.Kind.GENERATE, listener);
                        break;
                }
            }
            return true;
        }
 
Example 2
Source File: TestSimpleAddRemove.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
//            System.err.println("TestProcessor.process " + roundEnv);
            JavacTask task = JavacTask.instance(processingEnv);
            if (++round == 1) {
                switch (ak) {
                    case ADD_IN_PROCESSOR:
                        task.addTaskListener(listener);
                        break;
                    case ADD_IN_LISTENER:
                        addInListener(task, TaskEvent.Kind.ANALYZE, listener);
                        break;
                }
            } else if (roundEnv.processingOver()) {
                switch (rk) {
                    case REMOVE_IN_PROCESSOR:
                        task.removeTaskListener(listener);
                        break;
                    case REMOVE_IN_LISTENER:
                        removeInListener(task, TaskEvent.Kind.GENERATE, listener);
                        break;
                }
            }
            return true;
        }
 
Example 3
Source File: TestSimpleAddRemove.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
//            System.err.println("TestProcessor.process " + roundEnv);
            JavacTask task = JavacTask.instance(processingEnv);
            if (++round == 1) {
                switch (ak) {
                    case ADD_IN_PROCESSOR:
                        task.addTaskListener(listener);
                        break;
                    case ADD_IN_LISTENER:
                        addInListener(task, TaskEvent.Kind.ANALYZE, listener);
                        break;
                }
            } else if (roundEnv.processingOver()) {
                switch (rk) {
                    case REMOVE_IN_PROCESSOR:
                        task.removeTaskListener(listener);
                        break;
                    case REMOVE_IN_LISTENER:
                        removeInListener(task, TaskEvent.Kind.GENERATE, listener);
                        break;
                }
            }
            return true;
        }
 
Example 4
Source File: TestSimpleAddRemove.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
//            System.err.println("TestProcessor.process " + roundEnv);
            JavacTask task = JavacTask.instance(processingEnv);
            if (++round == 1) {
                switch (ak) {
                    case ADD_IN_PROCESSOR:
                        task.addTaskListener(listener);
                        break;
                    case ADD_IN_LISTENER:
                        addInListener(task, TaskEvent.Kind.ANALYZE, listener);
                        break;
                }
            } else if (roundEnv.processingOver()) {
                switch (rk) {
                    case REMOVE_IN_PROCESSOR:
                        task.removeTaskListener(listener);
                        break;
                    case REMOVE_IN_LISTENER:
                        removeInListener(task, TaskEvent.Kind.GENERATE, listener);
                        break;
                }
            }
            return true;
        }
 
Example 5
Source File: TestSimpleAddRemove.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
//            System.err.println("TestProcessor.process " + roundEnv);
            JavacTask task = JavacTask.instance(processingEnv);
            if (++round == 1) {
                switch (ak) {
                    case ADD_IN_PROCESSOR:
                        task.addTaskListener(listener);
                        break;
                    case ADD_IN_LISTENER:
                        addInListener(task, TaskEvent.Kind.ANALYZE, listener);
                        break;
                }
            } else if (roundEnv.processingOver()) {
                switch (rk) {
                    case REMOVE_IN_PROCESSOR:
                        task.removeTaskListener(listener);
                        break;
                    case REMOVE_IN_LISTENER:
                        removeInListener(task, TaskEvent.Kind.GENERATE, listener);
                        break;
                }
            }
            return true;
        }
 
Example 6
Source File: TestSimpleAddRemove.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
//            System.err.println("TestProcessor.process " + roundEnv);
            JavacTask task = JavacTask.instance(processingEnv);
            if (++round == 1) {
                switch (ak) {
                    case ADD_IN_PROCESSOR:
                        task.addTaskListener(listener);
                        break;
                    case ADD_IN_LISTENER:
                        addInListener(task, TaskEvent.Kind.ANALYZE, listener);
                        break;
                }
            } else if (roundEnv.processingOver()) {
                switch (rk) {
                    case REMOVE_IN_PROCESSOR:
                        task.removeTaskListener(listener);
                        break;
                    case REMOVE_IN_LISTENER:
                        removeInListener(task, TaskEvent.Kind.GENERATE, listener);
                        break;
                }
            }
            return true;
        }
 
Example 7
Source File: TestSimpleAddRemove.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
//            System.err.println("TestProcessor.process " + roundEnv);
            JavacTask task = JavacTask.instance(processingEnv);
            if (++round == 1) {
                switch (ak) {
                    case ADD_IN_PROCESSOR:
                        task.addTaskListener(listener);
                        break;
                    case ADD_IN_LISTENER:
                        addInListener(task, TaskEvent.Kind.ANALYZE, listener);
                        break;
                }
            } else if (roundEnv.processingOver()) {
                switch (rk) {
                    case REMOVE_IN_PROCESSOR:
                        task.removeTaskListener(listener);
                        break;
                    case REMOVE_IN_LISTENER:
                        removeInListener(task, TaskEvent.Kind.GENERATE, listener);
                        break;
                }
            }
            return true;
        }
 
Example 8
Source File: TestSimpleAddRemove.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
//            System.err.println("TestProcessor.process " + roundEnv);
            JavacTask task = JavacTask.instance(processingEnv);
            if (++round == 1) {
                switch (ak) {
                    case ADD_IN_PROCESSOR:
                        task.addTaskListener(listener);
                        break;
                    case ADD_IN_LISTENER:
                        addInListener(task, TaskEvent.Kind.ANALYZE, listener);
                        break;
                }
            } else if (roundEnv.processingOver()) {
                switch (rk) {
                    case REMOVE_IN_PROCESSOR:
                        task.removeTaskListener(listener);
                        break;
                    case REMOVE_IN_LISTENER:
                        removeInListener(task, TaskEvent.Kind.GENERATE, listener);
                        break;
                }
            }
            return true;
        }
 
Example 9
Source File: TestSimpleAddRemove.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
void test(CompileKind ck, AddKind ak, RemoveKind rk) throws IOException {
    System.err.println("Test: " + ck + " " + ak + " " + rk);

    File tmpDir = new File(ck + "-" + ak + "-" + rk);
    tmpDir.mkdirs();
    fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tmpDir));

    List<String> options = new ArrayList<String>();
    Iterable<? extends JavaFileObject> files = Arrays.asList(new TestSource());
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    JavacTask task = tool.getTask(pw, fm, null, options, null, files);

    EventKindCounter ec = new EventKindCounter();
    TaskListener listener = new TestListener(ec);
    boolean needProcessor = false;

    switch (ak) {
        case SET_IN_TASK:
            task.setTaskListener(listener);
            break;
        case ADD_IN_TASK:
            task.addTaskListener(listener);
            break;
        case ADD_IN_PROCESSOR:
        case ADD_IN_LISTENER:
            needProcessor = true;
    }

    switch (rk) {
        case REMOVE_IN_TASK:
            task.removeTaskListener(listener);
            break;
        case REMOVE_IN_PROCESSOR:
        case REMOVE_IN_LISTENER:
            needProcessor = true;
    }

    if (needProcessor)
        task.setProcessors(Arrays.asList(new TestProcessor(ak, rk, listener)));

    ck.run(task);
    System.err.println(ec);

    check(ck, ak, rk, ec);

    System.err.println();
}
 
Example 10
Source File: TestSimpleAddRemove.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
void test(CompileKind ck, AddKind ak, RemoveKind rk) throws IOException {
    System.err.println("Test: " + ck + " " + ak + " " + rk);

    File tmpDir = new File(ck + "-" + ak + "-" + rk);
    tmpDir.mkdirs();
    fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tmpDir));

    List<String> options = new ArrayList<String>();
    Iterable<? extends JavaFileObject> files = Arrays.asList(new TestSource());
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    JavacTask task = tool.getTask(pw, fm, null, options, null, files);

    EventKindCounter ec = new EventKindCounter();
    TaskListener listener = new TestListener(ec);
    boolean needProcessor = false;

    switch (ak) {
        case SET_IN_TASK:
            task.setTaskListener(listener);
            break;
        case ADD_IN_TASK:
            task.addTaskListener(listener);
            break;
        case ADD_IN_PROCESSOR:
        case ADD_IN_LISTENER:
            needProcessor = true;
    }

    switch (rk) {
        case REMOVE_IN_TASK:
            task.removeTaskListener(listener);
            break;
        case REMOVE_IN_PROCESSOR:
        case REMOVE_IN_LISTENER:
            needProcessor = true;
    }

    if (needProcessor)
        task.setProcessors(Arrays.asList(new TestProcessor(ak, rk, listener)));

    ck.run(task);
    System.err.println(ec);

    check(ck, ak, rk, ec);

    System.err.println();
}
 
Example 11
Source File: TestSimpleAddRemove.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
void test(CompileKind ck, AddKind ak, RemoveKind rk) throws IOException {
    System.err.println("Test: " + ck + " " + ak + " " + rk);

    File tmpDir = new File(ck + "-" + ak + "-" + rk);
    tmpDir.mkdirs();
    fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tmpDir));

    List<String> options = new ArrayList<String>();
    Iterable<? extends JavaFileObject> files = Arrays.asList(new TestSource());
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    JavacTask task = tool.getTask(pw, fm, null, options, null, files);

    EventKindCounter ec = new EventKindCounter();
    TaskListener listener = new TestListener(ec);
    boolean needProcessor = false;

    switch (ak) {
        case SET_IN_TASK:
            task.setTaskListener(listener);
            break;
        case ADD_IN_TASK:
            task.addTaskListener(listener);
            break;
        case ADD_IN_PROCESSOR:
        case ADD_IN_LISTENER:
            needProcessor = true;
    }

    switch (rk) {
        case REMOVE_IN_TASK:
            task.removeTaskListener(listener);
            break;
        case REMOVE_IN_PROCESSOR:
        case REMOVE_IN_LISTENER:
            needProcessor = true;
    }

    if (needProcessor)
        task.setProcessors(Arrays.asList(new TestProcessor(ak, rk, listener)));

    ck.run(task);
    System.err.println(ec);

    check(ck, ak, rk, ec);

    System.err.println();
}
 
Example 12
Source File: TestSimpleAddRemove.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
void test(CompileKind ck, AddKind ak, RemoveKind rk) throws IOException {
    System.err.println("Test: " + ck + " " + ak + " " + rk);

    File tmpDir = new File(ck + "-" + ak + "-" + rk);
    tmpDir.mkdirs();
    fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tmpDir));

    List<String> options = new ArrayList<String>();
    Iterable<? extends JavaFileObject> files = Arrays.asList(new TestSource());
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    JavacTask task = tool.getTask(pw, fm, null, options, null, files);

    EventKindCounter ec = new EventKindCounter();
    TaskListener listener = new TestListener(ec);
    boolean needProcessor = false;

    switch (ak) {
        case SET_IN_TASK:
            task.setTaskListener(listener);
            break;
        case ADD_IN_TASK:
            task.addTaskListener(listener);
            break;
        case ADD_IN_PROCESSOR:
        case ADD_IN_LISTENER:
            needProcessor = true;
    }

    switch (rk) {
        case REMOVE_IN_TASK:
            task.removeTaskListener(listener);
            break;
        case REMOVE_IN_PROCESSOR:
        case REMOVE_IN_LISTENER:
            needProcessor = true;
    }

    if (needProcessor)
        task.setProcessors(Arrays.asList(new TestProcessor(ak, rk, listener)));

    ck.run(task);
    System.err.println(ec);

    check(ck, ak, rk, ec);

    System.err.println();
}
 
Example 13
Source File: TestSimpleAddRemove.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
void test(CompileKind ck, AddKind ak, RemoveKind rk) throws IOException {
    System.err.println("Test: " + ck + " " + ak + " " + rk);

    File tmpDir = new File(ck + "-" + ak + "-" + rk);
    tmpDir.mkdirs();
    fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tmpDir));

    List<String> options = new ArrayList<String>();
    Iterable<? extends JavaFileObject> files = Arrays.asList(new TestSource());
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    JavacTask task = tool.getTask(pw, fm, null, options, null, files);

    EventKindCounter ec = new EventKindCounter();
    TaskListener listener = new TestListener(ec);
    boolean needProcessor = false;

    switch (ak) {
        case SET_IN_TASK:
            task.setTaskListener(listener);
            break;
        case ADD_IN_TASK:
            task.addTaskListener(listener);
            break;
        case ADD_IN_PROCESSOR:
        case ADD_IN_LISTENER:
            needProcessor = true;
    }

    switch (rk) {
        case REMOVE_IN_TASK:
            task.removeTaskListener(listener);
            break;
        case REMOVE_IN_PROCESSOR:
        case REMOVE_IN_LISTENER:
            needProcessor = true;
    }

    if (needProcessor)
        task.setProcessors(Arrays.asList(new TestProcessor(ak, rk, listener)));

    ck.run(task);
    System.err.println(ec);

    check(ck, ak, rk, ec);

    System.err.println();
}
 
Example 14
Source File: TestSimpleAddRemove.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
void test(CompileKind ck, AddKind ak, RemoveKind rk) throws IOException {
    System.err.println("Test: " + ck + " " + ak + " " + rk);

    File tmpDir = new File(ck + "-" + ak + "-" + rk);
    tmpDir.mkdirs();
    fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tmpDir));

    List<String> options = new ArrayList<String>();
    Iterable<? extends JavaFileObject> files = Arrays.asList(new TestSource());
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    JavacTask task = tool.getTask(pw, fm, null, options, null, files);

    EventKindCounter ec = new EventKindCounter();
    TaskListener listener = new TestListener(ec);
    boolean needProcessor = false;

    switch (ak) {
        case SET_IN_TASK:
            task.setTaskListener(listener);
            break;
        case ADD_IN_TASK:
            task.addTaskListener(listener);
            break;
        case ADD_IN_PROCESSOR:
        case ADD_IN_LISTENER:
            needProcessor = true;
    }

    switch (rk) {
        case REMOVE_IN_TASK:
            task.removeTaskListener(listener);
            break;
        case REMOVE_IN_PROCESSOR:
        case REMOVE_IN_LISTENER:
            needProcessor = true;
    }

    if (needProcessor)
        task.setProcessors(Arrays.asList(new TestProcessor(ak, rk, listener)));

    ck.run(task);
    System.err.println(ec);

    check(ck, ak, rk, ec);

    System.err.println();
}
 
Example 15
Source File: TestSimpleAddRemove.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
void test(CompileKind ck, AddKind ak, RemoveKind rk) throws IOException {
    System.err.println("Test: " + ck + " " + ak + " " + rk);

    File tmpDir = new File(ck + "-" + ak + "-" + rk);
    tmpDir.mkdirs();
    fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tmpDir));

    List<String> options = new ArrayList<String>();
    Iterable<? extends JavaFileObject> files = Arrays.asList(new TestSource());
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    JavacTask task = tool.getTask(pw, fm, null, options, null, files);

    EventKindCounter ec = new EventKindCounter();
    TaskListener listener = new TestListener(ec);
    boolean needProcessor = false;

    switch (ak) {
        case SET_IN_TASK:
            task.setTaskListener(listener);
            break;
        case ADD_IN_TASK:
            task.addTaskListener(listener);
            break;
        case ADD_IN_PROCESSOR:
        case ADD_IN_LISTENER:
            needProcessor = true;
    }

    switch (rk) {
        case REMOVE_IN_TASK:
            task.removeTaskListener(listener);
            break;
        case REMOVE_IN_PROCESSOR:
        case REMOVE_IN_LISTENER:
            needProcessor = true;
    }

    if (needProcessor)
        task.setProcessors(Arrays.asList(new TestProcessor(ak, rk, listener)));

    ck.run(task);
    System.err.println(ec);

    check(ck, ak, rk, ec);

    System.err.println();
}
 
Example 16
Source File: TestSimpleAddRemove.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
void test(CompileKind ck, AddKind ak, RemoveKind rk) throws IOException {
    System.err.println("Test: " + ck + " " + ak + " " + rk);

    File tmpDir = new File(ck + "-" + ak + "-" + rk);
    tmpDir.mkdirs();
    fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tmpDir));

    List<String> options = new ArrayList<String>();
    Iterable<? extends JavaFileObject> files = Arrays.asList(new TestSource());
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    JavacTask task = tool.getTask(pw, fm, null, options, null, files);

    EventKindCounter ec = new EventKindCounter();
    TaskListener listener = new TestListener(ec);
    boolean needProcessor = false;

    switch (ak) {
        case SET_IN_TASK:
            task.setTaskListener(listener);
            break;
        case ADD_IN_TASK:
            task.addTaskListener(listener);
            break;
        case ADD_IN_PROCESSOR:
        case ADD_IN_LISTENER:
            needProcessor = true;
    }

    switch (rk) {
        case REMOVE_IN_TASK:
            task.removeTaskListener(listener);
            break;
        case REMOVE_IN_PROCESSOR:
        case REMOVE_IN_LISTENER:
            needProcessor = true;
    }

    if (needProcessor)
        task.setProcessors(Arrays.asList(new TestProcessor(ak, rk, listener)));

    ck.run(task);
    System.err.println(ec);

    check(ck, ak, rk, ec);

    System.err.println();
}