boolean anyRemoved = false;
for (CompilationUnit unit : units) {
if (unit.getState() != State.COMPILED) {
continue;
}
CompilationResult result = unit.getJdtCud().compilationResult();
if (result.hasProblems()) {
// Log the errors and GWT warnings.
TreeLogger branch = null;
for (CategorizedProblem problem : result.getProblems()) {
TreeLogger.Type logLevel;
if (problem.isError()) {
// Log errors.
logLevel = TreeLogger.ERROR;
// Only log GWT-specific warnings.
} else if (problem.isWarning() && problem instanceof GWTProblem) {
logLevel = TreeLogger.WARN;
} else {
// Ignore all other problems.
continue;
}
// Append 'Line #: msg' to the error message.
StringBuffer msgBuf = new StringBuffer();
int line = problem.getSourceLineNumber();
if (line > 0) {
msgBuf.append("Line ");
msgBuf.append(line);
msgBuf.append(": ");
}
msgBuf.append(problem.getMessage());
HelpInfo helpInfo = null;
if (problem instanceof GWTProblem) {
GWTProblem gwtProblem = (GWTProblem) problem;
helpInfo = gwtProblem.getHelpInfo();
}
if (branch == null) {
Type branchType = result.hasErrors() ? TreeLogger.ERROR
: TreeLogger.WARN;
String branchString = result.hasErrors() ? "Errors" : "Warnings";
branch = logger.branch(branchType, branchString + " in '"
+ unit.getDisplayLocation() + "'", null);
}
branch.log(logLevel, msgBuf.toString(), null, helpInfo);
}
if (branch != null) {
Util.maybeDumpSource(branch, unit.getDisplayLocation(),
unit.getSource(), unit.getTypeName());
}
// Invalidate the unit if there are errors.
if (result.hasErrors()) {
unit.setError();
anyRemoved = true;
}
}
}