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

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

Issue 987143002: Fix for dartbug.com/22656- analysis.flushedResults implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: comment Created 5 years, 9 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 d90a771f9ff7da80044900e15b2be57c169ffb45..3064867c0e961b7307151526d94a7a5b949ec08d 100644
--- a/pkg/analyzer/lib/src/generated/engine.dart
+++ b/pkg/analyzer/lib/src/generated/engine.dart
@@ -419,12 +419,6 @@ abstract class AnalysisContext {
set name(String name);
/**
- * Returns a type provider for this context or throws [AnalysisException] if
- * `dart:core` or `dart:async` cannot be resolved.
- */
- TypeProvider get typeProvider;
-
- /**
* The stream that is notified when sources have been added or removed,
* or the source's content has changed.
*/
@@ -457,6 +451,19 @@ abstract class AnalysisContext {
void set sourceFactory(SourceFactory factory);
/**
+ * Return an array containing all of the sources known to this context.
+ *
+ * @return all of the sources known to this context
+ */
+ List<Source> get sources;
+
+ /**
+ * Returns a type provider for this context or throws [AnalysisException] if
+ * `dart:core` or `dart:async` cannot be resolved.
+ */
+ TypeProvider get typeProvider;
+
+ /**
* Add the given listener to the list of objects that are to be notified when various analysis
* results are produced in this context.
*
@@ -1127,7 +1134,8 @@ class AnalysisContextImpl implements InternalAnalysisContext {
void set analysisOptions(AnalysisOptions options) {
bool needsRecompute = this._options.analyzeFunctionBodiesPredicate !=
options.analyzeFunctionBodiesPredicate ||
- this._options.generateImplicitErrors != options.generateImplicitErrors ||
+ this._options.generateImplicitErrors !=
+ options.generateImplicitErrors ||
this._options.generateSdkErrors != options.generateSdkErrors ||
this._options.dart2jsHint != options.dart2jsHint ||
(this._options.hint && !options.hint) ||
@@ -1153,7 +1161,7 @@ class AnalysisContextImpl implements InternalAnalysisContext {
}
this._options.analyzeFunctionBodiesPredicate =
options.analyzeFunctionBodiesPredicate;
- this._options.generateImplicitErrors = options.generateImplicitErrors;
+ this._options.generateImplicitErrors = options.generateImplicitErrors;
this._options.generateSdkErrors = options.generateSdkErrors;
this._options.dart2jsHint = options.dart2jsHint;
this._options.hint = options.hint;
@@ -1440,6 +1448,16 @@ class AnalysisContextImpl implements InternalAnalysisContext {
_invalidateAllLocalResolutionInformation(true);
}
+ @override
+ List<Source> get sources {
+ List<Source> sources = new List<Source>();
+ MapIterator<Source, SourceEntry> iterator = _cache.iterator();
+ while (iterator.moveNext()) {
+ sources.add(iterator.key);
+ }
+ return sources;
+ }
+
/**
* Return a list of the sources that would be processed by [performAnalysisTask]. This
* method duplicates, and must therefore be kept in sync with, [getNextAnalysisTask].
@@ -2625,20 +2643,6 @@ class AnalysisContextImpl implements InternalAnalysisContext {
}
/**
- * Return `true` if errors should be produced for the given [source]. The
- * [dartEntry] associated with the source is passed in for efficiency.
- */
- bool _shouldErrorsBeAnalyzed(Source source, DartEntry dartEntry) {
- if (source.isInSystemLibrary) {
- return _generateSdkErrors;
- } else if (!dartEntry.explicitlyAdded) {
- return _generateImplicitErrors;
- } else {
- return true;
- }
- }
-
- /**
* Visit all entries of the content cache.
*/
void visitContentCache(ContentCacheVisitor visitor) {
@@ -4329,6 +4333,28 @@ class AnalysisContextImpl implements InternalAnalysisContext {
}
}
+ /**
+ * Record the results produced by performing a [task] and return the cache
+ * entry associated with the results.
+ */
+ DartEntry _recordBuildUnitElementTask(BuildUnitElementTask task) {
+ Source source = task.source;
+ Source library = task.library;
+ DartEntry dartEntry = _cache.get(source);
+ CaughtException thrownException = task.exception;
+ if (thrownException != null) {
+ dartEntry.recordBuildElementErrorInLibrary(library, thrownException);
+ throw new AnalysisException('<rethrow>', thrownException);
+ }
+ dartEntry.setValueInLibrary(DartEntry.BUILT_UNIT, library, task.unit);
+ dartEntry.setValueInLibrary(
+ DartEntry.BUILT_ELEMENT, library, task.unitElement);
+ ChangeNoticeImpl notice = _getNotice(source);
+ LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO);
+ notice.setErrors(dartEntry.allErrors, lineInfo);
+ return dartEntry;
+ }
+
// /**
// * Notify all of the analysis listeners that the given source is no longer included in the set of
// * sources that are being analyzed.
@@ -4408,28 +4434,6 @@ class AnalysisContextImpl implements InternalAnalysisContext {
// }
/**
- * Record the results produced by performing a [task] and return the cache
- * entry associated with the results.
- */
- DartEntry _recordBuildUnitElementTask(BuildUnitElementTask task) {
- Source source = task.source;
- Source library = task.library;
- DartEntry dartEntry = _cache.get(source);
- CaughtException thrownException = task.exception;
- if (thrownException != null) {
- dartEntry.recordBuildElementErrorInLibrary(library, thrownException);
- throw new AnalysisException('<rethrow>', thrownException);
- }
- dartEntry.setValueInLibrary(DartEntry.BUILT_UNIT, library, task.unit);
- dartEntry.setValueInLibrary(
- DartEntry.BUILT_ELEMENT, library, task.unitElement);
- ChangeNoticeImpl notice = _getNotice(source);
- LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO);
- notice.setErrors(dartEntry.allErrors, lineInfo);
- return dartEntry;
- }
-
- /**
* Given a cache entry and a library element, record the library element and other information
* gleaned from the element in the cache entry.
*
@@ -4825,6 +4829,20 @@ class AnalysisContextImpl implements InternalAnalysisContext {
}
/**
+ * Return `true` if errors should be produced for the given [source]. The
+ * [dartEntry] associated with the source is passed in for efficiency.
+ */
+ bool _shouldErrorsBeAnalyzed(Source source, DartEntry dartEntry) {
+ if (source.isInSystemLibrary) {
+ return _generateSdkErrors;
+ } else if (!dartEntry.explicitlyAdded) {
+ return _generateImplicitErrors;
+ } else {
+ return true;
+ }
+ }
+
+ /**
* Create an entry for the newly added [source] and invalidate any sources
* that referenced the source before it existed.
*

Powered by Google App Engine
This is Rietveld 408576698