本文整理汇总了Java中com.sun.source.util.JavacTask.removeTaskListener方法的典型用法代码示例。如果您正苦于以下问题:Java JavacTask.removeTaskListener方法的具体用法?Java JavacTask.removeTaskListener怎么用?Java JavacTask.removeTaskListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.source.util.JavacTask
的用法示例。
在下文中一共展示了JavacTask.removeTaskListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import com.sun.source.util.JavacTask; //导入方法依赖的package包/类
@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;
}
示例2: test
import com.sun.source.util.JavacTask; //导入方法依赖的package包/类
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();
}