public AnalysisResult performAnalysisTask() {
if (TRACE_PERFORM_TASK) {
System.out.println("----------------------------------------");
}
long getStart = System.currentTimeMillis();
AnalysisTask task = getNextAnalysisTask();
long getEnd = System.currentTimeMillis();
if (task == null && validateCacheConsistency()) {
task = getNextAnalysisTask();
}
if (task == null) {
return new AnalysisResult(getChangeNotices(true), getEnd - getStart, null, -1L);
}
String taskDescription = task.toString();
if (!reportedLoop && !recentTasks.add(taskDescription)) {
@SuppressWarnings("resource")
PrintStringWriter writer = new PrintStringWriter();
writer.print("Performing repeated task: ");
writer.println(taskDescription);
for (String description : recentTasks) {
writer.print(" ");
writer.println(description);
}
logInformation(writer.toString());
}
notifyAboutToPerformTask(taskDescription);
if (TRACE_PERFORM_TASK) {
System.out.println(taskDescription);
}
long performStart = System.currentTimeMillis();
try {
task.perform(resultRecorder);
} catch (ObsoleteSourceAnalysisException exception) {
AnalysisEngine.getInstance().getLogger().logInformation(
"Could not perform analysis task: " + taskDescription,
exception);
} catch (AnalysisException exception) {
if (!(exception.getCause() instanceof IOException)) {
AnalysisEngine.getInstance().getLogger().logError(
"Internal error while performing the task: " + task,
exception);
}
}
long performEnd = System.currentTimeMillis();
ChangeNotice[] notices = getChangeNotices(false);
int noticeCount = notices.length;
for (int i = 0; i < noticeCount; i++) {
ChangeNotice notice = notices[i];
Source source = notice.getSource();
// TODO(brianwilkerson) Figure out whether the compilation unit is always resolved, or whether
// we need to decide whether to invoke the "parsed" or "resolved" method. This might be better
// done when recording task results in order to reduce the chance of errors.
// if (notice.getCompilationUnit() != null) {
// notifyResolvedDart(source, notice.getCompilationUnit());
// } else if (notice.getHtmlUnit() != null) {
// notifyResolvedHtml(source, notice.getHtmlUnit());
// }
notifyErrors(source, notice.getErrors(), notice.getLineInfo());
}
return new AnalysisResult(notices, getEnd - getStart, task.getClass().getName(), performEnd
- performStart);
}