/** Get the context for the next round of processing.
* Important values are propagated from round to round;
* other values are implicitly reset.
*/
private Context nextContext() {
Context next = new Context(context);
Options options = Options.instance(context);
Assert.checkNonNull(options);
next.put(Options.optionsKey, options);
Locale locale = context.get(Locale.class);
if (locale != null)
next.put(Locale.class, locale);
Assert.checkNonNull(messages);
next.put(JavacMessages.messagesKey, messages);
final boolean shareNames = true;
if (shareNames) {
Names names = Names.instance(context);
Assert.checkNonNull(names);
next.put(Names.namesKey, names);
}
DiagnosticListener<?> dl = context.get(DiagnosticListener.class);
if (dl != null)
next.put(DiagnosticListener.class, dl);
MultiTaskListener mtl = context.get(MultiTaskListener.taskListenerKey);
if (mtl != null)
next.put(MultiTaskListener.taskListenerKey, mtl);
FSInfo fsInfo = context.get(FSInfo.class);
if (fsInfo != null)
next.put(FSInfo.class, fsInfo);
JavaFileManager jfm = context.get(JavaFileManager.class);
Assert.checkNonNull(jfm);
next.put(JavaFileManager.class, jfm);
if (jfm instanceof JavacFileManager) {
((JavacFileManager)jfm).setContext(next);
}
Names names = Names.instance(context);
Assert.checkNonNull(names);
next.put(Names.namesKey, names);
Tokens tokens = Tokens.instance(context);
Assert.checkNonNull(tokens);
next.put(Tokens.tokensKey, tokens);
Log nextLog = Log.instance(next);
nextLog.initRound(log);
JavaCompiler oldCompiler = JavaCompiler.instance(context);
JavaCompiler nextCompiler = JavaCompiler.instance(next);
nextCompiler.initRound(oldCompiler);
filer.newRound(next);
messager.newRound(next);
elementUtils.setContext(next);
typeUtils.setContext(next);
JavacTask task = context.get(JavacTask.class);
if (task != null) {
next.put(JavacTask.class, task);
if (task instanceof BasicJavacTask)
((BasicJavacTask) task).updateContext(next);
}
JavacTrees trees = context.get(JavacTrees.class);
if (trees != null) {
next.put(JavacTrees.class, trees);
trees.updateContext(next);
}
context.clear();
return next;