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

Side by Side Diff: pkg/analyzer/lib/src/generated/engine.dart

Issue 981283003: Change all sources associated with changed files (issue 22680) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments 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 * Returns a type provider for this context or throws [AnalysisException] if
455 * `dart:core` or `dart:async` cannot be resolved.
456 */
457 TypeProvider get typeProvider;
458
459 /**
460 * Add the given listener to the list of objects that are to be notified when various analysis 460 * Add the given listener to the list of objects that are to be notified when various analysis
461 * results are produced in this context. 461 * results are produced in this context.
462 * 462 *
463 * @param listener the listener to be added 463 * @param listener the listener to be added
464 */ 464 */
465 void addListener(AnalysisListener listener); 465 void addListener(AnalysisListener listener);
466 466
467 /** 467 /**
468 * Apply the given delta to change the level of analysis that will be performe d for the sources 468 * Apply the given delta to change the level of analysis that will be performe d for the sources
469 * known to this context. 469 * known to this context.
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 * Return a fully resolved HTML unit, or `null` if the resolved unit is not al ready 780 * Return a fully resolved HTML unit, or `null` if the resolved unit is not al ready
781 * computed. 781 * computed.
782 * 782 *
783 * @param htmlSource the source of the HTML unit 783 * @param htmlSource the source of the HTML unit
784 * @return a fully resolved HTML unit 784 * @return a fully resolved HTML unit
785 * See [resolveHtmlUnit]. 785 * See [resolveHtmlUnit].
786 */ 786 */
787 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource); 787 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource);
788 788
789 /** 789 /**
790 * Return a list of the sources being analyzed in this context whose full path
791 * is equal to the given [path].
792 */
793 List<Source> getSourcesWithFullName(String path);
794
795 /**
790 * Return `true` if the given source is known to be the defining compilation u nit of a 796 * Return `true` if the given source is known to be the defining compilation u nit of a
791 * library that can be run on a client (references 'dart:html', either directl y or indirectly). 797 * library that can be run on a client (references 'dart:html', either directl y or indirectly).
792 * 798 *
793 * <b>Note:</b> In addition to the expected case of returning `false` if the s ource is known 799 * <b>Note:</b> In addition to the expected case of returning `false` if the s ource is known
794 * to be a library that cannot be run on a client, this method will also retur n `false` if 800 * to be a library that cannot be run on a client, this method will also retur n `false` if
795 * the source is not known to be a library or if we do not know whether it can be run on a client. 801 * the source is not known to be a library or if we do not know whether it can be run on a client.
796 * 802 *
797 * @param librarySource the source being tested 803 * @param librarySource the source being tested
798 * @return `true` if the given source is known to be a library that can be run on a client 804 * @return `true` if the given source is known to be a library that can be run on a client
799 */ 805 */
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 new StreamController<SourcesChangedEvent>.broadcast(); 1126 new StreamController<SourcesChangedEvent>.broadcast();
1121 } 1127 }
1122 1128
1123 @override 1129 @override
1124 AnalysisOptions get analysisOptions => _options; 1130 AnalysisOptions get analysisOptions => _options;
1125 1131
1126 @override 1132 @override
1127 void set analysisOptions(AnalysisOptions options) { 1133 void set analysisOptions(AnalysisOptions options) {
1128 bool needsRecompute = this._options.analyzeFunctionBodiesPredicate != 1134 bool needsRecompute = this._options.analyzeFunctionBodiesPredicate !=
1129 options.analyzeFunctionBodiesPredicate || 1135 options.analyzeFunctionBodiesPredicate ||
1130 this._options.generateImplicitErrors != options.generateImplicitErro rs || 1136 this._options.generateImplicitErrors !=
1137 options.generateImplicitErrors ||
1131 this._options.generateSdkErrors != options.generateSdkErrors || 1138 this._options.generateSdkErrors != options.generateSdkErrors ||
1132 this._options.dart2jsHint != options.dart2jsHint || 1139 this._options.dart2jsHint != options.dart2jsHint ||
1133 (this._options.hint && !options.hint) || 1140 (this._options.hint && !options.hint) ||
1134 this._options.preserveComments != options.preserveComments; 1141 this._options.preserveComments != options.preserveComments;
1135 int cacheSize = options.cacheSize; 1142 int cacheSize = options.cacheSize;
1136 if (this._options.cacheSize != cacheSize) { 1143 if (this._options.cacheSize != cacheSize) {
1137 this._options.cacheSize = cacheSize; 1144 this._options.cacheSize = cacheSize;
1138 //cache.setMaxCacheSize(cacheSize); 1145 //cache.setMaxCacheSize(cacheSize);
1139 _privatePartition.maxCacheSize = cacheSize; 1146 _privatePartition.maxCacheSize = cacheSize;
1140 // 1147 //
1141 // Cap the size of the priority list to being less than the cache size. 1148 // 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 1149 // Failure to do so can result in an infinite loop in
1143 // performAnalysisTask() because re-caching one AST structure 1150 // performAnalysisTask() because re-caching one AST structure
1144 // can cause another priority source's AST structure to be flushed. 1151 // can cause another priority source's AST structure to be flushed.
1145 // 1152 //
1146 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; 1153 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA;
1147 if (_priorityOrder.length > maxPriorityOrderSize) { 1154 if (_priorityOrder.length > maxPriorityOrderSize) {
1148 List<Source> newPriorityOrder = new List<Source>(maxPriorityOrderSize); 1155 List<Source> newPriorityOrder = new List<Source>(maxPriorityOrderSize);
1149 JavaSystem.arraycopy( 1156 JavaSystem.arraycopy(
1150 _priorityOrder, 0, newPriorityOrder, 0, maxPriorityOrderSize); 1157 _priorityOrder, 0, newPriorityOrder, 0, maxPriorityOrderSize);
1151 _priorityOrder = newPriorityOrder; 1158 _priorityOrder = newPriorityOrder;
1152 } 1159 }
1153 } 1160 }
1154 this._options.analyzeFunctionBodiesPredicate = 1161 this._options.analyzeFunctionBodiesPredicate =
1155 options.analyzeFunctionBodiesPredicate; 1162 options.analyzeFunctionBodiesPredicate;
1156 this._options.generateImplicitErrors = options.generateImplicitErrors; 1163 this._options.generateImplicitErrors = options.generateImplicitErrors;
1157 this._options.generateSdkErrors = options.generateSdkErrors; 1164 this._options.generateSdkErrors = options.generateSdkErrors;
1158 this._options.dart2jsHint = options.dart2jsHint; 1165 this._options.dart2jsHint = options.dart2jsHint;
1159 this._options.hint = options.hint; 1166 this._options.hint = options.hint;
1160 this._options.incremental = options.incremental; 1167 this._options.incremental = options.incremental;
1161 this._options.incrementalApi = options.incrementalApi; 1168 this._options.incrementalApi = options.incrementalApi;
1162 this._options.incrementalValidation = options.incrementalValidation; 1169 this._options.incrementalValidation = options.incrementalValidation;
1163 this._options.lint = options.lint; 1170 this._options.lint = options.lint;
1164 this._options.preserveComments = options.preserveComments; 1171 this._options.preserveComments = options.preserveComments;
1165 _generateImplicitErrors = options.generateImplicitErrors; 1172 _generateImplicitErrors = options.generateImplicitErrors;
1166 _generateSdkErrors = options.generateSdkErrors; 1173 _generateSdkErrors = options.generateSdkErrors;
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { 2164 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) {
2158 SourceEntry sourceEntry = getReadableSourceEntryOrNull(htmlSource); 2165 SourceEntry sourceEntry = getReadableSourceEntryOrNull(htmlSource);
2159 if (sourceEntry is HtmlEntry) { 2166 if (sourceEntry is HtmlEntry) {
2160 HtmlEntry htmlEntry = sourceEntry; 2167 HtmlEntry htmlEntry = sourceEntry;
2161 return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); 2168 return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT);
2162 } 2169 }
2163 return null; 2170 return null;
2164 } 2171 }
2165 2172
2166 @override 2173 @override
2174 List<Source> getSourcesWithFullName(String path) {
2175 List<Source> sources = <Source>[];
2176 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
2177 while (iterator.moveNext()) {
2178 if (iterator.key.fullName == path) {
2179 sources.add(iterator.key);
2180 }
2181 }
2182 return sources;
2183 }
2184
2185 @override
2167 bool handleContentsChanged( 2186 bool handleContentsChanged(
2168 Source source, String originalContents, String newContents, bool notify) { 2187 Source source, String originalContents, String newContents, bool notify) {
2169 SourceEntry sourceEntry = _cache.get(source); 2188 SourceEntry sourceEntry = _cache.get(source);
2170 if (sourceEntry == null) { 2189 if (sourceEntry == null) {
2171 return false; 2190 return false;
2172 } 2191 }
2173 bool changed = newContents != originalContents; 2192 bool changed = newContents != originalContents;
2174 if (newContents != null) { 2193 if (newContents != null) {
2175 if (newContents != originalContents) { 2194 if (newContents != originalContents) {
2176 _incrementalAnalysisCache = 2195 _incrementalAnalysisCache =
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
2618 } 2637 }
2619 callback(librarySource, sourceEntry, descriptor, 2638 callback(librarySource, sourceEntry, descriptor,
2620 sourceEntry.getStateInLibrary(descriptor, librarySource)); 2639 sourceEntry.getStateInLibrary(descriptor, librarySource));
2621 } 2640 }
2622 } 2641 }
2623 } 2642 }
2624 } 2643 }
2625 } 2644 }
2626 2645
2627 /** 2646 /**
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. 2647 * Visit all entries of the content cache.
2643 */ 2648 */
2644 void visitContentCache(ContentCacheVisitor visitor) { 2649 void visitContentCache(ContentCacheVisitor visitor) {
2645 _contentCache.accept(visitor); 2650 _contentCache.accept(visitor);
2646 } 2651 }
2647 2652
2648 /** 2653 /**
2649 * Record that we have accessed the AST structure associated with the given so urce. At the moment, 2654 * 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. 2655 * there is no differentiation between the parsed and resolved forms of the AS T.
2651 * 2656 *
(...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after
4322 _workManager.add(source, SourcePriority.UNKNOWN); 4327 _workManager.add(source, SourcePriority.UNKNOWN);
4323 } 4328 }
4324 // reset unit in the notification, it is out of date now 4329 // reset unit in the notification, it is out of date now
4325 ChangeNoticeImpl notice = _pendingNotices[source]; 4330 ChangeNoticeImpl notice = _pendingNotices[source];
4326 if (notice != null) { 4331 if (notice != null) {
4327 notice.resolvedDartUnit = null; 4332 notice.resolvedDartUnit = null;
4328 notice.resolvedHtmlUnit = null; 4333 notice.resolvedHtmlUnit = null;
4329 } 4334 }
4330 } 4335 }
4331 4336
4337 /**
4338 * Record the results produced by performing a [task] and return the cache
4339 * entry associated with the results.
4340 */
4341 DartEntry _recordBuildUnitElementTask(BuildUnitElementTask task) {
4342 Source source = task.source;
4343 Source library = task.library;
4344 DartEntry dartEntry = _cache.get(source);
4345 CaughtException thrownException = task.exception;
4346 if (thrownException != null) {
4347 dartEntry.recordBuildElementErrorInLibrary(library, thrownException);
4348 throw new AnalysisException('<rethrow>', thrownException);
4349 }
4350 dartEntry.setValueInLibrary(DartEntry.BUILT_UNIT, library, task.unit);
4351 dartEntry.setValueInLibrary(
4352 DartEntry.BUILT_ELEMENT, library, task.unitElement);
4353 ChangeNoticeImpl notice = _getNotice(source);
4354 LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO);
4355 notice.setErrors(dartEntry.allErrors, lineInfo);
4356 return dartEntry;
4357 }
4358
4332 // /** 4359 // /**
4333 // * Notify all of the analysis listeners that the given source is no longer i ncluded in the set of 4360 // * 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. 4361 // * sources that are being analyzed.
4335 // * 4362 // *
4336 // * @param source the source that is no longer being analyzed 4363 // * @param source the source that is no longer being analyzed
4337 // */ 4364 // */
4338 // void _notifyExcludedSource(Source source) { 4365 // void _notifyExcludedSource(Source source) {
4339 // int count = _listeners.length; 4366 // int count = _listeners.length;
4340 // for (int i = 0; i < count; i++) { 4367 // for (int i = 0; i < count; i++) {
4341 // _listeners[i].excludedSource(this, source); 4368 // _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 4428 // * @param unit the result of resolving the source
4402 // */ 4429 // */
4403 // void _notifyResolvedHtml(Source source, ht.HtmlUnit unit) { 4430 // void _notifyResolvedHtml(Source source, ht.HtmlUnit unit) {
4404 // int count = _listeners.length; 4431 // int count = _listeners.length;
4405 // for (int i = 0; i < count; i++) { 4432 // for (int i = 0; i < count; i++) {
4406 // _listeners[i].resolvedHtml(this, source, unit); 4433 // _listeners[i].resolvedHtml(this, source, unit);
4407 // } 4434 // }
4408 // } 4435 // }
4409 4436
4410 /** 4437 /**
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 4438 * 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. 4439 * gleaned from the element in the cache entry.
4435 * 4440 *
4436 * @param dartCopy the cache entry in which data is to be recorded 4441 * @param dartCopy the cache entry in which data is to be recorded
4437 * @param library the library element used to record information 4442 * @param library the library element used to record information
4438 * @param librarySource the source for the library used to record information 4443 * @param librarySource the source for the library used to record information
4439 * @param htmlSource the source for the HTML library 4444 * @param htmlSource the source for the HTML library
4440 */ 4445 */
4441 void _recordElementData(DartEntry dartEntry, LibraryElement library, 4446 void _recordElementData(DartEntry dartEntry, LibraryElement library,
4442 Source librarySource, Source htmlSource) { 4447 Source librarySource, Source htmlSource) {
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
4818 if (_priorityOrder[i] != source) { 4823 if (_priorityOrder[i] != source) {
4819 newOrder.add(_priorityOrder[i]); 4824 newOrder.add(_priorityOrder[i]);
4820 } 4825 }
4821 } 4826 }
4822 if (newOrder.length < count) { 4827 if (newOrder.length < count) {
4823 analysisPriorityOrder = newOrder; 4828 analysisPriorityOrder = newOrder;
4824 } 4829 }
4825 } 4830 }
4826 4831
4827 /** 4832 /**
4833 * Return `true` if errors should be produced for the given [source]. The
4834 * [dartEntry] associated with the source is passed in for efficiency.
4835 */
4836 bool _shouldErrorsBeAnalyzed(Source source, DartEntry dartEntry) {
4837 if (source.isInSystemLibrary) {
4838 return _generateSdkErrors;
4839 } else if (!dartEntry.explicitlyAdded) {
4840 return _generateImplicitErrors;
4841 } else {
4842 return true;
4843 }
4844 }
4845
4846 /**
4828 * Create an entry for the newly added [source] and invalidate any sources 4847 * Create an entry for the newly added [source] and invalidate any sources
4829 * that referenced the source before it existed. 4848 * that referenced the source before it existed.
4830 * 4849 *
4831 * <b>Note:</b> This method must only be invoked while we are synchronized on 4850 * <b>Note:</b> This method must only be invoked while we are synchronized on
4832 * [cacheLock]. 4851 * [cacheLock].
4833 */ 4852 */
4834 void _sourceAvailable(Source source) { 4853 void _sourceAvailable(Source source) {
4835 SourceEntry sourceEntry = _cache.get(source); 4854 SourceEntry sourceEntry = _cache.get(source);
4836 if (sourceEntry == null) { 4855 if (sourceEntry == null) {
4837 sourceEntry = _createSourceEntry(source, true); 4856 sourceEntry = _createSourceEntry(source, true);
(...skipping 2695 matching lines...) Expand 10 before | Expand all | Expand 10 after
7533 } 7552 }
7534 buffer.write(label); 7553 buffer.write(label);
7535 String prefix = " "; 7554 String prefix = " ";
7536 for (Source source in sources.keys.toSet()) { 7555 for (Source source in sources.keys.toSet()) {
7537 buffer.write(prefix); 7556 buffer.write(prefix);
7538 buffer.write(source.fullName); 7557 buffer.write(source.fullName);
7539 prefix = ", "; 7558 prefix = ", ";
7540 } 7559 }
7541 return true; 7560 return true;
7542 } 7561 }
7562
7563 void changedAllSources(List<Source> sources) {
Paul Berry 2015/03/09 18:05:33 Was this added by mistake? It looks like it's not
Brian Wilkerson 2015/03/09 18:24:46 Yes. Thanks! I added it when looking at the ineff
7564 }
7543 } 7565 }
7544 7566
7545 /** 7567 /**
7546 * Instances of the class `ContentChange` represent a change to the content of a source. 7568 * Instances of the class `ContentChange` represent a change to the content of a source.
7547 */ 7569 */
7548 class ChangeSet_ContentChange { 7570 class ChangeSet_ContentChange {
7549 /** 7571 /**
7550 * The new contents of the source. 7572 * The new contents of the source.
7551 */ 7573 */
7552 final String contents; 7574 final String contents;
(...skipping 4615 matching lines...) Expand 10 before | Expand all | Expand 10 after
12168 visitElement(Element element) { 12190 visitElement(Element element) {
12169 if (element.id == _id) { 12191 if (element.id == _id) {
12170 result = element; 12192 result = element;
12171 throw new _ElementByIdFinderException(); 12193 throw new _ElementByIdFinderException();
12172 } 12194 }
12173 super.visitElement(element); 12195 super.visitElement(element);
12174 } 12196 }
12175 } 12197 }
12176 12198
12177 class _ElementByIdFinderException {} 12199 class _ElementByIdFinderException {}
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/context_manager_test.dart ('k') | pkg/analyzer/test/generated/engine_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698