Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: pkg/analyzer/lib/src/generated/engine.dart

Issue 1311773005: Extension point for WorkManagerFactory(s). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/generated/engine.dart
diff --git a/pkg/analyzer/lib/src/generated/engine.dart b/pkg/analyzer/lib/src/generated/engine.dart
index d3cb976fed81d4b3f7fc7a402cde06367cd37bf9..acaad042a7df8e04ac8e6a07b2e3bc0a8e39c04e 100644
--- a/pkg/analyzer/lib/src/generated/engine.dart
+++ b/pkg/analyzer/lib/src/generated/engine.dart
@@ -1089,7 +1089,8 @@ class AnalysisContextImpl implements InternalAnalysisContext {
*/
AnalysisContextImpl() {
_resultRecorder = new AnalysisContextImpl_AnalysisTaskResultRecorder(this);
- _privatePartition = new UniversalCachePartition(this,
+ _privatePartition = new UniversalCachePartition(
+ this,
AnalysisOptionsImpl.DEFAULT_CACHE_SIZE,
new AnalysisContextImpl_ContextRetentionPolicy(this));
_cache = createCacheFromSourceFactory(null);
@@ -1648,11 +1649,15 @@ class AnalysisContextImpl implements InternalAnalysisContext {
_getDartParseData(source, dartEntry, DartEntry.PARSE_ERRORS));
dartEntry = _getReadableDartEntry(source);
if (dartEntry.getValue(DartEntry.SOURCE_KIND) == SourceKind.LIBRARY) {
- ListUtilities.addAll(errors, _getDartResolutionData(
- source, source, dartEntry, DartEntry.RESOLUTION_ERRORS));
+ ListUtilities.addAll(
+ errors,
+ _getDartResolutionData(
+ source, source, dartEntry, DartEntry.RESOLUTION_ERRORS));
dartEntry = _getReadableDartEntry(source);
- ListUtilities.addAll(errors, _getDartVerificationData(
- source, source, dartEntry, DartEntry.VERIFICATION_ERRORS));
+ ListUtilities.addAll(
+ errors,
+ _getDartVerificationData(
+ source, source, dartEntry, DartEntry.VERIFICATION_ERRORS));
if (enableHints) {
dartEntry = _getReadableDartEntry(source);
ListUtilities.addAll(errors,
@@ -1666,20 +1671,28 @@ class AnalysisContextImpl implements InternalAnalysisContext {
} else {
List<Source> libraries = getLibrariesContaining(source);
for (Source librarySource in libraries) {
- ListUtilities.addAll(errors, _getDartResolutionData(
- source, librarySource, dartEntry, DartEntry.RESOLUTION_ERRORS));
+ ListUtilities.addAll(
+ errors,
+ _getDartResolutionData(source, librarySource, dartEntry,
+ DartEntry.RESOLUTION_ERRORS));
dartEntry = _getReadableDartEntry(source);
- ListUtilities.addAll(errors, _getDartVerificationData(source,
- librarySource, dartEntry, DartEntry.VERIFICATION_ERRORS));
+ ListUtilities.addAll(
+ errors,
+ _getDartVerificationData(source, librarySource, dartEntry,
+ DartEntry.VERIFICATION_ERRORS));
if (enableHints) {
dartEntry = _getReadableDartEntry(source);
- ListUtilities.addAll(errors, _getDartHintData(
- source, librarySource, dartEntry, DartEntry.HINTS));
+ ListUtilities.addAll(
+ errors,
+ _getDartHintData(
+ source, librarySource, dartEntry, DartEntry.HINTS));
}
if (enableLints) {
dartEntry = _getReadableDartEntry(source);
- ListUtilities.addAll(errors, _getDartLintData(
- source, librarySource, dartEntry, DartEntry.LINTS));
+ ListUtilities.addAll(
+ errors,
+ _getDartLintData(
+ source, librarySource, dartEntry, DartEntry.LINTS));
}
}
}
@@ -1775,8 +1788,8 @@ class AnalysisContextImpl implements InternalAnalysisContext {
@override
CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync(
Source unitSource, Source librarySource) {
- return new _AnalysisFutureHelper<CompilationUnit>(this).computeAsync(
- unitSource, (SourceEntry sourceEntry) {
+ return new _AnalysisFutureHelper<CompilationUnit>(this)
+ .computeAsync(unitSource, (SourceEntry sourceEntry) {
if (sourceEntry is DartEntry) {
if (sourceEntry.getStateInLibrary(
DartEntry.RESOLVED_UNIT, librarySource) ==
@@ -2117,7 +2130,8 @@ class AnalysisContextImpl implements InternalAnalysisContext {
if (dartEntry == null) {
AnalysisEngine.instance.logger.logError(
"Could not compute the public namespace for ${library.source.fullName}",
- new CaughtException(new AnalysisException(
+ new CaughtException(
+ new AnalysisException(
"A Dart file became a non-Dart file: ${source.fullName}"),
null));
return null;
@@ -2312,7 +2326,8 @@ class AnalysisContextImpl implements InternalAnalysisContext {
_validateLastIncrementalResolutionResult();
if (_performAnalysisTaskStopwatch != null) {
AnalysisEngine.instance.instrumentationService.logPerformance(
- AnalysisPerformanceKind.FULL, _performAnalysisTaskStopwatch,
+ AnalysisPerformanceKind.FULL,
+ _performAnalysisTaskStopwatch,
'context_id=$_id');
_performAnalysisTaskStopwatch = null;
}
@@ -2566,7 +2581,8 @@ class AnalysisContextImpl implements InternalAnalysisContext {
@override
CompilationUnit resolveCompilationUnit2(
- Source unitSource, Source librarySource) => _getDartResolutionData2(
+ Source unitSource, Source librarySource) =>
+ _getDartResolutionData2(
unitSource, librarySource, DartEntry.RESOLVED_UNIT, null);
@override
@@ -2890,7 +2906,9 @@ class AnalysisContextImpl implements InternalAnalysisContext {
// source continues to change, this loop will eventually terminate.
//
dartEntry = _cacheDartScanData(source, dartEntry, DartEntry.TOKEN_STREAM);
- dartEntry = new ParseDartTask(this, source,
+ dartEntry = new ParseDartTask(
+ this,
+ source,
dartEntry.getValue(DartEntry.TOKEN_STREAM),
dartEntry.getValue(SourceEntry.LINE_INFO))
.perform(_resultRecorder) as DartEntry;
@@ -2954,8 +2972,8 @@ class AnalysisContextImpl implements InternalAnalysisContext {
//
try {
if (dartEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) {
- dartEntry = new GetContentTask(this, source)
- .perform(_resultRecorder) as DartEntry;
+ dartEntry = new GetContentTask(this, source).perform(_resultRecorder)
+ as DartEntry;
}
dartEntry = new ScanDartTask(
this, source, dartEntry.getValue(SourceEntry.CONTENT))
@@ -3031,8 +3049,8 @@ class AnalysisContextImpl implements InternalAnalysisContext {
//
try {
if (htmlEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) {
- htmlEntry = new GetContentTask(this, source)
- .perform(_resultRecorder) as HtmlEntry;
+ htmlEntry = new GetContentTask(this, source).perform(_resultRecorder)
+ as HtmlEntry;
}
htmlEntry = new ParseHtmlTask(
this, source, htmlEntry.getValue(SourceEntry.CONTENT))
@@ -3168,8 +3186,14 @@ class AnalysisContextImpl implements InternalAnalysisContext {
if (contents != originalContents) {
if (_options.incremental) {
_incrementalAnalysisCache = IncrementalAnalysisCache.update(
- _incrementalAnalysisCache, source, originalContents, contents,
- offset, oldLength, newLength, _getReadableSourceEntry(source));
+ _incrementalAnalysisCache,
+ source,
+ originalContents,
+ contents,
+ offset,
+ oldLength,
+ newLength,
+ _getReadableSourceEntry(source));
}
_sourceChanged(source);
changed = true;
@@ -3217,11 +3241,12 @@ class AnalysisContextImpl implements InternalAnalysisContext {
CompilationUnit unit =
unitEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource);
if (unit == null) {
- CaughtException exception = new CaughtException(new AnalysisException(
+ CaughtException exception = new CaughtException(
+ new AnalysisException(
"Entry has VALID state for RESOLVED_UNIT but null value for ${unitSource.fullName} in ${librarySource.fullName}"),
null);
- AnalysisEngine.instance.logger.logInformation(
- exception.toString(), exception);
+ AnalysisEngine.instance.logger
+ .logInformation(exception.toString(), exception);
unitEntry.recordResolutionError(exception);
return new AnalysisContextImpl_TaskData(null, false);
}
@@ -3319,8 +3344,10 @@ class AnalysisContextImpl implements InternalAnalysisContext {
}
Token tokenStream = dartEntry.getValue(DartEntry.TOKEN_STREAM);
dartEntry.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED);
- return new AnalysisContextImpl_TaskData(new ParseDartTask(this, source,
- tokenStream, dartEntry.getValue(SourceEntry.LINE_INFO)), false);
+ return new AnalysisContextImpl_TaskData(
+ new ParseDartTask(this, source, tokenStream,
+ dartEntry.getValue(SourceEntry.LINE_INFO)),
+ false);
}
/**
@@ -3353,8 +3380,10 @@ class AnalysisContextImpl implements InternalAnalysisContext {
if (taskData != null) {
return taskData;
}
- return new AnalysisContextImpl_TaskData(new ResolveDartLibraryCycleTask(
- this, source, source, builder.librariesInCycle), false);
+ return new AnalysisContextImpl_TaskData(
+ new ResolveDartLibraryCycleTask(
+ this, source, source, builder.librariesInCycle),
+ false);
} on AnalysisException catch (exception, stackTrace) {
dartEntry
.recordResolutionError(new CaughtException(exception, stackTrace));
@@ -3374,9 +3403,10 @@ class AnalysisContextImpl implements InternalAnalysisContext {
if (htmlEntry.getState(HtmlEntry.PARSED_UNIT) != CacheState.VALID) {
return _createParseHtmlTask(source, htmlEntry);
}
- return new AnalysisContextImpl_TaskData(new ResolveHtmlTask(this, source,
- htmlEntry.modificationTime,
- htmlEntry.getValue(HtmlEntry.PARSED_UNIT)), false);
+ return new AnalysisContextImpl_TaskData(
+ new ResolveHtmlTask(this, source, htmlEntry.modificationTime,
+ htmlEntry.getValue(HtmlEntry.PARSED_UNIT)),
+ false);
}
/**
@@ -3720,8 +3750,11 @@ class AnalysisContextImpl implements InternalAnalysisContext {
* related to it. Return the task that should be performed, or `null` if there
* is no more work to be done for the source.
*/
- AnalysisContextImpl_TaskData _getNextAnalysisTaskForSource(Source source,
- SourceEntry sourceEntry, bool isPriority, bool hintsEnabled,
+ AnalysisContextImpl_TaskData _getNextAnalysisTaskForSource(
+ Source source,
+ SourceEntry sourceEntry,
+ bool isPriority,
+ bool hintsEnabled,
bool lintsEnabled) {
// Refuse to generate tasks for html based files that are above 1500 KB
if (_isTooBigHtmlSourceEntry(source, sourceEntry)) {
@@ -3911,7 +3944,8 @@ class AnalysisContextImpl implements InternalAnalysisContext {
DartEntry dartEntry = sourceEntry;
if (dartEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) ==
CacheState.VALID) {
- return new TimestampedData<CompilationUnit>(dartEntry.modificationTime,
+ return new TimestampedData<CompilationUnit>(
+ dartEntry.modificationTime,
dartEntry.getValueInLibrary(
DartEntry.RESOLVED_UNIT, librarySource));
}
@@ -3941,8 +3975,12 @@ class AnalysisContextImpl implements InternalAnalysisContext {
* [_getNextAnalysisTaskForSource]. This method is intended to be used for
* testing purposes only.
*/
- void _getSourcesNeedingProcessing(Source source, SourceEntry sourceEntry,
- bool isPriority, bool hintsEnabled, bool lintsEnabled,
+ void _getSourcesNeedingProcessing(
+ Source source,
+ SourceEntry sourceEntry,
+ bool isPriority,
+ bool hintsEnabled,
+ bool lintsEnabled,
HashSet<Source> sources) {
if (sourceEntry is DartEntry) {
DartEntry dartEntry = sourceEntry;
@@ -4796,11 +4834,18 @@ class AnalysisContextImpl implements InternalAnalysisContext {
// do resolution
Stopwatch perfCounter = new Stopwatch()..start();
PoorMansIncrementalResolver resolver = new PoorMansIncrementalResolver(
- typeProvider, unitSource, getReadableSourceEntryOrNull(unitSource),
- null, null, oldUnit, analysisOptions.incrementalApi, analysisOptions);
+ typeProvider,
+ unitSource,
+ getReadableSourceEntryOrNull(unitSource),
+ null,
+ null,
+ oldUnit,
+ analysisOptions.incrementalApi,
+ analysisOptions);
bool success = resolver.resolve(newCode);
AnalysisEngine.instance.instrumentationService.logPerformance(
- AnalysisPerformanceKind.INCREMENTAL, perfCounter,
+ AnalysisPerformanceKind.INCREMENTAL,
+ perfCounter,
'success=$success,context_id=$_id,code_length=${newCode.length}');
if (!success) {
return false;
@@ -5020,8 +5065,8 @@ class AnalysisContextImpl_CycleBuilder {
// library.
AnalysisTask task = _taskData.task;
if (task is ResolveDartLibraryTask) {
- AnalysisContextImpl_this._workManager.addFirst(
- task.librarySource, SourcePriority.LIBRARY);
+ AnalysisContextImpl_this._workManager
+ .addFirst(task.librarySource, SourcePriority.LIBRARY);
}
return;
}
@@ -5249,8 +5294,8 @@ class AnalysisContextImpl_CycleBuilder {
AnalysisContextImpl_this._getReadableDartEntry(librarySource);
if (libraryEntry != null &&
libraryEntry.getState(DartEntry.PARSED_UNIT) != CacheState.ERROR) {
- AnalysisContextImpl_this._workManager.addFirst(
- librarySource, SourcePriority.LIBRARY);
+ AnalysisContextImpl_this._workManager
+ .addFirst(librarySource, SourcePriority.LIBRARY);
if (_taskData == null) {
_taskData = AnalysisContextImpl_this._createResolveDartLibraryTask(
librarySource, libraryEntry);
@@ -6567,8 +6612,8 @@ abstract class AnalysisTask {
if (contextName == null) {
contextName = 'unnamed';
}
- AnalysisEngine.instance.instrumentationService.logAnalysisTask(
- contextName, taskDescription);
+ AnalysisEngine.instance.instrumentationService
+ .logAnalysisTask(contextName, taskDescription);
internalPerform();
} on AnalysisException {
rethrow;
@@ -8402,8 +8447,11 @@ class GenerateDartErrorsTask extends AnalysisTask {
//
// Use the ErrorVerifier to compute the rest of the errors.
//
- ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter,
- libraryElement, typeProvider, new InheritanceManager(libraryElement),
+ ErrorVerifier errorVerifier = new ErrorVerifier(
+ errorReporter,
+ libraryElement,
+ typeProvider,
+ new InheritanceManager(libraryElement),
context.analysisOptions.enableSuperMixins);
_unit.accept(errorVerifier);
_errors = errorListener.getErrorsForSource(source);
@@ -8438,8 +8486,10 @@ class GenerateDartErrorsTask extends AnalysisTask {
* @param directive the directive to be verified
* @param errorListener the error listener to which errors should be reported
*/
- static void validateReferencedSource(AnalysisContext context,
- Source librarySource, UriBasedDirective directive,
+ static void validateReferencedSource(
+ AnalysisContext context,
+ Source librarySource,
+ UriBasedDirective directive,
AnalysisErrorListener errorListener) {
Source source = directive.source;
if (source != null) {
@@ -8453,8 +8503,11 @@ class GenerateDartErrorsTask extends AnalysisTask {
}
}
StringLiteral uriLiteral = directive.uri;
- errorListener.onError(new AnalysisError(librarySource, uriLiteral.offset,
- uriLiteral.length, CompileTimeErrorCode.URI_DOES_NOT_EXIST,
+ errorListener.onError(new AnalysisError(
+ librarySource,
+ uriLiteral.offset,
+ uriLiteral.length,
+ CompileTimeErrorCode.URI_DOES_NOT_EXIST,
[directive.uriContent]));
}
}
@@ -8546,7 +8599,6 @@ class GenerateDartHintsTask extends AnalysisTask {
/// Generates lint feedback for a single Dart library.
class GenerateDartLintsTask extends AnalysisTask {
-
///The compilation units that comprise the library, with the defining
///compilation unit appearing first in the list.
final List<TimestampedData<CompilationUnit>> _units;
@@ -8676,8 +8728,8 @@ class GetContentTask extends AnalysisTask {
TimestampedData<String> data = context.getContents(source);
_content = data.data;
_modificationTime = data.modificationTime;
- AnalysisEngine.instance.instrumentationService.logFileRead(
- source.fullName, _modificationTime, _content);
+ AnalysisEngine.instance.instrumentationService
+ .logFileRead(source.fullName, _modificationTime, _content);
} catch (exception, stackTrace) {
errors.add(new AnalysisError(
source, 0, 0, ScannerErrorCode.UNABLE_GET_CONTENT, [exception]));
@@ -8962,8 +9014,14 @@ class IncrementalAnalysisCache {
int _newLength = 0;
- IncrementalAnalysisCache(this.librarySource, this.source, this.resolvedUnit,
- this.oldContents, this._newContents, this._offset, this._oldLength,
+ IncrementalAnalysisCache(
+ this.librarySource,
+ this.source,
+ this.resolvedUnit,
+ this.oldContents,
+ this._newContents,
+ this._offset,
+ this._oldLength,
this._newLength);
/**
@@ -9048,9 +9106,15 @@ class IncrementalAnalysisCache {
* @return the cache used for incremental analysis or `null` if incremental analysis cannot
* be performed
*/
- static IncrementalAnalysisCache update(IncrementalAnalysisCache cache,
- Source source, String oldContents, String newContents, int offset,
- int oldLength, int newLength, SourceEntry sourceEntry) {
+ static IncrementalAnalysisCache update(
+ IncrementalAnalysisCache cache,
+ Source source,
+ String oldContents,
+ String newContents,
+ int offset,
+ int oldLength,
+ int newLength,
+ SourceEntry sourceEntry) {
// Determine the cache resolved unit
Source librarySource = null;
CompilationUnit unit = null;
@@ -9476,8 +9540,9 @@ class ObsoleteSourceAnalysisException extends AnalysisException {
* Initialize a newly created exception to represent the removal of the given
* [source].
*/
- ObsoleteSourceAnalysisException(Source source) : super(
- "The source '${source.fullName}' was removed while it was being analyzed") {
+ ObsoleteSourceAnalysisException(Source source)
+ : super(
+ "The source '${source.fullName}' was removed while it was being analyzed") {
this._source = source;
}
@@ -10834,8 +10899,11 @@ class ResolveDartUnitTask extends AnalysisTask {
//
PerformanceStatistics.errors.makeCurrentWhile(() {
ErrorReporter errorReporter = new ErrorReporter(errorListener, source);
- ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter,
- _libraryElement, typeProvider, inheritanceManager,
+ ErrorVerifier errorVerifier = new ErrorVerifier(
+ errorReporter,
+ _libraryElement,
+ typeProvider,
+ inheritanceManager,
context.analysisOptions.enableSuperMixins);
unit.accept(errorVerifier);
// TODO(paulberry): as a temporary workaround for issue 21572,

Powered by Google App Engine
This is Rietveld 408576698