* @throws AnalysisException if the results could not be recorded
*/
private HtmlEntry recordResolveHtmlTaskResults(ResolveHtmlTask task) throws AnalysisException {
Source source = task.getSource();
AnalysisException thrownException = task.getException();
HtmlEntry htmlEntry = null;
synchronized (cacheLock) {
SourceEntry sourceEntry = cache.get(source);
if (sourceEntry == null) {
throw new ObsoleteSourceAnalysisException(source);
} else if (!(sourceEntry instanceof HtmlEntry)) {
// This shouldn't be possible because we should never have performed the task if the source
// didn't represent an HTML file, but check to be safe.
throw new AnalysisException(
"Internal error: attempting to resolve non-HTML file as an HTML file: "
+ source.getFullName());
}
htmlEntry = (HtmlEntry) sourceEntry;
long sourceTime = getModificationStamp(source);
long resultTime = task.getModificationTime();
if (sourceTime == resultTime) {
if (htmlEntry.getModificationTime() != sourceTime) {
// The source has changed without the context being notified. Simulate notification.
sourceChanged(source);
htmlEntry = getReadableHtmlEntry(source);
if (htmlEntry == null) {
throw new AnalysisException("An HTML file became a non-HTML file: "
+ source.getFullName());
}
}
HtmlEntryImpl htmlCopy = htmlEntry.getWritableCopy();
if (thrownException == null) {
htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED);
htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.getResolvedUnit());
htmlCopy.setValue(HtmlEntry.ELEMENT, task.getElement());
htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, task.getResolutionErrors());
cache.storedAst(source);
ChangeNoticeImpl notice = getNotice(source);
notice.setHtmlUnit(task.getResolvedUnit());
notice.setErrors(htmlCopy.getAllErrors(), htmlCopy.getValue(SourceEntry.LINE_INFO));
} else {
htmlCopy.recordResolutionError(thrownException);
cache.removedAst(source);
}
cache.put(source, htmlCopy);
htmlEntry = htmlCopy;
} else {
logInformation("Resolution results discarded for " + debuggingString(source)
+ "; sourceTime = " + sourceTime + ", resultTime = " + resultTime + ", cacheTime = "
+ htmlEntry.getModificationTime(), thrownException);
HtmlEntryImpl htmlCopy = htmlEntry.getWritableCopy();
if (thrownException == null || resultTime >= 0L) {
//
// The analysis was performed on out-of-date sources. Mark the cache so that the sources
// will be re-analyzed using the up-to-date sources.
//