throw new AnalysisException("A Dart file became a non-Dart file: "
+ source.getFullName());
}
}
removeFromParts(source, dartEntry);
DartEntryImpl dartCopy = dartEntry.getWritableCopy();
if (thrownException == null) {
if (task.hasNonPartOfDirective()) {
dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
dartCopy.setContainingLibrary(source);
workManager.add(source, SourcePriority.LIBRARY);
} else if (task.hasPartOfDirective()) {
dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
dartCopy.removeContainingLibrary(source);
workManager.add(source, SourcePriority.NORMAL_PART);
} else {
// The file contains no directives.
List<Source> containingLibraries = dartCopy.getContainingLibraries();
if (containingLibraries.size() > 1
|| (containingLibraries.size() == 1 && !containingLibraries.get(0).equals(source))) {
dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
dartCopy.removeContainingLibrary(source);
workManager.add(source, SourcePriority.NORMAL_PART);
} else {
dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
dartCopy.setContainingLibrary(source);
workManager.add(source, SourcePriority.LIBRARY);
}
}
Source[] newParts = task.getIncludedSources();
for (int i = 0; i < newParts.length; i++) {
Source partSource = newParts[i];
DartEntry partEntry = getReadableDartEntry(partSource);
if (partEntry != null && partEntry != dartEntry) {
DartEntryImpl partCopy = partEntry.getWritableCopy();
// TODO(brianwilkerson) Change the kind of the "part" if it was marked as a library
// and it has no directives.
partCopy.addContainingLibrary(source);
cache.put(partSource, partCopy);
}
}
dartCopy.setValue(DartEntry.PARSED_UNIT, task.getCompilationUnit());
dartCopy.setValue(DartEntry.PARSE_ERRORS, task.getErrors());
dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, task.getExportedSources());
dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, task.getImportedSources());
dartCopy.setValue(DartEntry.INCLUDED_PARTS, newParts);
cache.storedAst(source);
ChangeNoticeImpl notice = getNotice(source);
notice.setErrors(dartCopy.getAllErrors(), task.getLineInfo());
// Verify that the incrementally parsed and resolved unit in the incremental cache
// is structurally equivalent to the fully parsed unit
incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(
incrementalAnalysisCache,
source,
task.getCompilationUnit());
} else {
removeFromParts(source, dartEntry);
dartCopy.recordParseError(thrownException);
cache.removedAst(source);
}
cache.put(source, dartCopy);
dartEntry = dartCopy;
} else {
logInformation(
"Parse results discarded for " + debuggingString(source) + "; sourceTime = "
+ sourceTime + ", resultTime = " + resultTime + ", cacheTime = "
+ dartEntry.getModificationTime(),
thrownException);
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.recordParseNotInProcess();
removeFromParts(source, dartEntry);
dartCopy.invalidateAllInformation();
dartCopy.setModificationTime(sourceTime);
cache.removedAst(source);
workManager.add(source, SourcePriority.UNKNOWN);
} 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.recordParseError(thrownException);
}
cache.put(source, dartCopy);
dartEntry = dartCopy;
}
}