private List<Difference> processExternalCUs(Map<?, int[]> tag2Span, Set<Tree> syntheticTrees) {
if (externalChanges == null) {
return Collections.<Difference>emptyList();
}
List<Difference> result = new LinkedList<Difference>();
for (CompilationUnitTree t : externalChanges.values()) {
try {
FileObject targetFile = doCreateFromTemplate(t);
CompilationUnitTree templateCUT = impl.getJavacTask().parse(FileObjects.sourceFileObject(targetFile, targetFile.getParent())).iterator().next();
CompilationUnitTree importComments = GeneratorUtilities.get(this).importComments(templateCUT, templateCUT);
rewrite(importComments, getTreeMaker().asRemoved(t));
StringWriter target = new StringWriter();
ModificationResult.commit(targetFile, processCurrentCompilationUnit(new DiffContext(this, templateCUT, codeForCompilationUnit(templateCUT), new PositionConverter(), targetFile, syntheticTrees, getFileObject() != null ? getCompilationUnit() : null, getFileObject() != null ? getText() : null), tag2Span), target);
result.add(new CreateChange(t.getSourceFile(), target.toString()));
target.close();
} catch (BadLocationException ex) {
Exceptions.printStackTrace(ex);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
return result;
}