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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine; 8 library engine;
9 9
10 import "dart:math" as math; 10 import "dart:math" as math;
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 */ 412 */
413 String get name; 413 String get name;
414 414
415 /** 415 /**
416 * Set the client-provided name used to identify this context to the given 416 * Set the client-provided name used to identify this context to the given
417 * [name]. 417 * [name].
418 */ 418 */
419 set name(String name); 419 set name(String name);
420 420
421 /** 421 /**
422 * Returns a type provider for this context or throws [AnalysisException] if
423 * `dart:core` or `dart:async` cannot be resolved.
424 */
425 TypeProvider get typeProvider;
426
427 /**
428 * The stream that is notified when sources have been added or removed, 422 * The stream that is notified when sources have been added or removed,
429 * or the source's content has changed. 423 * or the source's content has changed.
430 */ 424 */
431 Stream<SourcesChangedEvent> get onSourcesChanged; 425 Stream<SourcesChangedEvent> get onSourcesChanged;
432 426
433 /** 427 /**
434 * Return an array containing all of the sources known to this context and the ir resolution state 428 * Return an array containing all of the sources known to this context and the ir resolution state
435 * is not valid or flush. So, these sources are not safe to update during refa ctoring, because we 429 * is not valid or flush. So, these sources are not safe to update during refa ctoring, because we
436 * may be don't know all the references in them. 430 * may be don't know all the references in them.
437 * 431 *
(...skipping 12 matching lines...) Expand all
450 * Set the source factory used to create the sources that can be analyzed in t his context to the 444 * Set the source factory used to create the sources that can be analyzed in t his context to the
451 * given source factory. Clients can safely assume that all analysis results h ave been 445 * given source factory. Clients can safely assume that all analysis results h ave been
452 * invalidated. 446 * invalidated.
453 * 447 *
454 * @param factory the source factory used to create the sources that can be an alyzed in this 448 * @param factory the source factory used to create the sources that can be an alyzed in this
455 * context 449 * context
456 */ 450 */
457 void set sourceFactory(SourceFactory factory); 451 void set sourceFactory(SourceFactory factory);
458 452
459 /** 453 /**
454 * Return an array containing all of the sources known to this context.
455 *
456 * @return all of the sources known to this context
457 */
458 List<Source> get sources;
459
460 /**
461 * Returns a type provider for this context or throws [AnalysisException] if
462 * `dart:core` or `dart:async` cannot be resolved.
463 */
464 TypeProvider get typeProvider;
465
466 /**
460 * Add the given listener to the list of objects that are to be notified when various analysis 467 * Add the given listener to the list of objects that are to be notified when various analysis
461 * results are produced in this context. 468 * results are produced in this context.
462 * 469 *
463 * @param listener the listener to be added 470 * @param listener the listener to be added
464 */ 471 */
465 void addListener(AnalysisListener listener); 472 void addListener(AnalysisListener listener);
466 473
467 /** 474 /**
468 * Apply the given delta to change the level of analysis that will be performe d for the sources 475 * Apply the given delta to change the level of analysis that will be performe d for the sources
469 * known to this context. 476 * known to this context.
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 new StreamController<SourcesChangedEvent>.broadcast(); 1127 new StreamController<SourcesChangedEvent>.broadcast();
1121 } 1128 }
1122 1129
1123 @override 1130 @override
1124 AnalysisOptions get analysisOptions => _options; 1131 AnalysisOptions get analysisOptions => _options;
1125 1132
1126 @override 1133 @override
1127 void set analysisOptions(AnalysisOptions options) { 1134 void set analysisOptions(AnalysisOptions options) {
1128 bool needsRecompute = this._options.analyzeFunctionBodiesPredicate != 1135 bool needsRecompute = this._options.analyzeFunctionBodiesPredicate !=
1129 options.analyzeFunctionBodiesPredicate || 1136 options.analyzeFunctionBodiesPredicate ||
1130 this._options.generateImplicitErrors != options.generateImplicitErro rs || 1137 this._options.generateImplicitErrors !=
1138 options.generateImplicitErrors ||
1131 this._options.generateSdkErrors != options.generateSdkErrors || 1139 this._options.generateSdkErrors != options.generateSdkErrors ||
1132 this._options.dart2jsHint != options.dart2jsHint || 1140 this._options.dart2jsHint != options.dart2jsHint ||
1133 (this._options.hint && !options.hint) || 1141 (this._options.hint && !options.hint) ||
1134 this._options.preserveComments != options.preserveComments; 1142 this._options.preserveComments != options.preserveComments;
1135 int cacheSize = options.cacheSize; 1143 int cacheSize = options.cacheSize;
1136 if (this._options.cacheSize != cacheSize) { 1144 if (this._options.cacheSize != cacheSize) {
1137 this._options.cacheSize = cacheSize; 1145 this._options.cacheSize = cacheSize;
1138 //cache.setMaxCacheSize(cacheSize); 1146 //cache.setMaxCacheSize(cacheSize);
1139 _privatePartition.maxCacheSize = cacheSize; 1147 _privatePartition.maxCacheSize = cacheSize;
1140 // 1148 //
1141 // Cap the size of the priority list to being less than the cache size. 1149 // Cap the size of the priority list to being less than the cache size.
1142 // Failure to do so can result in an infinite loop in 1150 // Failure to do so can result in an infinite loop in
1143 // performAnalysisTask() because re-caching one AST structure 1151 // performAnalysisTask() because re-caching one AST structure
1144 // can cause another priority source's AST structure to be flushed. 1152 // can cause another priority source's AST structure to be flushed.
1145 // 1153 //
1146 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; 1154 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA;
1147 if (_priorityOrder.length > maxPriorityOrderSize) { 1155 if (_priorityOrder.length > maxPriorityOrderSize) {
1148 List<Source> newPriorityOrder = new List<Source>(maxPriorityOrderSize); 1156 List<Source> newPriorityOrder = new List<Source>(maxPriorityOrderSize);
1149 JavaSystem.arraycopy( 1157 JavaSystem.arraycopy(
1150 _priorityOrder, 0, newPriorityOrder, 0, maxPriorityOrderSize); 1158 _priorityOrder, 0, newPriorityOrder, 0, maxPriorityOrderSize);
1151 _priorityOrder = newPriorityOrder; 1159 _priorityOrder = newPriorityOrder;
1152 } 1160 }
1153 } 1161 }
1154 this._options.analyzeFunctionBodiesPredicate = 1162 this._options.analyzeFunctionBodiesPredicate =
1155 options.analyzeFunctionBodiesPredicate; 1163 options.analyzeFunctionBodiesPredicate;
1156 this._options.generateImplicitErrors = options.generateImplicitErrors; 1164 this._options.generateImplicitErrors = options.generateImplicitErrors;
1157 this._options.generateSdkErrors = options.generateSdkErrors; 1165 this._options.generateSdkErrors = options.generateSdkErrors;
1158 this._options.dart2jsHint = options.dart2jsHint; 1166 this._options.dart2jsHint = options.dart2jsHint;
1159 this._options.hint = options.hint; 1167 this._options.hint = options.hint;
1160 this._options.incremental = options.incremental; 1168 this._options.incremental = options.incremental;
1161 this._options.incrementalApi = options.incrementalApi; 1169 this._options.incrementalApi = options.incrementalApi;
1162 this._options.incrementalValidation = options.incrementalValidation; 1170 this._options.incrementalValidation = options.incrementalValidation;
1163 this._options.lint = options.lint; 1171 this._options.lint = options.lint;
1164 this._options.preserveComments = options.preserveComments; 1172 this._options.preserveComments = options.preserveComments;
1165 _generateImplicitErrors = options.generateImplicitErrors; 1173 _generateImplicitErrors = options.generateImplicitErrors;
1166 _generateSdkErrors = options.generateSdkErrors; 1174 _generateSdkErrors = options.generateSdkErrors;
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 _sourceFactory.context = null; 1441 _sourceFactory.context = null;
1434 } 1442 }
1435 factory.context = this; 1443 factory.context = this;
1436 _sourceFactory = factory; 1444 _sourceFactory = factory;
1437 _coreLibrarySource = _sourceFactory.forUri(DartSdk.DART_CORE); 1445 _coreLibrarySource = _sourceFactory.forUri(DartSdk.DART_CORE);
1438 _asyncLibrarySource = _sourceFactory.forUri(DartSdk.DART_ASYNC); 1446 _asyncLibrarySource = _sourceFactory.forUri(DartSdk.DART_ASYNC);
1439 _cache = createCacheFromSourceFactory(factory); 1447 _cache = createCacheFromSourceFactory(factory);
1440 _invalidateAllLocalResolutionInformation(true); 1448 _invalidateAllLocalResolutionInformation(true);
1441 } 1449 }
1442 1450
1451 @override
1452 List<Source> get sources {
1453 List<Source> sources = new List<Source>();
1454 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
1455 while (iterator.moveNext()) {
1456 sources.add(iterator.key);
1457 }
1458 return sources;
1459 }
1460
1443 /** 1461 /**
1444 * Return a list of the sources that would be processed by [performAnalysisTas k]. This 1462 * Return a list of the sources that would be processed by [performAnalysisTas k]. This
1445 * method duplicates, and must therefore be kept in sync with, [getNextAnalysi sTask]. 1463 * method duplicates, and must therefore be kept in sync with, [getNextAnalysi sTask].
1446 * This method is intended to be used for testing purposes only. 1464 * This method is intended to be used for testing purposes only.
1447 * 1465 *
1448 * @return a list of the sources that would be processed by [performAnalysisTa sk] 1466 * @return a list of the sources that would be processed by [performAnalysisTa sk]
1449 */ 1467 */
1450 List<Source> get sourcesNeedingProcessing { 1468 List<Source> get sourcesNeedingProcessing {
1451 HashSet<Source> sources = new HashSet<Source>(); 1469 HashSet<Source> sources = new HashSet<Source>();
1452 bool hintsEnabled = _options.hint; 1470 bool hintsEnabled = _options.hint;
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2618 } 2636 }
2619 callback(librarySource, sourceEntry, descriptor, 2637 callback(librarySource, sourceEntry, descriptor,
2620 sourceEntry.getStateInLibrary(descriptor, librarySource)); 2638 sourceEntry.getStateInLibrary(descriptor, librarySource));
2621 } 2639 }
2622 } 2640 }
2623 } 2641 }
2624 } 2642 }
2625 } 2643 }
2626 2644
2627 /** 2645 /**
2628 * Return `true` if errors should be produced for the given [source]. The
2629 * [dartEntry] associated with the source is passed in for efficiency.
2630 */
2631 bool _shouldErrorsBeAnalyzed(Source source, DartEntry dartEntry) {
2632 if (source.isInSystemLibrary) {
2633 return _generateSdkErrors;
2634 } else if (!dartEntry.explicitlyAdded) {
2635 return _generateImplicitErrors;
2636 } else {
2637 return true;
2638 }
2639 }
2640
2641 /**
2642 * Visit all entries of the content cache. 2646 * Visit all entries of the content cache.
2643 */ 2647 */
2644 void visitContentCache(ContentCacheVisitor visitor) { 2648 void visitContentCache(ContentCacheVisitor visitor) {
2645 _contentCache.accept(visitor); 2649 _contentCache.accept(visitor);
2646 } 2650 }
2647 2651
2648 /** 2652 /**
2649 * Record that we have accessed the AST structure associated with the given so urce. At the moment, 2653 * Record that we have accessed the AST structure associated with the given so urce. At the moment,
2650 * there is no differentiation between the parsed and resolved forms of the AS T. 2654 * there is no differentiation between the parsed and resolved forms of the AS T.
2651 * 2655 *
(...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after
4322 _workManager.add(source, SourcePriority.UNKNOWN); 4326 _workManager.add(source, SourcePriority.UNKNOWN);
4323 } 4327 }
4324 // reset unit in the notification, it is out of date now 4328 // reset unit in the notification, it is out of date now
4325 ChangeNoticeImpl notice = _pendingNotices[source]; 4329 ChangeNoticeImpl notice = _pendingNotices[source];
4326 if (notice != null) { 4330 if (notice != null) {
4327 notice.resolvedDartUnit = null; 4331 notice.resolvedDartUnit = null;
4328 notice.resolvedHtmlUnit = null; 4332 notice.resolvedHtmlUnit = null;
4329 } 4333 }
4330 } 4334 }
4331 4335
4336 /**
4337 * Record the results produced by performing a [task] and return the cache
4338 * entry associated with the results.
4339 */
4340 DartEntry _recordBuildUnitElementTask(BuildUnitElementTask task) {
4341 Source source = task.source;
4342 Source library = task.library;
4343 DartEntry dartEntry = _cache.get(source);
4344 CaughtException thrownException = task.exception;
4345 if (thrownException != null) {
4346 dartEntry.recordBuildElementErrorInLibrary(library, thrownException);
4347 throw new AnalysisException('<rethrow>', thrownException);
4348 }
4349 dartEntry.setValueInLibrary(DartEntry.BUILT_UNIT, library, task.unit);
4350 dartEntry.setValueInLibrary(
4351 DartEntry.BUILT_ELEMENT, library, task.unitElement);
4352 ChangeNoticeImpl notice = _getNotice(source);
4353 LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO);
4354 notice.setErrors(dartEntry.allErrors, lineInfo);
4355 return dartEntry;
4356 }
4357
4332 // /** 4358 // /**
4333 // * Notify all of the analysis listeners that the given source is no longer i ncluded in the set of 4359 // * Notify all of the analysis listeners that the given source is no longer i ncluded in the set of
4334 // * sources that are being analyzed. 4360 // * sources that are being analyzed.
4335 // * 4361 // *
4336 // * @param source the source that is no longer being analyzed 4362 // * @param source the source that is no longer being analyzed
4337 // */ 4363 // */
4338 // void _notifyExcludedSource(Source source) { 4364 // void _notifyExcludedSource(Source source) {
4339 // int count = _listeners.length; 4365 // int count = _listeners.length;
4340 // for (int i = 0; i < count; i++) { 4366 // for (int i = 0; i < count; i++) {
4341 // _listeners[i].excludedSource(this, source); 4367 // _listeners[i].excludedSource(this, source);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
4401 // * @param unit the result of resolving the source 4427 // * @param unit the result of resolving the source
4402 // */ 4428 // */
4403 // void _notifyResolvedHtml(Source source, ht.HtmlUnit unit) { 4429 // void _notifyResolvedHtml(Source source, ht.HtmlUnit unit) {
4404 // int count = _listeners.length; 4430 // int count = _listeners.length;
4405 // for (int i = 0; i < count; i++) { 4431 // for (int i = 0; i < count; i++) {
4406 // _listeners[i].resolvedHtml(this, source, unit); 4432 // _listeners[i].resolvedHtml(this, source, unit);
4407 // } 4433 // }
4408 // } 4434 // }
4409 4435
4410 /** 4436 /**
4411 * Record the results produced by performing a [task] and return the cache
4412 * entry associated with the results.
4413 */
4414 DartEntry _recordBuildUnitElementTask(BuildUnitElementTask task) {
4415 Source source = task.source;
4416 Source library = task.library;
4417 DartEntry dartEntry = _cache.get(source);
4418 CaughtException thrownException = task.exception;
4419 if (thrownException != null) {
4420 dartEntry.recordBuildElementErrorInLibrary(library, thrownException);
4421 throw new AnalysisException('<rethrow>', thrownException);
4422 }
4423 dartEntry.setValueInLibrary(DartEntry.BUILT_UNIT, library, task.unit);
4424 dartEntry.setValueInLibrary(
4425 DartEntry.BUILT_ELEMENT, library, task.unitElement);
4426 ChangeNoticeImpl notice = _getNotice(source);
4427 LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO);
4428 notice.setErrors(dartEntry.allErrors, lineInfo);
4429 return dartEntry;
4430 }
4431
4432 /**
4433 * Given a cache entry and a library element, record the library element and o ther information 4437 * Given a cache entry and a library element, record the library element and o ther information
4434 * gleaned from the element in the cache entry. 4438 * gleaned from the element in the cache entry.
4435 * 4439 *
4436 * @param dartCopy the cache entry in which data is to be recorded 4440 * @param dartCopy the cache entry in which data is to be recorded
4437 * @param library the library element used to record information 4441 * @param library the library element used to record information
4438 * @param librarySource the source for the library used to record information 4442 * @param librarySource the source for the library used to record information
4439 * @param htmlSource the source for the HTML library 4443 * @param htmlSource the source for the HTML library
4440 */ 4444 */
4441 void _recordElementData(DartEntry dartEntry, LibraryElement library, 4445 void _recordElementData(DartEntry dartEntry, LibraryElement library,
4442 Source librarySource, Source htmlSource) { 4446 Source librarySource, Source htmlSource) {
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
4818 if (_priorityOrder[i] != source) { 4822 if (_priorityOrder[i] != source) {
4819 newOrder.add(_priorityOrder[i]); 4823 newOrder.add(_priorityOrder[i]);
4820 } 4824 }
4821 } 4825 }
4822 if (newOrder.length < count) { 4826 if (newOrder.length < count) {
4823 analysisPriorityOrder = newOrder; 4827 analysisPriorityOrder = newOrder;
4824 } 4828 }
4825 } 4829 }
4826 4830
4827 /** 4831 /**
4832 * Return `true` if errors should be produced for the given [source]. The
4833 * [dartEntry] associated with the source is passed in for efficiency.
4834 */
4835 bool _shouldErrorsBeAnalyzed(Source source, DartEntry dartEntry) {
4836 if (source.isInSystemLibrary) {
4837 return _generateSdkErrors;
4838 } else if (!dartEntry.explicitlyAdded) {
4839 return _generateImplicitErrors;
4840 } else {
4841 return true;
4842 }
4843 }
4844
4845 /**
4828 * Create an entry for the newly added [source] and invalidate any sources 4846 * Create an entry for the newly added [source] and invalidate any sources
4829 * that referenced the source before it existed. 4847 * that referenced the source before it existed.
4830 * 4848 *
4831 * <b>Note:</b> This method must only be invoked while we are synchronized on 4849 * <b>Note:</b> This method must only be invoked while we are synchronized on
4832 * [cacheLock]. 4850 * [cacheLock].
4833 */ 4851 */
4834 void _sourceAvailable(Source source) { 4852 void _sourceAvailable(Source source) {
4835 SourceEntry sourceEntry = _cache.get(source); 4853 SourceEntry sourceEntry = _cache.get(source);
4836 if (sourceEntry == null) { 4854 if (sourceEntry == null) {
4837 sourceEntry = _createSourceEntry(source, true); 4855 sourceEntry = _createSourceEntry(source, true);
(...skipping 7330 matching lines...) Expand 10 before | Expand all | Expand 10 after
12168 visitElement(Element element) { 12186 visitElement(Element element) {
12169 if (element.id == _id) { 12187 if (element.id == _id) {
12170 result = element; 12188 result = element;
12171 throw new _ElementByIdFinderException(); 12189 throw new _ElementByIdFinderException();
12172 } 12190 }
12173 super.visitElement(element); 12191 super.visitElement(element);
12174 } 12192 }
12175 } 12193 }
12176 12194
12177 class _ElementByIdFinderException {} 12195 class _ElementByIdFinderException {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698