unitEntry = getReadableDartEntry(unitSource);
if (unitEntry == null) {
throw new AnalysisException("A Dart file became a non-Dart file: "
+ unitSource.getFullName());
}
DartEntryImpl dartCopy = unitEntry.getWritableCopy();
if (thrownException == null) {
dartCopy.recordResolutionError(new AnalysisException(
"In recordResolveDartLibraryTaskResults, resolvedLibraries was null and there was no thrown exception"));
} else {
dartCopy.recordResolutionError(thrownException);
}
cache.put(unitSource, dartCopy);
cache.remove(unitSource);
if (thrownException != null) {
throw thrownException;
}
return dartCopy;
}
if (allModificationTimesMatch(resolvedLibraries)) {
Source htmlSource = getSourceFactory().forUri(DartSdk.DART_HTML);
RecordingErrorListener errorListener = resolver.getErrorListener();
for (Library library : resolvedLibraries) {
Source librarySource = library.getLibrarySource();
for (Source source : library.getCompilationUnitSources()) {
CompilationUnit unit = library.getAST(source);
AnalysisError[] errors = errorListener.getErrorsForSource(source);
LineInfo lineInfo = getLineInfo(source);
DartEntry dartEntry = (DartEntry) cache.get(source);
long sourceTime = getModificationStamp(source);
if (dartEntry.getModificationTime() != sourceTime) {
// The source has changed without the context being notified. Simulate notification.
sourceChanged(source);
dartEntry = getReadableDartEntry(source);
if (dartEntry == null) {
throw new AnalysisException("A Dart file became a non-Dart file: "
+ source.getFullName());
}
}
DartEntryImpl dartCopy = dartEntry.getWritableCopy();
if (thrownException == null) {
dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo);
dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
dartCopy.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, unit);
dartCopy.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySource, errors);
if (source.equals(librarySource)) {
recordElementData(
dartCopy,
library.getLibraryElement(),
librarySource,
htmlSource);
}
cache.storedAst(source);
} else {
dartCopy.recordResolutionErrorInLibrary(librarySource, thrownException);
cache.remove(source);
}
cache.put(source, dartCopy);
if (!source.equals(librarySource)) {
workManager.add(source, SourcePriority.PRIORITY_PART);
}
if (source.equals(unitSource)) {
unitEntry = dartCopy;
}
ChangeNoticeImpl notice = getNotice(source);
notice.setCompilationUnit(unit);
notice.setErrors(dartCopy.getAllErrors(), lineInfo);
}
}
} else {
@SuppressWarnings("resource")
PrintStringWriter writer = new PrintStringWriter();
writer.println("Library resolution results discarded for");
for (Library library : resolvedLibraries) {
for (Source source : library.getCompilationUnitSources()) {
DartEntry dartEntry = getReadableDartEntry(source);
if (dartEntry != null) {
long resultTime = library.getModificationTime(source);
writer.println(" " + debuggingString(source) + "; sourceTime = "
+ getModificationStamp(source) + ", resultTime = " + resultTime
+ ", cacheTime = " + dartEntry.getModificationTime());
DartEntryImpl dartCopy = dartEntry.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.
//
dartCopy.recordResolutionNotInProcess();
} else {
//
// We could not determine whether the sources were up-to-date or out-of-date. Mark
// the cache so that we won't attempt to re-analyze the sources until there's a
// good chance that we'll be able to do so without error.
//
dartCopy.recordResolutionError(thrownException);
cache.remove(source);
}
cache.put(source, dartCopy);
if (source.equals(unitSource)) {
unitEntry = dartCopy;