* @throws AnalysisException if the results could not be recorded
*/
private DartEntry recordGenerateDartHintsTask(GenerateDartHintsTask task)
throws AnalysisException {
Source librarySource = task.getLibraryElement().getSource();
AnalysisException thrownException = task.getException();
DartEntry libraryEntry = null;
HashMap<Source, TimestampedData<AnalysisError[]>> hintMap = task.getHintMap();
if (hintMap == null) {
synchronized (cacheLock) {
// We don't have any information about which sources to mark as invalid other than the library
// source.
SourceEntry sourceEntry = cache.get(librarySource);
if (sourceEntry == null) {
throw new ObsoleteSourceAnalysisException(librarySource);
} else if (!(sourceEntry instanceof DartEntry)) {
// This shouldn't be possible because we should never have performed the task if the source
// didn't represent a Dart file, but check to be safe.
throw new AnalysisException(
"Internal error: attempting to generate hints for non-Dart file as a Dart file: "
+ librarySource.getFullName());
}
if (thrownException == null) {
thrownException = new AnalysisException(
"GenerateDartHintsTask returned a null hint map without throwing an exception: "
+ librarySource.getFullName());
}
DartEntryImpl dartCopy = ((DartEntry) sourceEntry).getWritableCopy();
dartCopy.recordHintErrorInLibrary(librarySource, thrownException);
cache.put(librarySource, dartCopy);
}
throw thrownException;
}
for (Map.Entry<Source, TimestampedData<AnalysisError[]>> entry : hintMap.entrySet()) {
Source unitSource = entry.getKey();
TimestampedData<AnalysisError[]> results = entry.getValue();
synchronized (cacheLock) {
SourceEntry sourceEntry = cache.get(unitSource);
if (!(sourceEntry instanceof DartEntry)) {
// This shouldn't be possible because we should never have performed the task if the source
// didn't represent a Dart file, but check to be safe.
throw new AnalysisException(
"Internal error: attempting to parse non-Dart file as a Dart file: "
+ unitSource.getFullName());
}
DartEntry dartEntry = (DartEntry) sourceEntry;
if (unitSource.equals(librarySource)) {
libraryEntry = dartEntry;
}
long sourceTime = getModificationStamp(unitSource);
long resultTime = results.getModificationTime();
if (sourceTime == resultTime) {
if (dartEntry.getModificationTime() != sourceTime) {
// The source has changed without the context being notified. Simulate notification.
sourceChanged(unitSource);
dartEntry = getReadableDartEntry(unitSource);
if (dartEntry == null) {
throw new AnalysisException("A Dart file became a non-Dart file: "
+ unitSource.getFullName());
}
}
DartEntryImpl dartCopy = dartEntry.getWritableCopy();
if (thrownException == null) {