ResourceList resourceList, MessageCatalogFactory msgCatFactory,
String genPath) {
// TODO(jat): maintain MessageCatalogWriter instances across
// generator runs so they can save state. One problem is knowing
// when the last generator has been run.
Writer catWriter = null;
try {
String catalogName = genPath + msgCatFactory.getExtension();
Context ctx = new MessageCatalogContextImpl(
context, logger);
MessageInterface msgIntf = new TypeOracleMessageInterface(
LocaleUtils.getLocaleFactory(), targetClass, resourceList);
catWriter = msgCatFactory.getWriter(ctx, catalogName);
if (catWriter == null) {
if (logger.isLoggable(TreeLogger.TRACE)) {
logger.log(TreeLogger.TRACE, "Already generated " + catalogName);
}
return false;
}
msgIntf.accept(catWriter.visitClass());
} catch (MessageProcessingException e) {
logger.log(TreeLogger.ERROR, e.getMessage(), e);
seenError = true;
} finally {
if (catWriter != null) {
try {
catWriter.close();
} catch (IOException e) {
logger.log(TreeLogger.ERROR,
"IO error closing catalog writer", e);
seenError = true;
}