}
if (sourceEntry == null) {
return new TaskData(null, false);
}
CacheState contentState = sourceEntry.getState(SourceEntry.CONTENT);
if (contentState == CacheState.INVALID) {
return createGetContentTask(source, sourceEntry);
} else if (contentState == CacheState.IN_PROCESS) {
// We are already in the process of getting the content. There's nothing else we can do with
// this source until that's complete.
return new TaskData(null, true);
} else if (contentState == CacheState.ERROR) {
// We have done all of the analysis we can for this source because we cannot get its content.
return new TaskData(null, false);
}
if (sourceEntry instanceof DartEntry) {
DartEntry dartEntry = (DartEntry) sourceEntry;
CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS);
if (scanErrorsState == CacheState.INVALID
|| (isPriority && scanErrorsState == CacheState.FLUSHED)) {
return createScanDartTask(source, dartEntry);
}
CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS);
if (parseErrorsState == CacheState.INVALID
|| (isPriority && parseErrorsState == CacheState.FLUSHED)) {
return createParseDartTask(source, dartEntry);
}
if (isPriority && parseErrorsState != CacheState.ERROR) {
if (!dartEntry.hasResolvableCompilationUnit()) {
return createParseDartTask(source, dartEntry);
}
}
SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND);
if (kind == SourceKind.UNKNOWN) {
return createParseDartTask(source, dartEntry);
} else if (kind == SourceKind.LIBRARY) {
CacheState elementState = dartEntry.getState(DartEntry.ELEMENT);
if (elementState == CacheState.INVALID) {
return createResolveDartLibraryTask(source, dartEntry);
}
}
Source[] librariesContaining = dartEntry.getValue(DartEntry.CONTAINING_LIBRARIES);
for (Source librarySource : librariesContaining) {
SourceEntry librarySourceEntry = cache.get(librarySource);
if (librarySourceEntry instanceof DartEntry) {
DartEntry libraryEntry = (DartEntry) librarySourceEntry;
CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT);
if (elementState == CacheState.INVALID
|| (isPriority && elementState == CacheState.FLUSHED)) {
//return createResolveDartLibraryTask(librarySource, (DartEntry) libraryEntry);
DartEntryImpl libraryCopy = libraryEntry.getWritableCopy();
libraryCopy.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS);
cache.put(librarySource, libraryCopy);
return new TaskData(new ResolveDartLibraryTask(this, source, librarySource), false);
}
CacheState resolvedUnitState = dartEntry.getStateInLibrary(
DartEntry.RESOLVED_UNIT,
librarySource);
if (resolvedUnitState == CacheState.INVALID
|| (isPriority && resolvedUnitState == CacheState.FLUSHED)) {
//
// The commented out lines below are an optimization that doesn't quite work yet. The
// problem is that if the source was not resolved because it wasn't part of any library,
// then there won't be any elements in the element model that we can use to resolve it.
//
//LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT);
//if (libraryElement != null) {
// return new ResolveDartUnitTask(this, source, libraryElement);
//}
// Possibly replace with: return createResolveDartLibraryTask(librarySource, (DartEntry) libraryEntry);
DartEntryImpl dartCopy = dartEntry.getWritableCopy();
dartCopy.setStateInLibrary(
DartEntry.RESOLVED_UNIT,
librarySource,
CacheState.IN_PROCESS);
cache.put(source, dartCopy);
return new TaskData(new ResolveDartLibraryTask(this, source, librarySource), false);
}
if (generateSdkErrors || !source.isInSystemLibrary()) {
CacheState verificationErrorsState = dartEntry.getStateInLibrary(
DartEntry.VERIFICATION_ERRORS,
librarySource);
if (verificationErrorsState == CacheState.INVALID
|| (isPriority && verificationErrorsState == CacheState.FLUSHED)) {
return createGenerateDartErrorsTask(source, dartEntry, librarySource, libraryEntry);
}
if (hintsEnabled) {
CacheState hintsState = dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource);
if (hintsState == CacheState.INVALID
|| (isPriority && hintsState == CacheState.FLUSHED)) {
return createGenerateDartHintsTask(source, dartEntry, librarySource, libraryEntry);
}
}
}
}
}
} else if (sourceEntry instanceof HtmlEntry) {
HtmlEntry htmlEntry = (HtmlEntry) sourceEntry;
CacheState parseErrorsState = htmlEntry.getState(HtmlEntry.PARSE_ERRORS);
if (parseErrorsState == CacheState.INVALID
|| (isPriority && parseErrorsState == CacheState.FLUSHED)) {
return createParseHtmlTask(source, htmlEntry);
}
if (isPriority && parseErrorsState != CacheState.ERROR) {
HtmlUnit parsedUnit = htmlEntry.getAnyParsedUnit();
if (parsedUnit == null) {
return createParseHtmlTask(source, htmlEntry);
}
}
CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT);
if (resolvedUnitState == CacheState.INVALID
|| (isPriority && resolvedUnitState == CacheState.FLUSHED)) {
return createResolveHtmlTask(source, htmlEntry);
}
//
// Angular support
//
if (options.getAnalyzeAngular()) {
// Try to resolve the HTML as an Angular entry point.
CacheState angularEntryState = htmlEntry.getState(HtmlEntry.ANGULAR_ENTRY);
if (angularEntryState == CacheState.INVALID
|| (isPriority && angularEntryState == CacheState.FLUSHED)) {
return createResolveAngularEntryHtmlTask(source, htmlEntry);
}
// Try to resolve the HTML as an Angular application part.
CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERRORS);
if (angularErrorsState == CacheState.INVALID
|| (isPriority && angularErrorsState == CacheState.FLUSHED)) {
return createResolveAngularComponentTemplateTask(source, htmlEntry);
}
}
//
// Polymer support
//
if (options.getAnalyzePolymer()) {
// Build elements.
CacheState polymerBuildErrorsState = htmlEntry.getState(HtmlEntry.POLYMER_BUILD_ERRORS);
if (polymerBuildErrorsState == CacheState.INVALID
|| (isPriority && polymerBuildErrorsState == CacheState.FLUSHED)) {
return createPolymerBuildHtmlTask(source, htmlEntry);
}
// Resolve references.
CacheState polymerResolutionErrorsState = htmlEntry.getState(HtmlEntry.POLYMER_RESOLUTION_ERRORS);
if (polymerResolutionErrorsState == CacheState.INVALID
|| (isPriority && polymerResolutionErrorsState == CacheState.FLUSHED)) {
return createPolymerResolveHtmlTask(source, htmlEntry);
}
}