OLD | NEW |
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 | |
6 // significant change. Please see the README file for more information. | |
7 | |
8 library engine; | 5 library engine; |
9 | 6 |
10 import 'dart:async'; | 7 import 'dart:async'; |
11 import 'dart:collection'; | 8 import 'dart:collection'; |
12 import 'dart:math' as math; | 9 import 'dart:math' as math; |
13 | 10 |
14 import 'package:analyzer/src/cancelable_future.dart'; | 11 import 'package:analyzer/src/cancelable_future.dart'; |
15 import 'package:analyzer/src/context/cache.dart' as cache; | 12 import 'package:analyzer/src/context/cache.dart' as cache; |
16 import 'package:analyzer/src/context/context.dart' as newContext; | 13 import 'package:analyzer/src/context/context.dart' as newContext; |
17 import 'package:analyzer/src/generated/incremental_resolution_validator.dart'; | 14 import 'package:analyzer/src/generated/incremental_resolution_validator.dart'; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 199 } |
203 } | 200 } |
204 _partitions[i].put(source, entry); | 201 _partitions[i].put(source, entry); |
205 return; | 202 return; |
206 } | 203 } |
207 } | 204 } |
208 } | 205 } |
209 | 206 |
210 /** | 207 /** |
211 * Remove all information related to the given [source] from this cache. | 208 * Remove all information related to the given [source] from this cache. |
| 209 * Return the entry associated with the source, or `null` if there was cache |
| 210 * entry for the source. |
212 */ | 211 */ |
213 void remove(Source source) { | 212 SourceEntry remove(Source source) { |
214 int count = _partitions.length; | 213 int count = _partitions.length; |
215 for (int i = 0; i < count; i++) { | 214 for (int i = 0; i < count; i++) { |
216 if (_partitions[i].contains(source)) { | 215 if (_partitions[i].contains(source)) { |
217 if (_TRACE_CHANGES) { | 216 if (_TRACE_CHANGES) { |
218 try { | 217 try { |
219 AnalysisEngine.instance.logger.logInformation( | 218 AnalysisEngine.instance.logger.logInformation( |
220 "Removed the cache entry for ${source.fullName}'."); | 219 "Removed the cache entry for ${source.fullName}'."); |
221 } catch (exception) { | 220 } catch (exception) { |
222 // Ignored | 221 // Ignored |
223 JavaSystem.currentTimeMillis(); | 222 JavaSystem.currentTimeMillis(); |
224 } | 223 } |
225 } | 224 } |
226 _partitions[i].remove(source); | 225 return _partitions[i].remove(source); |
227 return; | |
228 } | 226 } |
229 } | 227 } |
| 228 return null; |
230 } | 229 } |
231 | 230 |
232 /** | 231 /** |
233 * Record that the AST associated with the given [source] was just removed | 232 * Record that the AST associated with the given [source] was just removed |
234 * from the cache. | 233 * from the cache. |
235 */ | 234 */ |
236 void removedAst(Source source) { | 235 void removedAst(Source source) { |
237 int count = _partitions.length; | 236 int count = _partitions.length; |
238 for (int i = 0; i < count; i++) { | 237 for (int i = 0; i < count; i++) { |
239 if (_partitions[i].contains(source)) { | 238 if (_partitions[i].contains(source)) { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 */ | 345 */ |
347 DeclaredVariables get declaredVariables; | 346 DeclaredVariables get declaredVariables; |
348 | 347 |
349 /** | 348 /** |
350 * Return a list containing all of the sources known to this context that | 349 * Return a list containing all of the sources known to this context that |
351 * represent HTML files. The contents of the list can be incomplete. | 350 * represent HTML files. The contents of the list can be incomplete. |
352 */ | 351 */ |
353 List<Source> get htmlSources; | 352 List<Source> get htmlSources; |
354 | 353 |
355 /** | 354 /** |
| 355 * The stream that is notified when a source either starts or stops being |
| 356 * analyzed implicitly. |
| 357 */ |
| 358 Stream<ImplicitAnalysisEvent> get implicitAnalysisEvents; |
| 359 |
| 360 /** |
356 * Returns `true` if this context was disposed using [dispose]. | 361 * Returns `true` if this context was disposed using [dispose]. |
357 */ | 362 */ |
358 bool get isDisposed; | 363 bool get isDisposed; |
359 | 364 |
360 /** | 365 /** |
361 * Return a list containing all of the sources known to this context that | 366 * Return a list containing all of the sources known to this context that |
362 * represent the defining compilation unit of a library that can be run within | 367 * represent the defining compilation unit of a library that can be run within |
363 * a browser. The sources that are returned represent libraries that have a | 368 * a browser. The sources that are returned represent libraries that have a |
364 * 'main' method and are either referenced by an HTML file or import, directly | 369 * 'main' method and are either referenced by an HTML file or import, directly |
365 * or indirectly, a client-only library. The contents of the list can be | 370 * or indirectly, a client-only library. The contents of the list can be |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 */ | 422 */ |
418 List<Source> get sources; | 423 List<Source> get sources; |
419 | 424 |
420 /** | 425 /** |
421 * Return a type provider for this context or throw [AnalysisException] if | 426 * Return a type provider for this context or throw [AnalysisException] if |
422 * either `dart:core` or `dart:async` cannot be resolved. | 427 * either `dart:core` or `dart:async` cannot be resolved. |
423 */ | 428 */ |
424 TypeProvider get typeProvider; | 429 TypeProvider get typeProvider; |
425 | 430 |
426 /** | 431 /** |
| 432 * Return a type system for this context. |
| 433 */ |
| 434 TypeSystem get typeSystem; |
| 435 |
| 436 /** |
427 * Add the given [listener] to the list of objects that are to be notified | 437 * Add the given [listener] to the list of objects that are to be notified |
428 * when various analysis results are produced in this context. | 438 * when various analysis results are produced in this context. |
429 */ | 439 */ |
430 void addListener(AnalysisListener listener); | 440 void addListener(AnalysisListener listener); |
431 | 441 |
432 /** | 442 /** |
433 * Apply the given [delta] to change the level of analysis that will be | 443 * Apply the given [delta] to change the level of analysis that will be |
434 * performed for the sources known to this context. | 444 * performed for the sources known to this context. |
435 */ | 445 */ |
436 void applyAnalysisDelta(AnalysisDelta delta); | 446 void applyAnalysisDelta(AnalysisDelta delta); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 * If the resolved AST can't be computed for some reason, the future will be | 551 * If the resolved AST can't be computed for some reason, the future will be |
542 * completed with an error. One possible error is AnalysisNotScheduledError, | 552 * completed with an error. One possible error is AnalysisNotScheduledError, |
543 * which means that the resolved AST can't be computed because the given | 553 * which means that the resolved AST can't be computed because the given |
544 * source file is not scheduled to be analyzed within the context of the | 554 * source file is not scheduled to be analyzed within the context of the |
545 * given library. | 555 * given library. |
546 */ | 556 */ |
547 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync( | 557 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync( |
548 Source source, Source librarySource); | 558 Source source, Source librarySource); |
549 | 559 |
550 /** | 560 /** |
| 561 * Perform work until the given [result] has been computed for the given |
| 562 * [target]. Return the computed value. |
| 563 */ |
| 564 Object /*V*/ computeResult( |
| 565 AnalysisTarget target, ResultDescriptor /*<V>*/ result); |
| 566 |
| 567 /** |
551 * Notifies the context that the client is going to stop using this context. | 568 * Notifies the context that the client is going to stop using this context. |
552 */ | 569 */ |
553 void dispose(); | 570 void dispose(); |
554 | 571 |
555 /** | 572 /** |
556 * Return `true` if the given [source] exists. | 573 * Return `true` if the given [source] exists. |
557 * | 574 * |
558 * This method should be used rather than the method [Source.exists] because | 575 * This method should be used rather than the method [Source.exists] because |
559 * contexts can have local overrides of the content of a source that the | 576 * contexts can have local overrides of the content of a source that the |
560 * source is not aware of and a source with local content is considered to | 577 * source is not aware of and a source with local content is considered to |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 /** | 723 /** |
707 * Return the fully resolved HTML unit defined by the given [htmlSource], or | 724 * Return the fully resolved HTML unit defined by the given [htmlSource], or |
708 * `null` if the resolved unit is not already computed. | 725 * `null` if the resolved unit is not already computed. |
709 * | 726 * |
710 * See [resolveHtmlUnit]. | 727 * See [resolveHtmlUnit]. |
711 */ | 728 */ |
712 @deprecated | 729 @deprecated |
713 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource); | 730 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource); |
714 | 731 |
715 /** | 732 /** |
| 733 * Return the value of the given [result] for the given [target]. |
| 734 * |
| 735 * If the corresponding [target] does not exist, or the [result] is not |
| 736 * computed yet, then the default value is returned. |
| 737 */ |
| 738 Object /*V*/ getResult( |
| 739 AnalysisTarget target, ResultDescriptor /*<V>*/ result); |
| 740 |
| 741 /** |
716 * Return a list of the sources being analyzed in this context whose full path | 742 * Return a list of the sources being analyzed in this context whose full path |
717 * is equal to the given [path]. | 743 * is equal to the given [path]. |
718 */ | 744 */ |
719 List<Source> getSourcesWithFullName(String path); | 745 List<Source> getSourcesWithFullName(String path); |
720 | 746 |
721 /** | 747 /** |
722 * Invalidates hints in the given [librarySource] and included parts. | 748 * Invalidates hints in the given [librarySource] and included parts. |
723 */ | 749 */ |
724 void invalidateLibraryHints(Source librarySource); | 750 void invalidateLibraryHints(Source librarySource); |
725 | 751 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 * Cached information used in incremental analysis or `null` if none. | 1038 * Cached information used in incremental analysis or `null` if none. |
1013 */ | 1039 */ |
1014 IncrementalAnalysisCache _incrementalAnalysisCache; | 1040 IncrementalAnalysisCache _incrementalAnalysisCache; |
1015 | 1041 |
1016 /** | 1042 /** |
1017 * The [TypeProvider] for this context, `null` if not yet created. | 1043 * The [TypeProvider] for this context, `null` if not yet created. |
1018 */ | 1044 */ |
1019 TypeProvider _typeProvider; | 1045 TypeProvider _typeProvider; |
1020 | 1046 |
1021 /** | 1047 /** |
| 1048 * The [TypeSystem] for this context, `null` if not yet created. |
| 1049 */ |
| 1050 TypeSystem _typeSystem; |
| 1051 |
| 1052 /** |
1022 * The object used to manage the list of sources that need to be analyzed. | 1053 * The object used to manage the list of sources that need to be analyzed. |
1023 */ | 1054 */ |
1024 WorkManager _workManager = new WorkManager(); | 1055 WorkManager _workManager = new WorkManager(); |
1025 | 1056 |
1026 /** | 1057 /** |
1027 * The [Stopwatch] of the current "perform tasks cycle". | 1058 * The [Stopwatch] of the current "perform tasks cycle". |
1028 */ | 1059 */ |
1029 Stopwatch _performAnalysisTaskStopwatch; | 1060 Stopwatch _performAnalysisTaskStopwatch; |
1030 | 1061 |
1031 /** | 1062 /** |
1032 * The controller for sending [SourcesChangedEvent]s. | 1063 * The controller for sending [SourcesChangedEvent]s. |
1033 */ | 1064 */ |
1034 StreamController<SourcesChangedEvent> _onSourcesChangedController; | 1065 StreamController<SourcesChangedEvent> _onSourcesChangedController; |
1035 | 1066 |
1036 /** | 1067 /** |
| 1068 * A subscription for a stream of events indicating when files are (and are |
| 1069 * not) being implicitly analyzed. |
| 1070 */ |
| 1071 StreamController<ImplicitAnalysisEvent> _implicitAnalysisEventsController; |
| 1072 |
| 1073 /** |
1037 * The listeners that are to be notified when various analysis results are | 1074 * The listeners that are to be notified when various analysis results are |
1038 * produced in this context. | 1075 * produced in this context. |
1039 */ | 1076 */ |
1040 List<AnalysisListener> _listeners = new List<AnalysisListener>(); | 1077 List<AnalysisListener> _listeners = new List<AnalysisListener>(); |
1041 | 1078 |
1042 /** | 1079 /** |
1043 * The most recently incrementally resolved source, or `null` when it was | 1080 * The most recently incrementally resolved source, or `null` when it was |
1044 * already validated, or the most recent change was not incrementally resolved
. | 1081 * already validated, or the most recent change was not incrementally resolved
. |
1045 */ | 1082 */ |
1046 Source incrementalResolutionValidation_lastUnitSource; | 1083 Source incrementalResolutionValidation_lastUnitSource; |
(...skipping 24 matching lines...) Expand all Loading... |
1071 /** | 1108 /** |
1072 * A factory to override how [LibraryResolver] is created. | 1109 * A factory to override how [LibraryResolver] is created. |
1073 */ | 1110 */ |
1074 LibraryResolverFactory libraryResolverFactory; | 1111 LibraryResolverFactory libraryResolverFactory; |
1075 | 1112 |
1076 /** | 1113 /** |
1077 * Initialize a newly created analysis context. | 1114 * Initialize a newly created analysis context. |
1078 */ | 1115 */ |
1079 AnalysisContextImpl() { | 1116 AnalysisContextImpl() { |
1080 _resultRecorder = new AnalysisContextImpl_AnalysisTaskResultRecorder(this); | 1117 _resultRecorder = new AnalysisContextImpl_AnalysisTaskResultRecorder(this); |
1081 _privatePartition = new UniversalCachePartition(this, | 1118 _privatePartition = new UniversalCachePartition( |
| 1119 this, |
1082 AnalysisOptionsImpl.DEFAULT_CACHE_SIZE, | 1120 AnalysisOptionsImpl.DEFAULT_CACHE_SIZE, |
1083 new AnalysisContextImpl_ContextRetentionPolicy(this)); | 1121 new AnalysisContextImpl_ContextRetentionPolicy(this)); |
1084 _cache = createCacheFromSourceFactory(null); | 1122 _cache = createCacheFromSourceFactory(null); |
1085 _onSourcesChangedController = | 1123 _onSourcesChangedController = |
1086 new StreamController<SourcesChangedEvent>.broadcast(); | 1124 new StreamController<SourcesChangedEvent>.broadcast(); |
| 1125 _implicitAnalysisEventsController = |
| 1126 new StreamController<ImplicitAnalysisEvent>.broadcast(); |
1087 } | 1127 } |
1088 | 1128 |
1089 @override | 1129 @override |
1090 AnalysisCache get analysisCache => _cache; | 1130 AnalysisCache get analysisCache => _cache; |
1091 | 1131 |
1092 @override | 1132 @override |
1093 AnalysisOptions get analysisOptions => _options; | 1133 AnalysisOptions get analysisOptions => _options; |
1094 | 1134 |
1095 @override | 1135 @override |
1096 void set analysisOptions(AnalysisOptions options) { | 1136 void set analysisOptions(AnalysisOptions options) { |
1097 bool needsRecompute = this._options.analyzeFunctionBodiesPredicate != | 1137 bool needsRecompute = this._options.analyzeFunctionBodiesPredicate != |
1098 options.analyzeFunctionBodiesPredicate || | 1138 options.analyzeFunctionBodiesPredicate || |
1099 this._options.generateImplicitErrors != | 1139 this._options.generateImplicitErrors != |
1100 options.generateImplicitErrors || | 1140 options.generateImplicitErrors || |
1101 this._options.generateSdkErrors != options.generateSdkErrors || | 1141 this._options.generateSdkErrors != options.generateSdkErrors || |
1102 this._options.dart2jsHint != options.dart2jsHint || | 1142 this._options.dart2jsHint != options.dart2jsHint || |
1103 (this._options.hint && !options.hint) || | 1143 (this._options.hint && !options.hint) || |
1104 this._options.preserveComments != options.preserveComments || | 1144 this._options.preserveComments != options.preserveComments || |
1105 this._options.enableStrictCallChecks != options.enableStrictCallChecks; | 1145 this._options.strongMode != options.strongMode || |
| 1146 this._options.enableStrictCallChecks != |
| 1147 options.enableStrictCallChecks || |
| 1148 this._options.enableSuperMixins != options.enableSuperMixins; |
1106 int cacheSize = options.cacheSize; | 1149 int cacheSize = options.cacheSize; |
1107 if (this._options.cacheSize != cacheSize) { | 1150 if (this._options.cacheSize != cacheSize) { |
1108 this._options.cacheSize = cacheSize; | 1151 this._options.cacheSize = cacheSize; |
1109 //cache.setMaxCacheSize(cacheSize); | 1152 //cache.setMaxCacheSize(cacheSize); |
1110 _privatePartition.maxCacheSize = cacheSize; | 1153 _privatePartition.maxCacheSize = cacheSize; |
1111 // | 1154 // |
1112 // Cap the size of the priority list to being less than the cache size. | 1155 // Cap the size of the priority list to being less than the cache size. |
1113 // Failure to do so can result in an infinite loop in | 1156 // Failure to do so can result in an infinite loop in |
1114 // performAnalysisTask() because re-caching one AST structure | 1157 // performAnalysisTask() because re-caching one AST structure |
1115 // can cause another priority source's AST structure to be flushed. | 1158 // can cause another priority source's AST structure to be flushed. |
1116 // | 1159 // |
1117 // TODO(brianwilkerson) Remove this constraint when the new task model is | 1160 // TODO(brianwilkerson) Remove this constraint when the new task model is |
1118 // implemented. | 1161 // implemented. |
1119 // | 1162 // |
1120 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; | 1163 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; |
1121 if (_priorityOrder.length > maxPriorityOrderSize) { | 1164 if (_priorityOrder.length > maxPriorityOrderSize) { |
1122 _priorityOrder = _priorityOrder.sublist(0, maxPriorityOrderSize); | 1165 _priorityOrder = _priorityOrder.sublist(0, maxPriorityOrderSize); |
1123 } | 1166 } |
1124 } | 1167 } |
1125 this._options.analyzeFunctionBodiesPredicate = | 1168 this._options.analyzeFunctionBodiesPredicate = |
1126 options.analyzeFunctionBodiesPredicate; | 1169 options.analyzeFunctionBodiesPredicate; |
1127 this._options.generateImplicitErrors = options.generateImplicitErrors; | 1170 this._options.generateImplicitErrors = options.generateImplicitErrors; |
1128 this._options.generateSdkErrors = options.generateSdkErrors; | 1171 this._options.generateSdkErrors = options.generateSdkErrors; |
1129 this._options.dart2jsHint = options.dart2jsHint; | 1172 this._options.dart2jsHint = options.dart2jsHint; |
1130 this._options.enableStrictCallChecks = options.enableStrictCallChecks; | 1173 this._options.enableStrictCallChecks = options.enableStrictCallChecks; |
| 1174 this._options.enableSuperMixins = options.enableSuperMixins; |
1131 this._options.hint = options.hint; | 1175 this._options.hint = options.hint; |
1132 this._options.incremental = options.incremental; | 1176 this._options.incremental = options.incremental; |
1133 this._options.incrementalApi = options.incrementalApi; | 1177 this._options.incrementalApi = options.incrementalApi; |
1134 this._options.incrementalValidation = options.incrementalValidation; | 1178 this._options.incrementalValidation = options.incrementalValidation; |
1135 this._options.lint = options.lint; | 1179 this._options.lint = options.lint; |
1136 this._options.preserveComments = options.preserveComments; | 1180 this._options.preserveComments = options.preserveComments; |
| 1181 this._options.strongMode = options.strongMode; |
1137 _generateImplicitErrors = options.generateImplicitErrors; | 1182 _generateImplicitErrors = options.generateImplicitErrors; |
1138 _generateSdkErrors = options.generateSdkErrors; | 1183 _generateSdkErrors = options.generateSdkErrors; |
1139 if (needsRecompute) { | 1184 if (needsRecompute) { |
1140 _invalidateAllLocalResolutionInformation(false); | 1185 _invalidateAllLocalResolutionInformation(false); |
1141 } | 1186 } |
1142 } | 1187 } |
1143 | 1188 |
1144 @override | 1189 @override |
1145 void set analysisPriorityOrder(List<Source> sources) { | 1190 void set analysisPriorityOrder(List<Source> sources) { |
1146 if (sources == null || sources.isEmpty) { | 1191 if (sources == null || sources.isEmpty) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 targets.add(iterator.key); | 1236 targets.add(iterator.key); |
1192 } | 1237 } |
1193 } | 1238 } |
1194 return targets; | 1239 return targets; |
1195 } | 1240 } |
1196 | 1241 |
1197 @override | 1242 @override |
1198 List<Source> get htmlSources => _getSources(SourceKind.HTML); | 1243 List<Source> get htmlSources => _getSources(SourceKind.HTML); |
1199 | 1244 |
1200 @override | 1245 @override |
| 1246 Stream<ImplicitAnalysisEvent> get implicitAnalysisEvents => |
| 1247 _implicitAnalysisEventsController.stream; |
| 1248 |
| 1249 @override |
1201 bool get isDisposed => _disposed; | 1250 bool get isDisposed => _disposed; |
1202 | 1251 |
1203 @override | 1252 @override |
1204 List<Source> get launchableClientLibrarySources { | 1253 List<Source> get launchableClientLibrarySources { |
1205 // TODO(brianwilkerson) This needs to filter out libraries that do not | 1254 // TODO(brianwilkerson) This needs to filter out libraries that do not |
1206 // reference dart:html, either directly or indirectly. | 1255 // reference dart:html, either directly or indirectly. |
1207 List<Source> sources = new List<Source>(); | 1256 List<Source> sources = new List<Source>(); |
1208 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); | 1257 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); |
1209 while (iterator.moveNext()) { | 1258 while (iterator.moveNext()) { |
1210 Source source = iterator.key; | 1259 Source source = iterator.key; |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 } | 1553 } |
1505 | 1554 |
1506 /** | 1555 /** |
1507 * Sets the [TypeProvider] for this context. | 1556 * Sets the [TypeProvider] for this context. |
1508 */ | 1557 */ |
1509 void set typeProvider(TypeProvider typeProvider) { | 1558 void set typeProvider(TypeProvider typeProvider) { |
1510 _typeProvider = typeProvider; | 1559 _typeProvider = typeProvider; |
1511 } | 1560 } |
1512 | 1561 |
1513 @override | 1562 @override |
| 1563 TypeSystem get typeSystem { |
| 1564 if (_typeSystem == null) { |
| 1565 _typeSystem = TypeSystem.create(this); |
| 1566 } |
| 1567 return _typeSystem; |
| 1568 } |
| 1569 |
| 1570 @override |
1514 void addListener(AnalysisListener listener) { | 1571 void addListener(AnalysisListener listener) { |
1515 if (!_listeners.contains(listener)) { | 1572 if (!_listeners.contains(listener)) { |
1516 _listeners.add(listener); | 1573 _listeners.add(listener); |
1517 } | 1574 } |
1518 } | 1575 } |
1519 | 1576 |
1520 @override | 1577 @override |
1521 void applyAnalysisDelta(AnalysisDelta delta) { | 1578 void applyAnalysisDelta(AnalysisDelta delta) { |
1522 ChangeSet changeSet = new ChangeSet(); | 1579 ChangeSet changeSet = new ChangeSet(); |
1523 delta.analysisLevels.forEach((Source source, AnalysisLevel level) { | 1580 delta.analysisLevels.forEach((Source source, AnalysisLevel level) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1577 | 1634 |
1578 @override | 1635 @override |
1579 String computeDocumentationComment(Element element) { | 1636 String computeDocumentationComment(Element element) { |
1580 if (element == null) { | 1637 if (element == null) { |
1581 return null; | 1638 return null; |
1582 } | 1639 } |
1583 Source source = element.source; | 1640 Source source = element.source; |
1584 if (source == null) { | 1641 if (source == null) { |
1585 return null; | 1642 return null; |
1586 } | 1643 } |
1587 CompilationUnit unit = parseCompilationUnit(source); | 1644 SourceRange docRange = element.docRange; |
1588 if (unit == null) { | 1645 if (docRange == null) { |
1589 return null; | 1646 return null; |
1590 } | 1647 } |
1591 NodeLocator locator = new NodeLocator(element.nameOffset); | 1648 String code = getContents(source).data; |
1592 AstNode nameNode = locator.searchWithin(unit); | 1649 String comment = code.substring(docRange.offset, docRange.end); |
1593 while (nameNode != null) { | 1650 return comment.replaceAll('\r\n', '\n'); |
1594 if (nameNode is AnnotatedNode) { | |
1595 Comment comment = nameNode.documentationComment; | |
1596 if (comment == null) { | |
1597 return null; | |
1598 } | |
1599 StringBuffer buffer = new StringBuffer(); | |
1600 List<Token> tokens = comment.tokens; | |
1601 for (int i = 0; i < tokens.length; i++) { | |
1602 if (i > 0) { | |
1603 buffer.write("\n"); | |
1604 } | |
1605 buffer.write(tokens[i].lexeme); | |
1606 } | |
1607 return buffer.toString(); | |
1608 } | |
1609 nameNode = nameNode.parent; | |
1610 } | |
1611 return null; | |
1612 } | 1651 } |
1613 | 1652 |
1614 @override | 1653 @override |
1615 List<AnalysisError> computeErrors(Source source) { | 1654 List<AnalysisError> computeErrors(Source source) { |
1616 bool enableHints = _options.hint; | 1655 bool enableHints = _options.hint; |
1617 bool enableLints = _options.lint; | 1656 bool enableLints = _options.lint; |
1618 | 1657 |
1619 SourceEntry sourceEntry = _getReadableSourceEntry(source); | 1658 SourceEntry sourceEntry = _getReadableSourceEntry(source); |
1620 if (sourceEntry is DartEntry) { | 1659 if (sourceEntry is DartEntry) { |
1621 List<AnalysisError> errors = new List<AnalysisError>(); | 1660 List<AnalysisError> errors = new List<AnalysisError>(); |
1622 try { | 1661 try { |
1623 DartEntry dartEntry = sourceEntry; | 1662 DartEntry dartEntry = sourceEntry; |
1624 ListUtilities.addAll( | 1663 ListUtilities.addAll( |
1625 errors, _getDartScanData(source, dartEntry, DartEntry.SCAN_ERRORS)); | 1664 errors, _getDartScanData(source, dartEntry, DartEntry.SCAN_ERRORS)); |
1626 dartEntry = _getReadableDartEntry(source); | 1665 dartEntry = _getReadableDartEntry(source); |
1627 ListUtilities.addAll(errors, | 1666 ListUtilities.addAll(errors, |
1628 _getDartParseData(source, dartEntry, DartEntry.PARSE_ERRORS)); | 1667 _getDartParseData(source, dartEntry, DartEntry.PARSE_ERRORS)); |
1629 dartEntry = _getReadableDartEntry(source); | 1668 dartEntry = _getReadableDartEntry(source); |
1630 if (dartEntry.getValue(DartEntry.SOURCE_KIND) == SourceKind.LIBRARY) { | 1669 if (dartEntry.getValue(DartEntry.SOURCE_KIND) == SourceKind.LIBRARY) { |
1631 ListUtilities.addAll(errors, _getDartResolutionData( | 1670 ListUtilities.addAll( |
1632 source, source, dartEntry, DartEntry.RESOLUTION_ERRORS)); | 1671 errors, |
| 1672 _getDartResolutionData( |
| 1673 source, source, dartEntry, DartEntry.RESOLUTION_ERRORS)); |
1633 dartEntry = _getReadableDartEntry(source); | 1674 dartEntry = _getReadableDartEntry(source); |
1634 ListUtilities.addAll(errors, _getDartVerificationData( | 1675 ListUtilities.addAll( |
1635 source, source, dartEntry, DartEntry.VERIFICATION_ERRORS)); | 1676 errors, |
| 1677 _getDartVerificationData( |
| 1678 source, source, dartEntry, DartEntry.VERIFICATION_ERRORS)); |
1636 if (enableHints) { | 1679 if (enableHints) { |
1637 dartEntry = _getReadableDartEntry(source); | 1680 dartEntry = _getReadableDartEntry(source); |
1638 ListUtilities.addAll(errors, | 1681 ListUtilities.addAll(errors, |
1639 _getDartHintData(source, source, dartEntry, DartEntry.HINTS)); | 1682 _getDartHintData(source, source, dartEntry, DartEntry.HINTS)); |
1640 } | 1683 } |
1641 if (enableLints) { | 1684 if (enableLints) { |
1642 dartEntry = _getReadableDartEntry(source); | 1685 dartEntry = _getReadableDartEntry(source); |
1643 ListUtilities.addAll(errors, | 1686 ListUtilities.addAll(errors, |
1644 _getDartLintData(source, source, dartEntry, DartEntry.LINTS)); | 1687 _getDartLintData(source, source, dartEntry, DartEntry.LINTS)); |
1645 } | 1688 } |
1646 } else { | 1689 } else { |
1647 List<Source> libraries = getLibrariesContaining(source); | 1690 List<Source> libraries = getLibrariesContaining(source); |
1648 for (Source librarySource in libraries) { | 1691 for (Source librarySource in libraries) { |
1649 ListUtilities.addAll(errors, _getDartResolutionData( | 1692 ListUtilities.addAll( |
1650 source, librarySource, dartEntry, DartEntry.RESOLUTION_ERRORS)); | 1693 errors, |
| 1694 _getDartResolutionData(source, librarySource, dartEntry, |
| 1695 DartEntry.RESOLUTION_ERRORS)); |
1651 dartEntry = _getReadableDartEntry(source); | 1696 dartEntry = _getReadableDartEntry(source); |
1652 ListUtilities.addAll(errors, _getDartVerificationData(source, | 1697 ListUtilities.addAll( |
1653 librarySource, dartEntry, DartEntry.VERIFICATION_ERRORS)); | 1698 errors, |
| 1699 _getDartVerificationData(source, librarySource, dartEntry, |
| 1700 DartEntry.VERIFICATION_ERRORS)); |
1654 if (enableHints) { | 1701 if (enableHints) { |
1655 dartEntry = _getReadableDartEntry(source); | 1702 dartEntry = _getReadableDartEntry(source); |
1656 ListUtilities.addAll(errors, _getDartHintData( | 1703 ListUtilities.addAll( |
1657 source, librarySource, dartEntry, DartEntry.HINTS)); | 1704 errors, |
| 1705 _getDartHintData( |
| 1706 source, librarySource, dartEntry, DartEntry.HINTS)); |
1658 } | 1707 } |
1659 if (enableLints) { | 1708 if (enableLints) { |
1660 dartEntry = _getReadableDartEntry(source); | 1709 dartEntry = _getReadableDartEntry(source); |
1661 ListUtilities.addAll(errors, _getDartLintData( | 1710 ListUtilities.addAll( |
1662 source, librarySource, dartEntry, DartEntry.LINTS)); | 1711 errors, |
| 1712 _getDartLintData( |
| 1713 source, librarySource, dartEntry, DartEntry.LINTS)); |
1663 } | 1714 } |
1664 } | 1715 } |
1665 } | 1716 } |
1666 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) { | 1717 } on ObsoleteSourceAnalysisException catch (exception, stackTrace) { |
1667 AnalysisEngine.instance.logger.logInformation( | 1718 AnalysisEngine.instance.logger.logInformation( |
1668 "Could not compute errors", | 1719 "Could not compute errors", |
1669 new CaughtException(exception, stackTrace)); | 1720 new CaughtException(exception, stackTrace)); |
1670 } | 1721 } |
1671 if (errors.isEmpty) { | 1722 if (errors.isEmpty) { |
1672 return AnalysisError.NO_ERRORS; | 1723 return AnalysisError.NO_ERRORS; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1748 throw new AnalysisException( | 1799 throw new AnalysisException( |
1749 "Internal error: computeResolvableCompilationUnit could not parse ${so
urce.fullName}", | 1800 "Internal error: computeResolvableCompilationUnit could not parse ${so
urce.fullName}", |
1750 new CaughtException(dartEntry.exception, null)); | 1801 new CaughtException(dartEntry.exception, null)); |
1751 } | 1802 } |
1752 return unit; | 1803 return unit; |
1753 } | 1804 } |
1754 | 1805 |
1755 @override | 1806 @override |
1756 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync( | 1807 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync( |
1757 Source unitSource, Source librarySource) { | 1808 Source unitSource, Source librarySource) { |
1758 return new _AnalysisFutureHelper<CompilationUnit>(this).computeAsync( | 1809 return new _AnalysisFutureHelper<CompilationUnit>(this) |
1759 unitSource, (SourceEntry sourceEntry) { | 1810 .computeAsync(unitSource, (SourceEntry sourceEntry) { |
1760 if (sourceEntry is DartEntry) { | 1811 if (sourceEntry is DartEntry) { |
1761 if (sourceEntry.getStateInLibrary( | 1812 if (sourceEntry.getStateInLibrary( |
1762 DartEntry.RESOLVED_UNIT, librarySource) == | 1813 DartEntry.RESOLVED_UNIT, librarySource) == |
1763 CacheState.ERROR) { | 1814 CacheState.ERROR) { |
1764 throw sourceEntry.exception; | 1815 throw sourceEntry.exception; |
1765 } | 1816 } |
1766 return sourceEntry.getValueInLibrary( | 1817 return sourceEntry.getValueInLibrary( |
1767 DartEntry.RESOLVED_UNIT, librarySource); | 1818 DartEntry.RESOLVED_UNIT, librarySource); |
1768 } | 1819 } |
1769 throw new AnalysisNotScheduledError(); | 1820 throw new AnalysisNotScheduledError(); |
1770 }); | 1821 }); |
1771 } | 1822 } |
1772 | 1823 |
| 1824 @override |
| 1825 Object computeResult(AnalysisTarget target, ResultDescriptor result) { |
| 1826 return result.defaultValue; |
| 1827 } |
| 1828 |
1773 /** | 1829 /** |
1774 * Create an analysis cache based on the given source [factory]. | 1830 * Create an analysis cache based on the given source [factory]. |
1775 */ | 1831 */ |
1776 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { | 1832 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { |
1777 if (factory == null) { | 1833 if (factory == null) { |
1778 return new AnalysisCache(<CachePartition>[_privatePartition]); | 1834 return new AnalysisCache(<CachePartition>[_privatePartition]); |
1779 } | 1835 } |
1780 DartSdk sdk = factory.dartSdk; | 1836 DartSdk sdk = factory.dartSdk; |
1781 if (sdk == null) { | 1837 if (sdk == null) { |
1782 return new AnalysisCache(<CachePartition>[_privatePartition]); | 1838 return new AnalysisCache(<CachePartition>[_privatePartition]); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2090 Namespace namespace = null; | 2146 Namespace namespace = null; |
2091 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { | 2147 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { |
2092 namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); | 2148 namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); |
2093 } | 2149 } |
2094 if (namespace == null) { | 2150 if (namespace == null) { |
2095 NamespaceBuilder builder = new NamespaceBuilder(); | 2151 NamespaceBuilder builder = new NamespaceBuilder(); |
2096 namespace = builder.createPublicNamespaceForLibrary(library); | 2152 namespace = builder.createPublicNamespaceForLibrary(library); |
2097 if (dartEntry == null) { | 2153 if (dartEntry == null) { |
2098 AnalysisEngine.instance.logger.logError( | 2154 AnalysisEngine.instance.logger.logError( |
2099 "Could not compute the public namespace for ${library.source.fullNam
e}", | 2155 "Could not compute the public namespace for ${library.source.fullNam
e}", |
2100 new CaughtException(new AnalysisException( | 2156 new CaughtException( |
| 2157 new AnalysisException( |
2101 "A Dart file became a non-Dart file: ${source.fullName}"), | 2158 "A Dart file became a non-Dart file: ${source.fullName}"), |
2102 null)); | 2159 null)); |
2103 return null; | 2160 return null; |
2104 } | 2161 } |
2105 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { | 2162 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { |
2106 dartEntry.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); | 2163 dartEntry.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); |
2107 } | 2164 } |
2108 } | 2165 } |
2109 return namespace; | 2166 return namespace; |
2110 } | 2167 } |
(...skipping 29 matching lines...) Expand all Loading... |
2140 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { | 2197 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { |
2141 SourceEntry sourceEntry = getReadableSourceEntryOrNull(htmlSource); | 2198 SourceEntry sourceEntry = getReadableSourceEntryOrNull(htmlSource); |
2142 if (sourceEntry is HtmlEntry) { | 2199 if (sourceEntry is HtmlEntry) { |
2143 HtmlEntry htmlEntry = sourceEntry; | 2200 HtmlEntry htmlEntry = sourceEntry; |
2144 return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); | 2201 return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
2145 } | 2202 } |
2146 return null; | 2203 return null; |
2147 } | 2204 } |
2148 | 2205 |
2149 @override | 2206 @override |
| 2207 Object getResult(AnalysisTarget target, ResultDescriptor result) { |
| 2208 return result.defaultValue; |
| 2209 } |
| 2210 |
| 2211 @override |
2150 List<Source> getSourcesWithFullName(String path) { | 2212 List<Source> getSourcesWithFullName(String path) { |
2151 List<Source> sources = <Source>[]; | 2213 List<Source> sources = <Source>[]; |
2152 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); | 2214 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); |
2153 while (iterator.moveNext()) { | 2215 while (iterator.moveNext()) { |
2154 if (iterator.key.fullName == path) { | 2216 if (iterator.key.fullName == path) { |
2155 sources.add(iterator.key); | 2217 sources.add(iterator.key); |
2156 } | 2218 } |
2157 } | 2219 } |
2158 return sources; | 2220 return sources; |
2159 } | 2221 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2285 } | 2347 } |
2286 return PerformanceStatistics.performAnaysis.makeCurrentWhile(() { | 2348 return PerformanceStatistics.performAnaysis.makeCurrentWhile(() { |
2287 int getStart = JavaSystem.currentTimeMillis(); | 2349 int getStart = JavaSystem.currentTimeMillis(); |
2288 AnalysisTask task = PerformanceStatistics.nextTask | 2350 AnalysisTask task = PerformanceStatistics.nextTask |
2289 .makeCurrentWhile(() => nextAnalysisTask); | 2351 .makeCurrentWhile(() => nextAnalysisTask); |
2290 int getEnd = JavaSystem.currentTimeMillis(); | 2352 int getEnd = JavaSystem.currentTimeMillis(); |
2291 if (task == null) { | 2353 if (task == null) { |
2292 _validateLastIncrementalResolutionResult(); | 2354 _validateLastIncrementalResolutionResult(); |
2293 if (_performAnalysisTaskStopwatch != null) { | 2355 if (_performAnalysisTaskStopwatch != null) { |
2294 AnalysisEngine.instance.instrumentationService.logPerformance( | 2356 AnalysisEngine.instance.instrumentationService.logPerformance( |
2295 AnalysisPerformanceKind.FULL, _performAnalysisTaskStopwatch, | 2357 AnalysisPerformanceKind.FULL, |
| 2358 _performAnalysisTaskStopwatch, |
2296 'context_id=$_id'); | 2359 'context_id=$_id'); |
2297 _performAnalysisTaskStopwatch = null; | 2360 _performAnalysisTaskStopwatch = null; |
2298 } | 2361 } |
2299 return new AnalysisResult( | 2362 return new AnalysisResult( |
2300 _getChangeNotices(true), getEnd - getStart, null, -1); | 2363 _getChangeNotices(true), getEnd - getStart, null, -1); |
2301 } | 2364 } |
2302 if (_performAnalysisTaskStopwatch == null) { | 2365 if (_performAnalysisTaskStopwatch == null) { |
2303 _performAnalysisTaskStopwatch = new Stopwatch()..start(); | 2366 _performAnalysisTaskStopwatch = new Stopwatch()..start(); |
2304 } | 2367 } |
2305 String taskDescription = task.toString(); | 2368 String taskDescription = task.toString(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2403 // during resolution. | 2466 // during resolution. |
2404 // | 2467 // |
2405 if (thrownException == null) { | 2468 if (thrownException == null) { |
2406 var message = "In recordResolveDartLibraryCycleTaskResults, " | 2469 var message = "In recordResolveDartLibraryCycleTaskResults, " |
2407 "resolvedLibraries was null and there was no thrown exception"; | 2470 "resolvedLibraries was null and there was no thrown exception"; |
2408 unitEntry.recordResolutionError( | 2471 unitEntry.recordResolutionError( |
2409 new CaughtException(new AnalysisException(message), null)); | 2472 new CaughtException(new AnalysisException(message), null)); |
2410 } else { | 2473 } else { |
2411 unitEntry.recordResolutionError(thrownException); | 2474 unitEntry.recordResolutionError(thrownException); |
2412 } | 2475 } |
2413 _cache.remove(unitSource); | 2476 _removeFromCache(unitSource); |
2414 if (thrownException != null) { | 2477 if (thrownException != null) { |
2415 throw new AnalysisException('<rethrow>', thrownException); | 2478 throw new AnalysisException('<rethrow>', thrownException); |
2416 } | 2479 } |
2417 return unitEntry; | 2480 return unitEntry; |
2418 } | 2481 } |
2419 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); | 2482 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); |
2420 RecordingErrorListener errorListener = resolver.errorListener; | 2483 RecordingErrorListener errorListener = resolver.errorListener; |
2421 for (ResolvableLibrary library in resolvedLibraries) { | 2484 for (ResolvableLibrary library in resolvedLibraries) { |
2422 Source librarySource = library.librarySource; | 2485 Source librarySource = library.librarySource; |
2423 for (Source source in library.compilationUnitSources) { | 2486 for (Source source in library.compilationUnitSources) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2476 // during resolution. | 2539 // during resolution. |
2477 // | 2540 // |
2478 if (thrownException == null) { | 2541 if (thrownException == null) { |
2479 String message = "In recordResolveDartLibraryTaskResults, " | 2542 String message = "In recordResolveDartLibraryTaskResults, " |
2480 "resolvedLibraries was null and there was no thrown exception"; | 2543 "resolvedLibraries was null and there was no thrown exception"; |
2481 unitEntry.recordResolutionError( | 2544 unitEntry.recordResolutionError( |
2482 new CaughtException(new AnalysisException(message), null)); | 2545 new CaughtException(new AnalysisException(message), null)); |
2483 } else { | 2546 } else { |
2484 unitEntry.recordResolutionError(thrownException); | 2547 unitEntry.recordResolutionError(thrownException); |
2485 } | 2548 } |
2486 _cache.remove(unitSource); | 2549 _removeFromCache(unitSource); |
2487 if (thrownException != null) { | 2550 if (thrownException != null) { |
2488 throw new AnalysisException('<rethrow>', thrownException); | 2551 throw new AnalysisException('<rethrow>', thrownException); |
2489 } | 2552 } |
2490 return unitEntry; | 2553 return unitEntry; |
2491 } | 2554 } |
2492 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); | 2555 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); |
2493 RecordingErrorListener errorListener = resolver.errorListener; | 2556 RecordingErrorListener errorListener = resolver.errorListener; |
2494 for (Library library in resolvedLibraries) { | 2557 for (Library library in resolvedLibraries) { |
2495 Source librarySource = library.librarySource; | 2558 Source librarySource = library.librarySource; |
2496 for (Source source in library.compilationUnitSources) { | 2559 for (Source source in library.compilationUnitSources) { |
2497 CompilationUnit unit = library.getAST(source); | 2560 CompilationUnit unit = library.getAST(source); |
2498 List<AnalysisError> errors = errorListener.getErrorsForSource(source); | 2561 List<AnalysisError> errors = errorListener.getErrorsForSource(source); |
2499 LineInfo lineInfo = getLineInfo(source); | 2562 LineInfo lineInfo = getLineInfo(source); |
2500 DartEntry dartEntry = _cache.get(source); | 2563 DartEntry dartEntry = _cache.get(source); |
2501 if (thrownException == null) { | 2564 if (thrownException == null) { |
2502 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo); | 2565 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo); |
2503 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); | 2566 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
2504 dartEntry.setValueInLibrary( | 2567 dartEntry.setValueInLibrary( |
2505 DartEntry.RESOLVED_UNIT, librarySource, unit); | 2568 DartEntry.RESOLVED_UNIT, librarySource, unit); |
2506 dartEntry.setValueInLibrary( | 2569 dartEntry.setValueInLibrary( |
2507 DartEntry.RESOLUTION_ERRORS, librarySource, errors); | 2570 DartEntry.RESOLUTION_ERRORS, librarySource, errors); |
2508 if (source == librarySource) { | 2571 if (source == librarySource) { |
2509 _recordElementData( | 2572 _recordElementData( |
2510 dartEntry, library.libraryElement, librarySource, htmlSource); | 2573 dartEntry, library.libraryElement, librarySource, htmlSource); |
2511 } | 2574 } |
2512 _cache.storedAst(source); | 2575 _cache.storedAst(source); |
2513 } else { | 2576 } else { |
2514 dartEntry.recordResolutionErrorInLibrary( | 2577 dartEntry.recordResolutionErrorInLibrary( |
2515 librarySource, thrownException); | 2578 librarySource, thrownException); |
2516 _cache.remove(source); | 2579 _removeFromCache(source); |
2517 } | 2580 } |
2518 if (source != librarySource) { | 2581 if (source != librarySource) { |
2519 _workManager.add(source, SourcePriority.PRIORITY_PART); | 2582 _workManager.add(source, SourcePriority.PRIORITY_PART); |
2520 } | 2583 } |
2521 ChangeNoticeImpl notice = getNotice(source); | 2584 ChangeNoticeImpl notice = getNotice(source); |
2522 notice.resolvedDartUnit = unit; | 2585 notice.resolvedDartUnit = unit; |
2523 notice.setErrors(dartEntry.allErrors, lineInfo); | 2586 notice.setErrors(dartEntry.allErrors, lineInfo); |
2524 } | 2587 } |
2525 } | 2588 } |
2526 } | 2589 } |
(...skipping 12 matching lines...) Expand all Loading... |
2539 CompilationUnit resolveCompilationUnit( | 2602 CompilationUnit resolveCompilationUnit( |
2540 Source unitSource, LibraryElement library) { | 2603 Source unitSource, LibraryElement library) { |
2541 if (library == null) { | 2604 if (library == null) { |
2542 return null; | 2605 return null; |
2543 } | 2606 } |
2544 return resolveCompilationUnit2(unitSource, library.source); | 2607 return resolveCompilationUnit2(unitSource, library.source); |
2545 } | 2608 } |
2546 | 2609 |
2547 @override | 2610 @override |
2548 CompilationUnit resolveCompilationUnit2( | 2611 CompilationUnit resolveCompilationUnit2( |
2549 Source unitSource, Source librarySource) => _getDartResolutionData2( | 2612 Source unitSource, Source librarySource) => |
| 2613 _getDartResolutionData2( |
2550 unitSource, librarySource, DartEntry.RESOLVED_UNIT, null); | 2614 unitSource, librarySource, DartEntry.RESOLVED_UNIT, null); |
2551 | 2615 |
2552 @override | 2616 @override |
2553 @deprecated | 2617 @deprecated |
2554 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { | 2618 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { |
2555 computeHtmlElement(htmlSource); | 2619 computeHtmlElement(htmlSource); |
2556 return parseHtmlUnit(htmlSource); | 2620 return parseHtmlUnit(htmlSource); |
2557 } | 2621 } |
2558 | 2622 |
2559 @override | 2623 @override |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2608 } | 2672 } |
2609 } | 2673 } |
2610 int count = changedSources.length; | 2674 int count = changedSources.length; |
2611 for (int i = 0; i < count; i++) { | 2675 for (int i = 0; i < count; i++) { |
2612 _sourceChanged(changedSources[i]); | 2676 _sourceChanged(changedSources[i]); |
2613 } | 2677 } |
2614 int removalCount = 0; | 2678 int removalCount = 0; |
2615 for (Source source in missingSources) { | 2679 for (Source source in missingSources) { |
2616 if (getLibrariesContaining(source).isEmpty && | 2680 if (getLibrariesContaining(source).isEmpty && |
2617 getLibrariesDependingOn(source).isEmpty) { | 2681 getLibrariesDependingOn(source).isEmpty) { |
2618 _cache.remove(source); | 2682 _removeFromCache(source); |
2619 removalCount++; | 2683 removalCount++; |
2620 } | 2684 } |
2621 } | 2685 } |
2622 int consistencyCheckEnd = JavaSystem.nanoTime(); | 2686 int consistencyCheckEnd = JavaSystem.nanoTime(); |
2623 if (changedSources.length > 0 || missingSources.length > 0) { | 2687 if (changedSources.length > 0 || missingSources.length > 0) { |
2624 StringBuffer buffer = new StringBuffer(); | 2688 StringBuffer buffer = new StringBuffer(); |
2625 buffer.write("Consistency check took "); | 2689 buffer.write("Consistency check took "); |
2626 buffer.write((consistencyCheckEnd - consistencyCheckStart) / 1000000.0); | 2690 buffer.write((consistencyCheckEnd - consistencyCheckStart) / 1000000.0); |
2627 buffer.writeln(" ms and found"); | 2691 buffer.writeln(" ms and found"); |
2628 buffer.write(" "); | 2692 buffer.write(" "); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2863 // | 2927 // |
2864 // Check to see whether we already have the information being requested. | 2928 // Check to see whether we already have the information being requested. |
2865 // | 2929 // |
2866 CacheState state = dartEntry.getState(descriptor); | 2930 CacheState state = dartEntry.getState(descriptor); |
2867 while (state != CacheState.ERROR && state != CacheState.VALID) { | 2931 while (state != CacheState.ERROR && state != CacheState.VALID) { |
2868 // | 2932 // |
2869 // If not, compute the information. Unless the modification date of the | 2933 // If not, compute the information. Unless the modification date of the |
2870 // source continues to change, this loop will eventually terminate. | 2934 // source continues to change, this loop will eventually terminate. |
2871 // | 2935 // |
2872 dartEntry = _cacheDartScanData(source, dartEntry, DartEntry.TOKEN_STREAM); | 2936 dartEntry = _cacheDartScanData(source, dartEntry, DartEntry.TOKEN_STREAM); |
2873 dartEntry = new ParseDartTask(this, source, | 2937 dartEntry = new ParseDartTask( |
| 2938 this, |
| 2939 source, |
2874 dartEntry.getValue(DartEntry.TOKEN_STREAM), | 2940 dartEntry.getValue(DartEntry.TOKEN_STREAM), |
2875 dartEntry.getValue(SourceEntry.LINE_INFO)) | 2941 dartEntry.getValue(SourceEntry.LINE_INFO)) |
2876 .perform(_resultRecorder) as DartEntry; | 2942 .perform(_resultRecorder) as DartEntry; |
2877 state = dartEntry.getState(descriptor); | 2943 state = dartEntry.getState(descriptor); |
2878 } | 2944 } |
2879 return dartEntry; | 2945 return dartEntry; |
2880 } | 2946 } |
2881 | 2947 |
2882 /** | 2948 /** |
2883 * Given a source for a Dart file and the library that contains it, return a | 2949 * Given a source for a Dart file and the library that contains it, return a |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2927 // Check to see whether we already have the information being requested. | 2993 // Check to see whether we already have the information being requested. |
2928 // | 2994 // |
2929 CacheState state = dartEntry.getState(descriptor); | 2995 CacheState state = dartEntry.getState(descriptor); |
2930 while (state != CacheState.ERROR && state != CacheState.VALID) { | 2996 while (state != CacheState.ERROR && state != CacheState.VALID) { |
2931 // | 2997 // |
2932 // If not, compute the information. Unless the modification date of the | 2998 // If not, compute the information. Unless the modification date of the |
2933 // source continues to change, this loop will eventually terminate. | 2999 // source continues to change, this loop will eventually terminate. |
2934 // | 3000 // |
2935 try { | 3001 try { |
2936 if (dartEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { | 3002 if (dartEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { |
2937 dartEntry = new GetContentTask(this, source) | 3003 dartEntry = new GetContentTask(this, source).perform(_resultRecorder) |
2938 .perform(_resultRecorder) as DartEntry; | 3004 as DartEntry; |
2939 } | 3005 } |
2940 dartEntry = new ScanDartTask( | 3006 dartEntry = new ScanDartTask( |
2941 this, source, dartEntry.getValue(SourceEntry.CONTENT)) | 3007 this, source, dartEntry.getValue(SourceEntry.CONTENT)) |
2942 .perform(_resultRecorder) as DartEntry; | 3008 .perform(_resultRecorder) as DartEntry; |
2943 } on AnalysisException catch (exception) { | 3009 } on AnalysisException catch (exception) { |
2944 throw exception; | 3010 throw exception; |
2945 } catch (exception, stackTrace) { | 3011 } catch (exception, stackTrace) { |
2946 throw new AnalysisException( | 3012 throw new AnalysisException( |
2947 "Exception", new CaughtException(exception, stackTrace)); | 3013 "Exception", new CaughtException(exception, stackTrace)); |
2948 } | 3014 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3004 // Check to see whether we already have the information being requested. | 3070 // Check to see whether we already have the information being requested. |
3005 // | 3071 // |
3006 CacheState state = htmlEntry.getState(descriptor); | 3072 CacheState state = htmlEntry.getState(descriptor); |
3007 while (state != CacheState.ERROR && state != CacheState.VALID) { | 3073 while (state != CacheState.ERROR && state != CacheState.VALID) { |
3008 // | 3074 // |
3009 // If not, compute the information. Unless the modification date of the | 3075 // If not, compute the information. Unless the modification date of the |
3010 // source continues to change, this loop will eventually terminate. | 3076 // source continues to change, this loop will eventually terminate. |
3011 // | 3077 // |
3012 try { | 3078 try { |
3013 if (htmlEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { | 3079 if (htmlEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { |
3014 htmlEntry = new GetContentTask(this, source) | 3080 htmlEntry = new GetContentTask(this, source).perform(_resultRecorder) |
3015 .perform(_resultRecorder) as HtmlEntry; | 3081 as HtmlEntry; |
3016 } | 3082 } |
3017 htmlEntry = new ParseHtmlTask( | 3083 htmlEntry = new ParseHtmlTask( |
3018 this, source, htmlEntry.getValue(SourceEntry.CONTENT)) | 3084 this, source, htmlEntry.getValue(SourceEntry.CONTENT)) |
3019 .perform(_resultRecorder) as HtmlEntry; | 3085 .perform(_resultRecorder) as HtmlEntry; |
3020 } on AnalysisException catch (exception) { | 3086 } on AnalysisException catch (exception) { |
3021 throw exception; | 3087 throw exception; |
3022 } catch (exception, stackTrace) { | 3088 } catch (exception, stackTrace) { |
3023 throw new AnalysisException( | 3089 throw new AnalysisException( |
3024 "Exception", new CaughtException(exception, stackTrace)); | 3090 "Exception", new CaughtException(exception, stackTrace)); |
3025 } | 3091 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3141 * event where as this method does not. | 3207 * event where as this method does not. |
3142 */ | 3208 */ |
3143 bool _contentRangeChanged(Source source, String contents, int offset, | 3209 bool _contentRangeChanged(Source source, String contents, int offset, |
3144 int oldLength, int newLength) { | 3210 int oldLength, int newLength) { |
3145 bool changed = false; | 3211 bool changed = false; |
3146 String originalContents = _contentCache.setContents(source, contents); | 3212 String originalContents = _contentCache.setContents(source, contents); |
3147 if (contents != null) { | 3213 if (contents != null) { |
3148 if (contents != originalContents) { | 3214 if (contents != originalContents) { |
3149 if (_options.incremental) { | 3215 if (_options.incremental) { |
3150 _incrementalAnalysisCache = IncrementalAnalysisCache.update( | 3216 _incrementalAnalysisCache = IncrementalAnalysisCache.update( |
3151 _incrementalAnalysisCache, source, originalContents, contents, | 3217 _incrementalAnalysisCache, |
3152 offset, oldLength, newLength, _getReadableSourceEntry(source)); | 3218 source, |
| 3219 originalContents, |
| 3220 contents, |
| 3221 offset, |
| 3222 oldLength, |
| 3223 newLength, |
| 3224 _getReadableSourceEntry(source)); |
3153 } | 3225 } |
3154 _sourceChanged(source); | 3226 _sourceChanged(source); |
3155 changed = true; | 3227 changed = true; |
3156 SourceEntry sourceEntry = _cache.get(source); | 3228 SourceEntry sourceEntry = _cache.get(source); |
3157 if (sourceEntry != null) { | 3229 if (sourceEntry != null) { |
3158 sourceEntry.modificationTime = | 3230 sourceEntry.modificationTime = |
3159 _contentCache.getModificationStamp(source); | 3231 _contentCache.getModificationStamp(source); |
3160 sourceEntry.setValue(SourceEntry.CONTENT, contents); | 3232 sourceEntry.setValue(SourceEntry.CONTENT, contents); |
3161 } | 3233 } |
3162 } | 3234 } |
(...skipping 27 matching lines...) Expand all Loading... |
3190 AnalysisContextImpl_TaskData _createGenerateDartErrorsTask(Source unitSource, | 3262 AnalysisContextImpl_TaskData _createGenerateDartErrorsTask(Source unitSource, |
3191 DartEntry unitEntry, Source librarySource, DartEntry libraryEntry) { | 3263 DartEntry unitEntry, Source librarySource, DartEntry libraryEntry) { |
3192 if (unitEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) != | 3264 if (unitEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) != |
3193 CacheState.VALID || | 3265 CacheState.VALID || |
3194 libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID) { | 3266 libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID) { |
3195 return _createResolveDartLibraryTask(librarySource, libraryEntry); | 3267 return _createResolveDartLibraryTask(librarySource, libraryEntry); |
3196 } | 3268 } |
3197 CompilationUnit unit = | 3269 CompilationUnit unit = |
3198 unitEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource); | 3270 unitEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource); |
3199 if (unit == null) { | 3271 if (unit == null) { |
3200 CaughtException exception = new CaughtException(new AnalysisException( | 3272 CaughtException exception = new CaughtException( |
| 3273 new AnalysisException( |
3201 "Entry has VALID state for RESOLVED_UNIT but null value for ${unit
Source.fullName} in ${librarySource.fullName}"), | 3274 "Entry has VALID state for RESOLVED_UNIT but null value for ${unit
Source.fullName} in ${librarySource.fullName}"), |
3202 null); | 3275 null); |
3203 AnalysisEngine.instance.logger.logInformation( | 3276 AnalysisEngine.instance.logger |
3204 exception.toString(), exception); | 3277 .logInformation(exception.toString(), exception); |
3205 unitEntry.recordResolutionError(exception); | 3278 unitEntry.recordResolutionError(exception); |
3206 return new AnalysisContextImpl_TaskData(null, false); | 3279 return new AnalysisContextImpl_TaskData(null, false); |
3207 } | 3280 } |
3208 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT); | 3281 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT); |
3209 return new AnalysisContextImpl_TaskData( | 3282 return new AnalysisContextImpl_TaskData( |
3210 new GenerateDartErrorsTask(this, unitSource, unit, libraryElement), | 3283 new GenerateDartErrorsTask(this, unitSource, unit, libraryElement), |
3211 false); | 3284 false); |
3212 } | 3285 } |
3213 | 3286 |
3214 /** | 3287 /** |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3292 * Create a [ParseDartTask] for the given [source]. | 3365 * Create a [ParseDartTask] for the given [source]. |
3293 */ | 3366 */ |
3294 AnalysisContextImpl_TaskData _createParseDartTask( | 3367 AnalysisContextImpl_TaskData _createParseDartTask( |
3295 Source source, DartEntry dartEntry) { | 3368 Source source, DartEntry dartEntry) { |
3296 if (dartEntry.getState(DartEntry.TOKEN_STREAM) != CacheState.VALID || | 3369 if (dartEntry.getState(DartEntry.TOKEN_STREAM) != CacheState.VALID || |
3297 dartEntry.getState(SourceEntry.LINE_INFO) != CacheState.VALID) { | 3370 dartEntry.getState(SourceEntry.LINE_INFO) != CacheState.VALID) { |
3298 return _createScanDartTask(source, dartEntry); | 3371 return _createScanDartTask(source, dartEntry); |
3299 } | 3372 } |
3300 Token tokenStream = dartEntry.getValue(DartEntry.TOKEN_STREAM); | 3373 Token tokenStream = dartEntry.getValue(DartEntry.TOKEN_STREAM); |
3301 dartEntry.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED); | 3374 dartEntry.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED); |
3302 return new AnalysisContextImpl_TaskData(new ParseDartTask(this, source, | 3375 return new AnalysisContextImpl_TaskData( |
3303 tokenStream, dartEntry.getValue(SourceEntry.LINE_INFO)), false); | 3376 new ParseDartTask(this, source, tokenStream, |
| 3377 dartEntry.getValue(SourceEntry.LINE_INFO)), |
| 3378 false); |
3304 } | 3379 } |
3305 | 3380 |
3306 /** | 3381 /** |
3307 * Create a [ParseHtmlTask] for the given [source]. | 3382 * Create a [ParseHtmlTask] for the given [source]. |
3308 */ | 3383 */ |
3309 AnalysisContextImpl_TaskData _createParseHtmlTask( | 3384 AnalysisContextImpl_TaskData _createParseHtmlTask( |
3310 Source source, HtmlEntry htmlEntry) { | 3385 Source source, HtmlEntry htmlEntry) { |
3311 if (htmlEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { | 3386 if (htmlEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { |
3312 return _createGetContentTask(source, htmlEntry); | 3387 return _createGetContentTask(source, htmlEntry); |
3313 } | 3388 } |
(...skipping 12 matching lines...) Expand all Loading... |
3326 try { | 3401 try { |
3327 AnalysisContextImpl_CycleBuilder builder = | 3402 AnalysisContextImpl_CycleBuilder builder = |
3328 new AnalysisContextImpl_CycleBuilder(this); | 3403 new AnalysisContextImpl_CycleBuilder(this); |
3329 PerformanceStatistics.cycles.makeCurrentWhile(() { | 3404 PerformanceStatistics.cycles.makeCurrentWhile(() { |
3330 builder.computeCycleContaining(source); | 3405 builder.computeCycleContaining(source); |
3331 }); | 3406 }); |
3332 AnalysisContextImpl_TaskData taskData = builder.taskData; | 3407 AnalysisContextImpl_TaskData taskData = builder.taskData; |
3333 if (taskData != null) { | 3408 if (taskData != null) { |
3334 return taskData; | 3409 return taskData; |
3335 } | 3410 } |
3336 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryCycleTask( | 3411 return new AnalysisContextImpl_TaskData( |
3337 this, source, source, builder.librariesInCycle), false); | 3412 new ResolveDartLibraryCycleTask( |
| 3413 this, source, source, builder.librariesInCycle), |
| 3414 false); |
3338 } on AnalysisException catch (exception, stackTrace) { | 3415 } on AnalysisException catch (exception, stackTrace) { |
3339 dartEntry | 3416 dartEntry |
3340 .recordResolutionError(new CaughtException(exception, stackTrace)); | 3417 .recordResolutionError(new CaughtException(exception, stackTrace)); |
3341 AnalysisEngine.instance.logger.logError( | 3418 AnalysisEngine.instance.logger.logError( |
3342 "Internal error trying to create a ResolveDartLibraryTask", | 3419 "Internal error trying to create a ResolveDartLibraryTask", |
3343 new CaughtException(exception, stackTrace)); | 3420 new CaughtException(exception, stackTrace)); |
3344 } | 3421 } |
3345 return new AnalysisContextImpl_TaskData(null, false); | 3422 return new AnalysisContextImpl_TaskData(null, false); |
3346 } | 3423 } |
3347 | 3424 |
3348 /** | 3425 /** |
3349 * Create a [ResolveHtmlTask] for the given [source], marking the resolved | 3426 * Create a [ResolveHtmlTask] for the given [source], marking the resolved |
3350 * unit as being in-process. | 3427 * unit as being in-process. |
3351 */ | 3428 */ |
3352 AnalysisContextImpl_TaskData _createResolveHtmlTask( | 3429 AnalysisContextImpl_TaskData _createResolveHtmlTask( |
3353 Source source, HtmlEntry htmlEntry) { | 3430 Source source, HtmlEntry htmlEntry) { |
3354 if (htmlEntry.getState(HtmlEntry.PARSED_UNIT) != CacheState.VALID) { | 3431 if (htmlEntry.getState(HtmlEntry.PARSED_UNIT) != CacheState.VALID) { |
3355 return _createParseHtmlTask(source, htmlEntry); | 3432 return _createParseHtmlTask(source, htmlEntry); |
3356 } | 3433 } |
3357 return new AnalysisContextImpl_TaskData(new ResolveHtmlTask(this, source, | 3434 return new AnalysisContextImpl_TaskData( |
3358 htmlEntry.modificationTime, | 3435 new ResolveHtmlTask(this, source, htmlEntry.modificationTime, |
3359 htmlEntry.getValue(HtmlEntry.PARSED_UNIT)), false); | 3436 htmlEntry.getValue(HtmlEntry.PARSED_UNIT)), |
| 3437 false); |
3360 } | 3438 } |
3361 | 3439 |
3362 /** | 3440 /** |
3363 * Create a [ScanDartTask] for the given [source], marking the scan errors as | 3441 * Create a [ScanDartTask] for the given [source], marking the scan errors as |
3364 * being in-process. | 3442 * being in-process. |
3365 */ | 3443 */ |
3366 AnalysisContextImpl_TaskData _createScanDartTask( | 3444 AnalysisContextImpl_TaskData _createScanDartTask( |
3367 Source source, DartEntry dartEntry) { | 3445 Source source, DartEntry dartEntry) { |
3368 if (dartEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { | 3446 if (dartEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { |
3369 return _createGetContentTask(source, dartEntry); | 3447 return _createGetContentTask(source, dartEntry); |
3370 } | 3448 } |
3371 String content = dartEntry.getValue(SourceEntry.CONTENT); | 3449 String content = dartEntry.getValue(SourceEntry.CONTENT); |
3372 dartEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED); | 3450 dartEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED); |
3373 return new AnalysisContextImpl_TaskData( | 3451 return new AnalysisContextImpl_TaskData( |
3374 new ScanDartTask(this, source, content), false); | 3452 new ScanDartTask(this, source, content), false); |
3375 } | 3453 } |
3376 | 3454 |
3377 /** | 3455 /** |
3378 * Create a source entry for the given [source]. Return the source entry that | 3456 * Create a source entry for the given [source]. Return the source entry that |
3379 * was created, or `null` if the source should not be tracked by this context. | 3457 * was created, or `null` if the source should not be tracked by this context. |
3380 */ | 3458 */ |
3381 SourceEntry _createSourceEntry(Source source, bool explicitlyAdded) { | 3459 SourceEntry _createSourceEntry(Source source, bool explicitlyAdded) { |
3382 String name = source.shortName; | 3460 String name = source.shortName; |
3383 if (AnalysisEngine.isHtmlFileName(name)) { | 3461 if (AnalysisEngine.isHtmlFileName(name)) { |
3384 HtmlEntry htmlEntry = new HtmlEntry(); | 3462 HtmlEntry htmlEntry = new HtmlEntry(); |
3385 htmlEntry.modificationTime = getModificationStamp(source); | 3463 htmlEntry.modificationTime = getModificationStamp(source); |
3386 htmlEntry.explicitlyAdded = explicitlyAdded; | 3464 htmlEntry.explicitlyAdded = explicitlyAdded; |
3387 _cache.put(source, htmlEntry); | 3465 _cache.put(source, htmlEntry); |
| 3466 if (!explicitlyAdded) { |
| 3467 _implicitAnalysisEventsController |
| 3468 .add(new ImplicitAnalysisEvent(source, true)); |
| 3469 } |
3388 return htmlEntry; | 3470 return htmlEntry; |
3389 } else { | 3471 } else { |
3390 DartEntry dartEntry = new DartEntry(); | 3472 DartEntry dartEntry = new DartEntry(); |
3391 dartEntry.modificationTime = getModificationStamp(source); | 3473 dartEntry.modificationTime = getModificationStamp(source); |
3392 dartEntry.explicitlyAdded = explicitlyAdded; | 3474 dartEntry.explicitlyAdded = explicitlyAdded; |
3393 _cache.put(source, dartEntry); | 3475 _cache.put(source, dartEntry); |
| 3476 if (!explicitlyAdded) { |
| 3477 _implicitAnalysisEventsController |
| 3478 .add(new ImplicitAnalysisEvent(source, true)); |
| 3479 } |
3394 return dartEntry; | 3480 return dartEntry; |
3395 } | 3481 } |
3396 } | 3482 } |
3397 | 3483 |
3398 /** | 3484 /** |
3399 * Return a list containing all of the change notices that are waiting to be | 3485 * Return a list containing all of the change notices that are waiting to be |
3400 * returned. If there are no notices, then return either `null` or an empty | 3486 * returned. If there are no notices, then return either `null` or an empty |
3401 * list, depending on the value of [nullIfEmpty]. | 3487 * list, depending on the value of [nullIfEmpty]. |
3402 */ | 3488 */ |
3403 List<ChangeNotice> _getChangeNotices(bool nullIfEmpty) { | 3489 List<ChangeNotice> _getChangeNotices(bool nullIfEmpty) { |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3685 _accessedAst(source); | 3771 _accessedAst(source); |
3686 } | 3772 } |
3687 return htmlEntry.getValue(descriptor); | 3773 return htmlEntry.getValue(descriptor); |
3688 } | 3774 } |
3689 | 3775 |
3690 /** | 3776 /** |
3691 * Look at the given [source] to see whether a task needs to be performed | 3777 * Look at the given [source] to see whether a task needs to be performed |
3692 * related to it. Return the task that should be performed, or `null` if there | 3778 * related to it. Return the task that should be performed, or `null` if there |
3693 * is no more work to be done for the source. | 3779 * is no more work to be done for the source. |
3694 */ | 3780 */ |
3695 AnalysisContextImpl_TaskData _getNextAnalysisTaskForSource(Source source, | 3781 AnalysisContextImpl_TaskData _getNextAnalysisTaskForSource( |
3696 SourceEntry sourceEntry, bool isPriority, bool hintsEnabled, | 3782 Source source, |
| 3783 SourceEntry sourceEntry, |
| 3784 bool isPriority, |
| 3785 bool hintsEnabled, |
3697 bool lintsEnabled) { | 3786 bool lintsEnabled) { |
3698 // Refuse to generate tasks for html based files that are above 1500 KB | 3787 // Refuse to generate tasks for html based files that are above 1500 KB |
3699 if (_isTooBigHtmlSourceEntry(source, sourceEntry)) { | 3788 if (_isTooBigHtmlSourceEntry(source, sourceEntry)) { |
3700 // TODO (jwren) we still need to report an error of some kind back to the | 3789 // TODO (jwren) we still need to report an error of some kind back to the |
3701 // client. | 3790 // client. |
3702 return new AnalysisContextImpl_TaskData(null, false); | 3791 return new AnalysisContextImpl_TaskData(null, false); |
3703 } | 3792 } |
3704 if (sourceEntry == null) { | 3793 if (sourceEntry == null) { |
3705 return new AnalysisContextImpl_TaskData(null, false); | 3794 return new AnalysisContextImpl_TaskData(null, false); |
3706 } | 3795 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3876 * the library defined by the given [librarySource], or `null` if the | 3965 * the library defined by the given [librarySource], or `null` if the |
3877 * information is not cached. | 3966 * information is not cached. |
3878 */ | 3967 */ |
3879 TimestampedData<CompilationUnit> _getResolvedUnit( | 3968 TimestampedData<CompilationUnit> _getResolvedUnit( |
3880 CompilationUnitElement element, Source librarySource) { | 3969 CompilationUnitElement element, Source librarySource) { |
3881 SourceEntry sourceEntry = _cache.get(element.source); | 3970 SourceEntry sourceEntry = _cache.get(element.source); |
3882 if (sourceEntry is DartEntry) { | 3971 if (sourceEntry is DartEntry) { |
3883 DartEntry dartEntry = sourceEntry; | 3972 DartEntry dartEntry = sourceEntry; |
3884 if (dartEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) == | 3973 if (dartEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) == |
3885 CacheState.VALID) { | 3974 CacheState.VALID) { |
3886 return new TimestampedData<CompilationUnit>(dartEntry.modificationTime, | 3975 return new TimestampedData<CompilationUnit>( |
| 3976 dartEntry.modificationTime, |
3887 dartEntry.getValueInLibrary( | 3977 dartEntry.getValueInLibrary( |
3888 DartEntry.RESOLVED_UNIT, librarySource)); | 3978 DartEntry.RESOLVED_UNIT, librarySource)); |
3889 } | 3979 } |
3890 } | 3980 } |
3891 return null; | 3981 return null; |
3892 } | 3982 } |
3893 | 3983 |
3894 /** | 3984 /** |
3895 * Return a list containing all of the sources known to this context that have | 3985 * Return a list containing all of the sources known to this context that have |
3896 * the given [kind]. | 3986 * the given [kind]. |
3897 */ | 3987 */ |
3898 List<Source> _getSources(SourceKind kind) { | 3988 List<Source> _getSources(SourceKind kind) { |
3899 List<Source> sources = new List<Source>(); | 3989 List<Source> sources = new List<Source>(); |
3900 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); | 3990 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); |
3901 while (iterator.moveNext()) { | 3991 while (iterator.moveNext()) { |
3902 if (iterator.value.kind == kind) { | 3992 if (iterator.value.kind == kind) { |
3903 sources.add(iterator.key); | 3993 sources.add(iterator.key); |
3904 } | 3994 } |
3905 } | 3995 } |
3906 return sources; | 3996 return sources; |
3907 } | 3997 } |
3908 | 3998 |
3909 /** | 3999 /** |
3910 * Look at the given [source] to see whether a task needs to be performed | 4000 * Look at the given [source] to see whether a task needs to be performed |
3911 * related to it. If so, add the source to the set of sources that need to be | 4001 * related to it. If so, add the source to the set of sources that need to be |
3912 * processed. This method duplicates, and must therefore be kept in sync with, | 4002 * processed. This method duplicates, and must therefore be kept in sync with, |
3913 * [_getNextAnalysisTaskForSource]. This method is intended to be used for | 4003 * [_getNextAnalysisTaskForSource]. This method is intended to be used for |
3914 * testing purposes only. | 4004 * testing purposes only. |
3915 */ | 4005 */ |
3916 void _getSourcesNeedingProcessing(Source source, SourceEntry sourceEntry, | 4006 void _getSourcesNeedingProcessing( |
3917 bool isPriority, bool hintsEnabled, bool lintsEnabled, | 4007 Source source, |
| 4008 SourceEntry sourceEntry, |
| 4009 bool isPriority, |
| 4010 bool hintsEnabled, |
| 4011 bool lintsEnabled, |
3918 HashSet<Source> sources) { | 4012 HashSet<Source> sources) { |
3919 if (sourceEntry is DartEntry) { | 4013 if (sourceEntry is DartEntry) { |
3920 DartEntry dartEntry = sourceEntry; | 4014 DartEntry dartEntry = sourceEntry; |
3921 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS); | 4015 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS); |
3922 if (scanErrorsState == CacheState.INVALID || | 4016 if (scanErrorsState == CacheState.INVALID || |
3923 (isPriority && scanErrorsState == CacheState.FLUSHED)) { | 4017 (isPriority && scanErrorsState == CacheState.FLUSHED)) { |
3924 sources.add(source); | 4018 sources.add(source); |
3925 return; | 4019 return; |
3926 } | 4020 } |
3927 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); | 4021 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4094 if (_isClient(exported, htmlSource, visitedLibraries)) { | 4188 if (_isClient(exported, htmlSource, visitedLibraries)) { |
4095 return true; | 4189 return true; |
4096 } | 4190 } |
4097 } | 4191 } |
4098 return false; | 4192 return false; |
4099 } | 4193 } |
4100 | 4194 |
4101 bool _isTooBigHtmlSourceEntry(Source source, SourceEntry sourceEntry) => | 4195 bool _isTooBigHtmlSourceEntry(Source source, SourceEntry sourceEntry) => |
4102 false; | 4196 false; |
4103 | 4197 |
4104 /** | |
4105 * Log the given debugging [message]. | |
4106 */ | |
4107 void _logInformation(String message) { | |
4108 AnalysisEngine.instance.logger.logInformation(message); | |
4109 } | |
4110 | |
4111 // /** | 4198 // /** |
4112 // * Notify all of the analysis listeners that the given source is no longer i
ncluded in the set of | 4199 // * Notify all of the analysis listeners that the given source is no longer i
ncluded in the set of |
4113 // * sources that are being analyzed. | 4200 // * sources that are being analyzed. |
4114 // * | 4201 // * |
4115 // * @param source the source that is no longer being analyzed | 4202 // * @param source the source that is no longer being analyzed |
4116 // */ | 4203 // */ |
4117 // void _notifyExcludedSource(Source source) { | 4204 // void _notifyExcludedSource(Source source) { |
4118 // int count = _listeners.length; | 4205 // int count = _listeners.length; |
4119 // for (int i = 0; i < count; i++) { | 4206 // for (int i = 0; i < count; i++) { |
4120 // _listeners[i].excludedSource(this, source); | 4207 // _listeners[i].excludedSource(this, source); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4180 // * @param unit the result of resolving the source | 4267 // * @param unit the result of resolving the source |
4181 // */ | 4268 // */ |
4182 // void _notifyResolvedHtml(Source source, ht.HtmlUnit unit) { | 4269 // void _notifyResolvedHtml(Source source, ht.HtmlUnit unit) { |
4183 // int count = _listeners.length; | 4270 // int count = _listeners.length; |
4184 // for (int i = 0; i < count; i++) { | 4271 // for (int i = 0; i < count; i++) { |
4185 // _listeners[i].resolvedHtml(this, source, unit); | 4272 // _listeners[i].resolvedHtml(this, source, unit); |
4186 // } | 4273 // } |
4187 // } | 4274 // } |
4188 | 4275 |
4189 /** | 4276 /** |
| 4277 * Log the given debugging [message]. |
| 4278 */ |
| 4279 void _logInformation(String message) { |
| 4280 AnalysisEngine.instance.logger.logInformation(message); |
| 4281 } |
| 4282 |
| 4283 /** |
4190 * Notify all of the analysis listeners that a task is about to be performed. | 4284 * Notify all of the analysis listeners that a task is about to be performed. |
4191 */ | 4285 */ |
4192 void _notifyAboutToPerformTask(String taskDescription) { | 4286 void _notifyAboutToPerformTask(String taskDescription) { |
4193 int count = _listeners.length; | 4287 int count = _listeners.length; |
4194 for (int i = 0; i < count; i++) { | 4288 for (int i = 0; i < count; i++) { |
4195 _listeners[i].aboutToPerformTask(this, taskDescription); | 4289 _listeners[i].aboutToPerformTask(this, taskDescription); |
4196 } | 4290 } |
4197 } | 4291 } |
4198 | 4292 |
4199 /** | 4293 /** |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4562 LineInfo lineInfo = task.lineInfo; | 4656 LineInfo lineInfo = task.lineInfo; |
4563 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo); | 4657 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo); |
4564 dartEntry.setValue(DartEntry.TOKEN_STREAM, task.tokenStream); | 4658 dartEntry.setValue(DartEntry.TOKEN_STREAM, task.tokenStream); |
4565 dartEntry.setValue(DartEntry.SCAN_ERRORS, task.errors); | 4659 dartEntry.setValue(DartEntry.SCAN_ERRORS, task.errors); |
4566 _cache.storedAst(source); | 4660 _cache.storedAst(source); |
4567 ChangeNoticeImpl notice = getNotice(source); | 4661 ChangeNoticeImpl notice = getNotice(source); |
4568 notice.setErrors(dartEntry.allErrors, lineInfo); | 4662 notice.setErrors(dartEntry.allErrors, lineInfo); |
4569 return dartEntry; | 4663 return dartEntry; |
4570 } | 4664 } |
4571 | 4665 |
| 4666 void _removeFromCache(Source source) { |
| 4667 SourceEntry entry = _cache.remove(source); |
| 4668 if (entry != null && !entry.explicitlyAdded) { |
| 4669 _implicitAnalysisEventsController |
| 4670 .add(new ImplicitAnalysisEvent(source, false)); |
| 4671 } |
| 4672 } |
| 4673 |
4572 /** | 4674 /** |
4573 * Remove the given [librarySource] from the list of containing libraries for | 4675 * Remove the given [librarySource] from the list of containing libraries for |
4574 * all of the parts referenced by the given [dartEntry]. | 4676 * all of the parts referenced by the given [dartEntry]. |
4575 */ | 4677 */ |
4576 void _removeFromParts(Source librarySource, DartEntry dartEntry) { | 4678 void _removeFromParts(Source librarySource, DartEntry dartEntry) { |
4577 List<Source> oldParts = dartEntry.getValue(DartEntry.INCLUDED_PARTS); | 4679 List<Source> oldParts = dartEntry.getValue(DartEntry.INCLUDED_PARTS); |
4578 for (int i = 0; i < oldParts.length; i++) { | 4680 for (int i = 0; i < oldParts.length; i++) { |
4579 Source partSource = oldParts[i]; | 4681 Source partSource = oldParts[i]; |
4580 DartEntry partEntry = _getReadableDartEntry(partSource); | 4682 DartEntry partEntry = _getReadableDartEntry(partSource); |
4581 if (partEntry != null && !identical(partEntry, dartEntry)) { | 4683 if (partEntry != null && !identical(partEntry, dartEntry)) { |
4582 partEntry.removeContainingLibrary(librarySource); | 4684 partEntry.removeContainingLibrary(librarySource); |
4583 if (partEntry.containingLibraries.length == 0 && !exists(partSource)) { | 4685 if (partEntry.containingLibraries.length == 0 && !exists(partSource)) { |
4584 _cache.remove(partSource); | 4686 _removeFromCache(partSource); |
4585 } | 4687 } |
4586 } | 4688 } |
4587 } | 4689 } |
4588 } | 4690 } |
4589 | 4691 |
4590 /** | 4692 /** |
4591 * Remove the given libraries that are keys in the given map from the list of | 4693 * Remove the given libraries that are keys in the given map from the list of |
4592 * containing libraries for each of the parts in the corresponding value. | 4694 * containing libraries for each of the parts in the corresponding value. |
4593 */ | 4695 */ |
4594 void _removeFromPartsUsingMap(HashMap<Source, List<Source>> oldPartMap) { | 4696 void _removeFromPartsUsingMap(HashMap<Source, List<Source>> oldPartMap) { |
4595 oldPartMap.forEach((Source librarySource, List<Source> oldParts) { | 4697 oldPartMap.forEach((Source librarySource, List<Source> oldParts) { |
4596 for (int i = 0; i < oldParts.length; i++) { | 4698 for (int i = 0; i < oldParts.length; i++) { |
4597 Source partSource = oldParts[i]; | 4699 Source partSource = oldParts[i]; |
4598 if (partSource != librarySource) { | 4700 if (partSource != librarySource) { |
4599 DartEntry partEntry = _getReadableDartEntry(partSource); | 4701 DartEntry partEntry = _getReadableDartEntry(partSource); |
4600 if (partEntry != null) { | 4702 if (partEntry != null) { |
4601 partEntry.removeContainingLibrary(librarySource); | 4703 partEntry.removeContainingLibrary(librarySource); |
4602 if (partEntry.containingLibraries.length == 0 && | 4704 if (partEntry.containingLibraries.length == 0 && |
4603 !exists(partSource)) { | 4705 !exists(partSource)) { |
4604 _cache.remove(partSource); | 4706 _removeFromCache(partSource); |
4605 } | 4707 } |
4606 } | 4708 } |
4607 } | 4709 } |
4608 } | 4710 } |
4609 }); | 4711 }); |
4610 } | 4712 } |
4611 | 4713 |
4612 /** | 4714 /** |
4613 * Remove the given [source] from the priority order if it is in the list. | 4715 * Remove the given [source] from the priority order if it is in the list. |
4614 */ | 4716 */ |
4615 void _removeFromPriorityOrder(Source source) { | 4717 void _removeFromPriorityOrder(Source source) { |
4616 int count = _priorityOrder.length; | 4718 int count = _priorityOrder.length; |
4617 List<Source> newOrder = new List<Source>(); | 4719 List<Source> newOrder = new List<Source>(); |
4618 for (int i = 0; i < count; i++) { | 4720 for (int i = 0; i < count; i++) { |
4619 if (_priorityOrder[i] != source) { | 4721 if (_priorityOrder[i] != source) { |
4620 newOrder.add(_priorityOrder[i]); | 4722 newOrder.add(_priorityOrder[i]); |
4621 } | 4723 } |
4622 } | 4724 } |
4623 if (newOrder.length < count) { | 4725 if (newOrder.length < count) { |
4624 analysisPriorityOrder = newOrder; | 4726 analysisPriorityOrder = newOrder; |
4625 } | 4727 } |
4626 } | 4728 } |
4627 | 4729 |
4628 /** | 4730 /** |
4629 * Create an entry for the newly added [source] and invalidate any sources | 4731 * Create an entry for the newly added [source] and invalidate any sources |
4630 * that referenced the source before it existed. | 4732 * that referenced the source before it existed. |
4631 */ | 4733 */ |
4632 void _sourceAvailable(Source source) { | 4734 void _sourceAvailable(Source source) { |
| 4735 // TODO(brianwilkerson) This method needs to check whether the source was |
| 4736 // previously being implicitly analyzed. If so, the cache entry needs to be |
| 4737 // update to reflect the new status and an event needs to be generated to |
| 4738 // inform clients that it is no longer being implicitly analyzed. |
4633 SourceEntry sourceEntry = _cache.get(source); | 4739 SourceEntry sourceEntry = _cache.get(source); |
4634 if (sourceEntry == null) { | 4740 if (sourceEntry == null) { |
4635 sourceEntry = _createSourceEntry(source, true); | 4741 sourceEntry = _createSourceEntry(source, true); |
4636 } else { | 4742 } else { |
4637 _propagateInvalidation(source, sourceEntry); | 4743 _propagateInvalidation(source, sourceEntry); |
4638 sourceEntry = _cache.get(source); | 4744 sourceEntry = _cache.get(source); |
4639 } | 4745 } |
4640 if (sourceEntry is HtmlEntry) { | 4746 if (sourceEntry is HtmlEntry) { |
4641 _workManager.add(source, SourcePriority.HTML); | 4747 _workManager.add(source, SourcePriority.HTML); |
4642 } else if (sourceEntry is DartEntry) { | 4748 } else if (sourceEntry is DartEntry) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4711 libraries.add(librarySource); | 4817 libraries.add(librarySource); |
4712 for (Source dependentLibrary | 4818 for (Source dependentLibrary |
4713 in getLibrariesDependingOn(librarySource)) { | 4819 in getLibrariesDependingOn(librarySource)) { |
4714 libraries.add(dependentLibrary); | 4820 libraries.add(dependentLibrary); |
4715 } | 4821 } |
4716 } | 4822 } |
4717 for (Source librarySource in libraries) { | 4823 for (Source librarySource in libraries) { |
4718 _invalidateLibraryResolution(librarySource); | 4824 _invalidateLibraryResolution(librarySource); |
4719 } | 4825 } |
4720 } | 4826 } |
4721 _cache.remove(source); | 4827 _removeFromCache(source); |
4722 _workManager.remove(source); | 4828 _workManager.remove(source); |
4723 _removeFromPriorityOrder(source); | 4829 _removeFromPriorityOrder(source); |
4724 } | 4830 } |
4725 | 4831 |
4726 /** | 4832 /** |
4727 * TODO(scheglov) A hackish, limited incremental resolution implementation. | 4833 * TODO(scheglov) A hackish, limited incremental resolution implementation. |
4728 */ | 4834 */ |
4729 bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) { | 4835 bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) { |
4730 return PerformanceStatistics.incrementalAnalysis.makeCurrentWhile(() { | 4836 return PerformanceStatistics.incrementalAnalysis.makeCurrentWhile(() { |
4731 incrementalResolutionValidation_lastUnitSource = null; | 4837 incrementalResolutionValidation_lastUnitSource = null; |
(...skipping 17 matching lines...) Expand all Loading... |
4749 } | 4855 } |
4750 // prepare the existing unit | 4856 // prepare the existing unit |
4751 CompilationUnit oldUnit = | 4857 CompilationUnit oldUnit = |
4752 getResolvedCompilationUnit2(unitSource, librarySource); | 4858 getResolvedCompilationUnit2(unitSource, librarySource); |
4753 if (oldUnit == null) { | 4859 if (oldUnit == null) { |
4754 return false; | 4860 return false; |
4755 } | 4861 } |
4756 // do resolution | 4862 // do resolution |
4757 Stopwatch perfCounter = new Stopwatch()..start(); | 4863 Stopwatch perfCounter = new Stopwatch()..start(); |
4758 PoorMansIncrementalResolver resolver = new PoorMansIncrementalResolver( | 4864 PoorMansIncrementalResolver resolver = new PoorMansIncrementalResolver( |
4759 typeProvider, unitSource, getReadableSourceEntryOrNull(unitSource), | 4865 typeProvider, |
4760 null, null, oldUnit, analysisOptions.incrementalApi, analysisOptions); | 4866 unitSource, |
| 4867 getReadableSourceEntryOrNull(unitSource), |
| 4868 null, |
| 4869 null, |
| 4870 oldUnit, |
| 4871 analysisOptions.incrementalApi); |
4761 bool success = resolver.resolve(newCode); | 4872 bool success = resolver.resolve(newCode); |
4762 AnalysisEngine.instance.instrumentationService.logPerformance( | 4873 AnalysisEngine.instance.instrumentationService.logPerformance( |
4763 AnalysisPerformanceKind.INCREMENTAL, perfCounter, | 4874 AnalysisPerformanceKind.INCREMENTAL, |
| 4875 perfCounter, |
4764 'success=$success,context_id=$_id,code_length=${newCode.length}'); | 4876 'success=$success,context_id=$_id,code_length=${newCode.length}'); |
4765 if (!success) { | 4877 if (!success) { |
4766 return false; | 4878 return false; |
4767 } | 4879 } |
4768 // if validation, remember the result, but throw it away | 4880 // if validation, remember the result, but throw it away |
4769 if (analysisOptions.incrementalValidation) { | 4881 if (analysisOptions.incrementalValidation) { |
4770 incrementalResolutionValidation_lastUnitSource = oldUnit.element.source; | 4882 incrementalResolutionValidation_lastUnitSource = oldUnit.element.source; |
4771 incrementalResolutionValidation_lastLibrarySource = | 4883 incrementalResolutionValidation_lastLibrarySource = |
4772 oldUnit.element.library.source; | 4884 oldUnit.element.library.source; |
4773 incrementalResolutionValidation_lastUnit = oldUnit; | 4885 incrementalResolutionValidation_lastUnit = oldUnit; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4973 _librariesInCycle = _dependencyGraph.findCycleContaining(targetLibrary); | 5085 _librariesInCycle = _dependencyGraph.findCycleContaining(targetLibrary); |
4974 // | 5086 // |
4975 // Ensure that all of the data needed to resolve them has been computed. | 5087 // Ensure that all of the data needed to resolve them has been computed. |
4976 // | 5088 // |
4977 _ensureImportsAndExports(); | 5089 _ensureImportsAndExports(); |
4978 if (_taskData != null) { | 5090 if (_taskData != null) { |
4979 // At least one imported library needs to be resolved before the target | 5091 // At least one imported library needs to be resolved before the target |
4980 // library. | 5092 // library. |
4981 AnalysisTask task = _taskData.task; | 5093 AnalysisTask task = _taskData.task; |
4982 if (task is ResolveDartLibraryTask) { | 5094 if (task is ResolveDartLibraryTask) { |
4983 AnalysisContextImpl_this._workManager.addFirst( | 5095 AnalysisContextImpl_this._workManager |
4984 task.librarySource, SourcePriority.LIBRARY); | 5096 .addFirst(task.librarySource, SourcePriority.LIBRARY); |
4985 } | 5097 } |
4986 return; | 5098 return; |
4987 } | 5099 } |
4988 _computePartsInCycle(librarySource); | 5100 _computePartsInCycle(librarySource); |
4989 if (_taskData != null) { | 5101 if (_taskData != null) { |
4990 // At least one part needs to be parsed. | 5102 // At least one part needs to be parsed. |
4991 return; | 5103 return; |
4992 } | 5104 } |
4993 // All of the AST's necessary to perform a resolution of the library cycle | 5105 // All of the AST's necessary to perform a resolution of the library cycle |
4994 // have been gathered, so it is no longer necessary to retain them in the | 5106 // have been gathered, so it is no longer necessary to retain them in the |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5202 * Ensure that the given [library] has an element model built for it. If | 5314 * Ensure that the given [library] has an element model built for it. If |
5203 * another task needs to be executed first in order to build the element | 5315 * another task needs to be executed first in order to build the element |
5204 * model, that task is placed in [taskData]. | 5316 * model, that task is placed in [taskData]. |
5205 */ | 5317 */ |
5206 void _ensureElementModel(ResolvableLibrary library) { | 5318 void _ensureElementModel(ResolvableLibrary library) { |
5207 Source librarySource = library.librarySource; | 5319 Source librarySource = library.librarySource; |
5208 DartEntry libraryEntry = | 5320 DartEntry libraryEntry = |
5209 AnalysisContextImpl_this._getReadableDartEntry(librarySource); | 5321 AnalysisContextImpl_this._getReadableDartEntry(librarySource); |
5210 if (libraryEntry != null && | 5322 if (libraryEntry != null && |
5211 libraryEntry.getState(DartEntry.PARSED_UNIT) != CacheState.ERROR) { | 5323 libraryEntry.getState(DartEntry.PARSED_UNIT) != CacheState.ERROR) { |
5212 AnalysisContextImpl_this._workManager.addFirst( | 5324 AnalysisContextImpl_this._workManager |
5213 librarySource, SourcePriority.LIBRARY); | 5325 .addFirst(librarySource, SourcePriority.LIBRARY); |
5214 if (_taskData == null) { | 5326 if (_taskData == null) { |
5215 _taskData = AnalysisContextImpl_this._createResolveDartLibraryTask( | 5327 _taskData = AnalysisContextImpl_this._createResolveDartLibraryTask( |
5216 librarySource, libraryEntry); | 5328 librarySource, libraryEntry); |
5217 } | 5329 } |
5218 } | 5330 } |
5219 } | 5331 } |
5220 | 5332 |
5221 /** | 5333 /** |
5222 * Ensure that all of the libraries that are exported by the given [library] | 5334 * Ensure that all of the libraries that are exported by the given [library] |
5223 * (but are not themselves in the cycle) have element models built for them. | 5335 * (but are not themselves in the cycle) have element models built for them. |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5785 */ | 5897 */ |
5786 bool useTaskModel = false; | 5898 bool useTaskModel = false; |
5787 | 5899 |
5788 /** | 5900 /** |
5789 * A flag indicating whether the task model should attempt to limit | 5901 * A flag indicating whether the task model should attempt to limit |
5790 * invalidation after a change. | 5902 * invalidation after a change. |
5791 */ | 5903 */ |
5792 bool limitInvalidationInTaskModel = false; | 5904 bool limitInvalidationInTaskModel = false; |
5793 | 5905 |
5794 /** | 5906 /** |
| 5907 * The plugins that are defined outside the `analyzer` package. |
| 5908 */ |
| 5909 List<Plugin> _userDefinedPlugins = <Plugin>[]; |
| 5910 |
| 5911 /** |
5795 * The task manager used to manage the tasks used to analyze code. | 5912 * The task manager used to manage the tasks used to analyze code. |
5796 */ | 5913 */ |
5797 TaskManager _taskManager; | 5914 TaskManager _taskManager; |
5798 | 5915 |
5799 AnalysisEngine._(); | 5916 AnalysisEngine._(); |
5800 | 5917 |
5801 /** | 5918 /** |
5802 * Return the instrumentation service that is to be used by this analysis | 5919 * Return the instrumentation service that is to be used by this analysis |
5803 * engine. | 5920 * engine. |
5804 */ | 5921 */ |
(...skipping 28 matching lines...) Expand all Loading... |
5833 /** | 5950 /** |
5834 * Return the list of supported plugins for processing by clients. | 5951 * Return the list of supported plugins for processing by clients. |
5835 */ | 5952 */ |
5836 List<Plugin> get supportedPlugins { | 5953 List<Plugin> get supportedPlugins { |
5837 if (_supportedPlugins == null) { | 5954 if (_supportedPlugins == null) { |
5838 _supportedPlugins = <Plugin>[ | 5955 _supportedPlugins = <Plugin>[ |
5839 enginePlugin, | 5956 enginePlugin, |
5840 commandLinePlugin, | 5957 commandLinePlugin, |
5841 optionsPlugin | 5958 optionsPlugin |
5842 ]; | 5959 ]; |
| 5960 _supportedPlugins.addAll(_userDefinedPlugins); |
5843 } | 5961 } |
5844 return _supportedPlugins; | 5962 return _supportedPlugins; |
5845 } | 5963 } |
5846 | 5964 |
5847 /** | 5965 /** |
5848 * Return the task manager used to manage the tasks used to analyze code. | 5966 * Return the task manager used to manage the tasks used to analyze code. |
5849 */ | 5967 */ |
5850 TaskManager get taskManager { | 5968 TaskManager get taskManager { |
5851 if (_taskManager == null) { | 5969 if (_taskManager == null) { |
5852 if (enginePlugin.taskExtensionPoint == null) { | 5970 new ExtensionManager().processPlugins(supportedPlugins); |
5853 // The plugin wasn't used, so tasks are not registered. | |
5854 new ExtensionManager().processPlugins([enginePlugin]); | |
5855 } | |
5856 _taskManager = new TaskManager(); | 5971 _taskManager = new TaskManager(); |
5857 _taskManager.addTaskDescriptors(enginePlugin.taskDescriptors); | 5972 _taskManager.addTaskDescriptors(enginePlugin.taskDescriptors); |
5858 // TODO(brianwilkerson) Create a way to associate different results with | 5973 // TODO(brianwilkerson) Create a way to associate different results with |
5859 // different file suffixes, then make this pluggable. | 5974 // different file suffixes, then make this pluggable. |
5860 _taskManager.addGeneralResult(DART_ERRORS); | 5975 _taskManager.addGeneralResult(DART_ERRORS); |
5861 } | 5976 } |
5862 return _taskManager; | 5977 return _taskManager; |
5863 } | 5978 } |
5864 | 5979 |
5865 /** | 5980 /** |
| 5981 * Set plugins that are defined outside the `analyzer` package. |
| 5982 */ |
| 5983 void set userDefinedPlugins(List<Plugin> plugins) { |
| 5984 if (plugins == null) { |
| 5985 plugins = <Plugin>[]; |
| 5986 } |
| 5987 _userDefinedPlugins = plugins; |
| 5988 _supportedPlugins = null; |
| 5989 _taskManager = null; |
| 5990 } |
| 5991 |
| 5992 /** |
5866 * Clear any caches holding on to analysis results so that a full re-analysis | 5993 * Clear any caches holding on to analysis results so that a full re-analysis |
5867 * will be performed the next time an analysis context is created. | 5994 * will be performed the next time an analysis context is created. |
5868 */ | 5995 */ |
5869 void clearCaches() { | 5996 void clearCaches() { |
5870 partitionManager.clearCache(); | 5997 partitionManager.clearCache(); |
5871 } | 5998 } |
5872 | 5999 |
5873 /** | 6000 /** |
5874 * Create and return a new context in which analysis can be performed. | 6001 * Create and return a new context in which analysis can be performed. |
5875 */ | 6002 */ |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6102 @deprecated // Always true | 6229 @deprecated // Always true |
6103 bool get enableNullAwareOperators; | 6230 bool get enableNullAwareOperators; |
6104 | 6231 |
6105 /** | 6232 /** |
6106 * Return `true` to strictly follow the specification when generating | 6233 * Return `true` to strictly follow the specification when generating |
6107 * warnings on "call" methods (fixes dartbug.com/21938). | 6234 * warnings on "call" methods (fixes dartbug.com/21938). |
6108 */ | 6235 */ |
6109 bool get enableStrictCallChecks; | 6236 bool get enableStrictCallChecks; |
6110 | 6237 |
6111 /** | 6238 /** |
| 6239 * Return `true` if mixins are allowed to inherit from types other than |
| 6240 * Object, and are allowed to reference `super`. |
| 6241 */ |
| 6242 bool get enableSuperMixins; |
| 6243 |
| 6244 /** |
6112 * Return `true` if errors, warnings and hints should be generated for sources | 6245 * Return `true` if errors, warnings and hints should be generated for sources |
6113 * that are implicitly being analyzed. The default value is `true`. | 6246 * that are implicitly being analyzed. The default value is `true`. |
6114 */ | 6247 */ |
6115 bool get generateImplicitErrors; | 6248 bool get generateImplicitErrors; |
6116 | 6249 |
6117 /** | 6250 /** |
6118 * Return `true` if errors, warnings and hints should be generated for sources | 6251 * Return `true` if errors, warnings and hints should be generated for sources |
6119 * in the SDK. The default value is `false`. | 6252 * in the SDK. The default value is `false`. |
6120 */ | 6253 */ |
6121 bool get generateSdkErrors; | 6254 bool get generateSdkErrors; |
(...skipping 23 matching lines...) Expand all Loading... |
6145 | 6278 |
6146 /** | 6279 /** |
6147 * Return `true` if analysis is to generate lint warnings. | 6280 * Return `true` if analysis is to generate lint warnings. |
6148 */ | 6281 */ |
6149 bool get lint; | 6282 bool get lint; |
6150 | 6283 |
6151 /** | 6284 /** |
6152 * Return `true` if analysis is to parse comments. | 6285 * Return `true` if analysis is to parse comments. |
6153 */ | 6286 */ |
6154 bool get preserveComments; | 6287 bool get preserveComments; |
| 6288 |
| 6289 /** |
| 6290 * Return `true` if strong mode analysis should be used. |
| 6291 */ |
| 6292 bool get strongMode; |
6155 } | 6293 } |
6156 | 6294 |
6157 /** | 6295 /** |
6158 * A set of analysis options used to control the behavior of an analysis | 6296 * A set of analysis options used to control the behavior of an analysis |
6159 * context. | 6297 * context. |
6160 */ | 6298 */ |
6161 class AnalysisOptionsImpl implements AnalysisOptions { | 6299 class AnalysisOptionsImpl implements AnalysisOptions { |
6162 /** | 6300 /** |
6163 * The maximum number of sources for which data should be kept in the cache. | 6301 * The maximum number of sources for which data should be kept in the cache. |
6164 */ | 6302 */ |
(...skipping 21 matching lines...) Expand all Loading... |
6186 /** | 6324 /** |
6187 * The maximum number of sources for which AST structures should be kept in | 6325 * The maximum number of sources for which AST structures should be kept in |
6188 * the cache. | 6326 * the cache. |
6189 */ | 6327 */ |
6190 int cacheSize = DEFAULT_CACHE_SIZE; | 6328 int cacheSize = DEFAULT_CACHE_SIZE; |
6191 | 6329 |
6192 /** | 6330 /** |
6193 * A flag indicating whether analysis is to generate dart2js related hint | 6331 * A flag indicating whether analysis is to generate dart2js related hint |
6194 * results. | 6332 * results. |
6195 */ | 6333 */ |
6196 bool dart2jsHint = true; | 6334 bool dart2jsHint = false; |
6197 | 6335 |
6198 /** | 6336 /** |
6199 * A flag indicating whether generic methods are to be supported (DEP 22). | 6337 * A flag indicating whether generic methods are to be supported (DEP 22). |
6200 */ | 6338 */ |
6201 bool enableGenericMethods = false; | 6339 bool enableGenericMethods = false; |
6202 | 6340 |
6203 /** | 6341 /** |
6204 * A flag indicating whether analysis is to strictly follow the specification | 6342 * A flag indicating whether analysis is to strictly follow the specification |
6205 * when generating warnings on "call" methods (fixes dartbug.com/21938). | 6343 * when generating warnings on "call" methods (fixes dartbug.com/21938). |
6206 */ | 6344 */ |
6207 bool enableStrictCallChecks = false; | 6345 bool enableStrictCallChecks = false; |
6208 | 6346 |
6209 /** | 6347 /** |
| 6348 * A flag indicating whether mixins are allowed to inherit from types other |
| 6349 * than Object, and are allowed to reference `super`. |
| 6350 */ |
| 6351 bool enableSuperMixins = false; |
| 6352 |
| 6353 /** |
6210 * A flag indicating whether errors, warnings and hints should be generated | 6354 * A flag indicating whether errors, warnings and hints should be generated |
6211 * for sources that are implicitly being analyzed. | 6355 * for sources that are implicitly being analyzed. |
6212 */ | 6356 */ |
6213 bool generateImplicitErrors = true; | 6357 bool generateImplicitErrors = true; |
6214 | 6358 |
6215 /** | 6359 /** |
6216 * A flag indicating whether errors, warnings and hints should be generated | 6360 * A flag indicating whether errors, warnings and hints should be generated |
6217 * for sources in the SDK. | 6361 * for sources in the SDK. |
6218 */ | 6362 */ |
6219 bool generateSdkErrors = false; | 6363 bool generateSdkErrors = false; |
(...skipping 25 matching lines...) Expand all Loading... |
6245 * A flag indicating whether analysis is to generate lint warnings. | 6389 * A flag indicating whether analysis is to generate lint warnings. |
6246 */ | 6390 */ |
6247 bool lint = false; | 6391 bool lint = false; |
6248 | 6392 |
6249 /** | 6393 /** |
6250 * A flag indicating whether analysis is to parse comments. | 6394 * A flag indicating whether analysis is to parse comments. |
6251 */ | 6395 */ |
6252 bool preserveComments = true; | 6396 bool preserveComments = true; |
6253 | 6397 |
6254 /** | 6398 /** |
| 6399 * A flag indicating whether strong-mode analysis should be used. |
| 6400 */ |
| 6401 bool strongMode = false; |
| 6402 |
| 6403 /** |
6255 * Initialize a newly created set of analysis options to have their default | 6404 * Initialize a newly created set of analysis options to have their default |
6256 * values. | 6405 * values. |
6257 */ | 6406 */ |
6258 AnalysisOptionsImpl(); | 6407 AnalysisOptionsImpl(); |
6259 | 6408 |
6260 /** | 6409 /** |
6261 * Initialize a newly created set of analysis options to have the same values | 6410 * Initialize a newly created set of analysis options to have the same values |
6262 * as those in the given set of analysis [options]. | 6411 * as those in the given set of analysis [options]. |
6263 */ | 6412 */ |
6264 @deprecated // Use new AnalysisOptionsImpl.from(options) | 6413 @deprecated // Use new AnalysisOptionsImpl.from(options) |
6265 AnalysisOptionsImpl.con1(AnalysisOptions options) { | 6414 AnalysisOptionsImpl.con1(AnalysisOptions options) { |
6266 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; | 6415 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; |
6267 cacheSize = options.cacheSize; | 6416 cacheSize = options.cacheSize; |
6268 dart2jsHint = options.dart2jsHint; | 6417 dart2jsHint = options.dart2jsHint; |
6269 enableStrictCallChecks = options.enableStrictCallChecks; | 6418 enableStrictCallChecks = options.enableStrictCallChecks; |
| 6419 enableSuperMixins = options.enableSuperMixins; |
6270 generateImplicitErrors = options.generateImplicitErrors; | 6420 generateImplicitErrors = options.generateImplicitErrors; |
6271 generateSdkErrors = options.generateSdkErrors; | 6421 generateSdkErrors = options.generateSdkErrors; |
6272 hint = options.hint; | 6422 hint = options.hint; |
6273 incremental = options.incremental; | 6423 incremental = options.incremental; |
6274 incrementalApi = options.incrementalApi; | 6424 incrementalApi = options.incrementalApi; |
6275 incrementalValidation = options.incrementalValidation; | 6425 incrementalValidation = options.incrementalValidation; |
6276 lint = options.lint; | 6426 lint = options.lint; |
6277 preserveComments = options.preserveComments; | 6427 preserveComments = options.preserveComments; |
| 6428 strongMode = options.strongMode; |
6278 } | 6429 } |
6279 | 6430 |
6280 /** | 6431 /** |
6281 * Initialize a newly created set of analysis options to have the same values | 6432 * Initialize a newly created set of analysis options to have the same values |
6282 * as those in the given set of analysis [options]. | 6433 * as those in the given set of analysis [options]. |
6283 */ | 6434 */ |
6284 AnalysisOptionsImpl.from(AnalysisOptions options) { | 6435 AnalysisOptionsImpl.from(AnalysisOptions options) { |
6285 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; | 6436 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; |
6286 cacheSize = options.cacheSize; | 6437 cacheSize = options.cacheSize; |
6287 dart2jsHint = options.dart2jsHint; | 6438 dart2jsHint = options.dart2jsHint; |
6288 enableStrictCallChecks = options.enableStrictCallChecks; | 6439 enableStrictCallChecks = options.enableStrictCallChecks; |
| 6440 enableSuperMixins = options.enableSuperMixins; |
6289 generateImplicitErrors = options.generateImplicitErrors; | 6441 generateImplicitErrors = options.generateImplicitErrors; |
6290 generateSdkErrors = options.generateSdkErrors; | 6442 generateSdkErrors = options.generateSdkErrors; |
6291 hint = options.hint; | 6443 hint = options.hint; |
6292 incremental = options.incremental; | 6444 incremental = options.incremental; |
6293 incrementalApi = options.incrementalApi; | 6445 incrementalApi = options.incrementalApi; |
6294 incrementalValidation = options.incrementalValidation; | 6446 incrementalValidation = options.incrementalValidation; |
6295 lint = options.lint; | 6447 lint = options.lint; |
6296 preserveComments = options.preserveComments; | 6448 preserveComments = options.preserveComments; |
| 6449 strongMode = options.strongMode; |
6297 } | 6450 } |
6298 | 6451 |
6299 bool get analyzeFunctionBodies { | 6452 bool get analyzeFunctionBodies { |
6300 if (identical(analyzeFunctionBodiesPredicate, _analyzeAllFunctionBodies)) { | 6453 if (identical(analyzeFunctionBodiesPredicate, _analyzeAllFunctionBodies)) { |
6301 return true; | 6454 return true; |
6302 } else if (identical( | 6455 } else if (identical( |
6303 analyzeFunctionBodiesPredicate, _analyzeNoFunctionBodies)) { | 6456 analyzeFunctionBodiesPredicate, _analyzeNoFunctionBodies)) { |
6304 return false; | 6457 return false; |
6305 } else { | 6458 } else { |
6306 throw new StateError('analyzeFunctionBodiesPredicate in use'); | 6459 throw new StateError('analyzeFunctionBodiesPredicate in use'); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6494 * Perform this analysis task, ensuring that all exceptions are wrapped in an | 6647 * Perform this analysis task, ensuring that all exceptions are wrapped in an |
6495 * [AnalysisException]. Throws an [AnalysisException] if any exception occurs | 6648 * [AnalysisException]. Throws an [AnalysisException] if any exception occurs |
6496 * while performing the task | 6649 * while performing the task |
6497 */ | 6650 */ |
6498 void _safelyPerform() { | 6651 void _safelyPerform() { |
6499 try { | 6652 try { |
6500 String contextName = context.name; | 6653 String contextName = context.name; |
6501 if (contextName == null) { | 6654 if (contextName == null) { |
6502 contextName = 'unnamed'; | 6655 contextName = 'unnamed'; |
6503 } | 6656 } |
6504 AnalysisEngine.instance.instrumentationService.logAnalysisTask( | 6657 AnalysisEngine.instance.instrumentationService |
6505 contextName, taskDescription); | 6658 .logAnalysisTask(contextName, taskDescription); |
6506 internalPerform(); | 6659 internalPerform(); |
6507 } on AnalysisException { | 6660 } on AnalysisException { |
6508 rethrow; | 6661 rethrow; |
6509 } catch (exception, stackTrace) { | 6662 } catch (exception, stackTrace) { |
6510 throw new AnalysisException( | 6663 throw new AnalysisException( |
6511 exception.toString(), new CaughtException(exception, stackTrace)); | 6664 exception.toString(), new CaughtException(exception, stackTrace)); |
6512 } | 6665 } |
6513 } | 6666 } |
6514 } | 6667 } |
6515 | 6668 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6653 * it's cached AST structure flushed. | 6806 * it's cached AST structure flushed. |
6654 */ | 6807 */ |
6655 List<Source> _recentlyUsed; | 6808 List<Source> _recentlyUsed; |
6656 | 6809 |
6657 /** | 6810 /** |
6658 * Initialize a newly created cache to maintain at most [maxCacheSize] AST | 6811 * Initialize a newly created cache to maintain at most [maxCacheSize] AST |
6659 * structures in the cache. The cache is owned by the give [context], and the | 6812 * structures in the cache. The cache is owned by the give [context], and the |
6660 * [retentionPolicy] will be used to determine which pieces of data to remove | 6813 * [retentionPolicy] will be used to determine which pieces of data to remove |
6661 * from the cache. | 6814 * from the cache. |
6662 */ | 6815 */ |
6663 CachePartition(this.context, int maxCacheSize, this._retentionPolicy) { | 6816 CachePartition(this.context, this._maxCacheSize, this._retentionPolicy) { |
6664 this._maxCacheSize = maxCacheSize; | |
6665 _recentlyUsed = new List<Source>(); | 6817 _recentlyUsed = new List<Source>(); |
6666 } | 6818 } |
6667 | 6819 |
6668 /** | 6820 /** |
6669 * Return the number of entries in this partition that have an AST associated | 6821 * Return the number of entries in this partition that have an AST associated |
6670 * with them. | 6822 * with them. |
6671 */ | 6823 */ |
6672 int get astSize { | 6824 int get astSize { |
6673 int astSize = 0; | 6825 int astSize = 0; |
6674 int count = _recentlyUsed.length; | 6826 int count = _recentlyUsed.length; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6745 | 6897 |
6746 /** | 6898 /** |
6747 * Associate the given [entry] with the given [source]. | 6899 * Associate the given [entry] with the given [source]. |
6748 */ | 6900 */ |
6749 void put(Source source, SourceEntry entry) { | 6901 void put(Source source, SourceEntry entry) { |
6750 entry.fixExceptionState(); | 6902 entry.fixExceptionState(); |
6751 _sourceMap[source] = entry; | 6903 _sourceMap[source] = entry; |
6752 } | 6904 } |
6753 | 6905 |
6754 /** | 6906 /** |
6755 * Remove all information related to the given [source] from this cache. | 6907 * Remove all information related to the given [source] from this partition. |
| 6908 * Return the entry associated with the source, or `null` if there was cache |
| 6909 * entry for the source. |
6756 */ | 6910 */ |
6757 void remove(Source source) { | 6911 SourceEntry remove(Source source) { |
6758 _recentlyUsed.remove(source); | 6912 _recentlyUsed.remove(source); |
6759 _sourceMap.remove(source); | 6913 return _sourceMap.remove(source); |
6760 } | 6914 } |
6761 | 6915 |
6762 /** | 6916 /** |
6763 * Record that the AST associated with the given [source] was just removed | 6917 * Record that the AST associated with the given [source] was just removed |
6764 * from the cache. | 6918 * from the cache. |
6765 */ | 6919 */ |
6766 void removedAst(Source source) { | 6920 void removedAst(Source source) { |
6767 _recentlyUsed.remove(source); | 6921 _recentlyUsed.remove(source); |
6768 } | 6922 } |
6769 | 6923 |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7309 | 7463 |
7310 /** | 7464 /** |
7311 * The (source, entry) pairs representing the compilation units in the | 7465 * The (source, entry) pairs representing the compilation units in the |
7312 * library. | 7466 * library. |
7313 */ | 7467 */ |
7314 List<CycleBuilder_SourceEntryPair> entryPairs; | 7468 List<CycleBuilder_SourceEntryPair> entryPairs; |
7315 | 7469 |
7316 /** | 7470 /** |
7317 * Initialize a newly created pair from the given [library] and [entryPairs]. | 7471 * Initialize a newly created pair from the given [library] and [entryPairs]. |
7318 */ | 7472 */ |
7319 CycleBuilder_LibraryPair(ResolvableLibrary library, | 7473 CycleBuilder_LibraryPair(this.library, this.entryPairs); |
7320 List<CycleBuilder_SourceEntryPair> entryPairs) { | |
7321 this.library = library; | |
7322 this.entryPairs = entryPairs; | |
7323 } | |
7324 } | 7474 } |
7325 | 7475 |
7326 /** | 7476 /** |
7327 * A pair containing a source and the cache entry associated with that source. | 7477 * A pair containing a source and the cache entry associated with that source. |
7328 * They are used to reduce the number of times an entry must be looked up in the | 7478 * They are used to reduce the number of times an entry must be looked up in the |
7329 * cache. | 7479 * cache. |
7330 */ | 7480 */ |
7331 class CycleBuilder_SourceEntryPair { | 7481 class CycleBuilder_SourceEntryPair { |
7332 /** | 7482 /** |
7333 * The source associated with the entry. | 7483 * The source associated with the entry. |
7334 */ | 7484 */ |
7335 Source source; | 7485 Source source; |
7336 | 7486 |
7337 /** | 7487 /** |
7338 * The entry associated with the source. | 7488 * The entry associated with the source. |
7339 */ | 7489 */ |
7340 DartEntry entry; | 7490 DartEntry entry; |
7341 | 7491 |
7342 /** | 7492 /** |
7343 * Initialize a newly created pair from the given [source] and [entry]. | 7493 * Initialize a newly created pair from the given [source] and [entry]. |
7344 */ | 7494 */ |
7345 CycleBuilder_SourceEntryPair(Source source, DartEntry entry) { | 7495 CycleBuilder_SourceEntryPair(this.source, this.entry); |
7346 this.source = source; | |
7347 this.entry = entry; | |
7348 } | |
7349 } | 7496 } |
7350 | 7497 |
7351 /** | 7498 /** |
7352 * The information cached by an analysis context about an individual Dart file. | 7499 * The information cached by an analysis context about an individual Dart file. |
7353 */ | 7500 */ |
7354 class DartEntry extends SourceEntry { | 7501 class DartEntry extends SourceEntry { |
7355 /** | 7502 /** |
7356 * The data descriptor representing the element model representing a single | 7503 * The data descriptor representing the element model representing a single |
7357 * compilation unit. This model is incomplete and should not be used except as | 7504 * compilation unit. This model is incomplete and should not be used except as |
7358 * input to another task. | 7505 * input to another task. |
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8335 // | 8482 // |
8336 // TODO(paulberry): as a temporary workaround for issue 21572, | 8483 // TODO(paulberry): as a temporary workaround for issue 21572, |
8337 // ConstantVerifier is being run right after ConstantValueComputer, so we | 8484 // ConstantVerifier is being run right after ConstantValueComputer, so we |
8338 // don't need to run it here. Once issue 21572 is fixed, re-enable the | 8485 // don't need to run it here. Once issue 21572 is fixed, re-enable the |
8339 // call to ConstantVerifier. | 8486 // call to ConstantVerifier. |
8340 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter,
libraryElement, typeProvider); | 8487 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter,
libraryElement, typeProvider); |
8341 // _unit.accept(constantVerifier); | 8488 // _unit.accept(constantVerifier); |
8342 // | 8489 // |
8343 // Use the ErrorVerifier to compute the rest of the errors. | 8490 // Use the ErrorVerifier to compute the rest of the errors. |
8344 // | 8491 // |
8345 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, | 8492 ErrorVerifier errorVerifier = new ErrorVerifier( |
8346 libraryElement, typeProvider, new InheritanceManager(libraryElement)); | 8493 errorReporter, |
| 8494 libraryElement, |
| 8495 typeProvider, |
| 8496 new InheritanceManager(libraryElement), |
| 8497 context.analysisOptions.enableSuperMixins); |
8347 _unit.accept(errorVerifier); | 8498 _unit.accept(errorVerifier); |
8348 _errors = errorListener.getErrorsForSource(source); | 8499 _errors = errorListener.getErrorsForSource(source); |
8349 }); | 8500 }); |
8350 } | 8501 } |
8351 | 8502 |
8352 /** | 8503 /** |
8353 * Check each directive in the given compilation unit to see if the referenced
source exists and | 8504 * Check each directive in the given compilation unit to see if the referenced
source exists and |
8354 * report an error if it does not. | 8505 * report an error if it does not. |
8355 * | 8506 * |
8356 * @param context the context in which the library exists | 8507 * @param context the context in which the library exists |
(...skipping 13 matching lines...) Expand all Loading... |
8370 | 8521 |
8371 /** | 8522 /** |
8372 * Check the given directive to see if the referenced source exists and report
an error if it does | 8523 * Check the given directive to see if the referenced source exists and report
an error if it does |
8373 * not. | 8524 * not. |
8374 * | 8525 * |
8375 * @param context the context in which the library exists | 8526 * @param context the context in which the library exists |
8376 * @param librarySource the source representing the library containing the dir
ective | 8527 * @param librarySource the source representing the library containing the dir
ective |
8377 * @param directive the directive to be verified | 8528 * @param directive the directive to be verified |
8378 * @param errorListener the error listener to which errors should be reported | 8529 * @param errorListener the error listener to which errors should be reported |
8379 */ | 8530 */ |
8380 static void validateReferencedSource(AnalysisContext context, | 8531 static void validateReferencedSource( |
8381 Source librarySource, UriBasedDirective directive, | 8532 AnalysisContext context, |
| 8533 Source librarySource, |
| 8534 UriBasedDirective directive, |
8382 AnalysisErrorListener errorListener) { | 8535 AnalysisErrorListener errorListener) { |
8383 Source source = directive.source; | 8536 Source source = directive.source; |
8384 if (source != null) { | 8537 if (source != null) { |
8385 if (context.exists(source)) { | 8538 if (context.exists(source)) { |
8386 return; | 8539 return; |
8387 } | 8540 } |
8388 } else { | 8541 } else { |
8389 // Don't report errors already reported by ParseDartTask.resolveDirective | 8542 // Don't report errors already reported by ParseDartTask.resolveDirective |
8390 if (directive.validate() != null) { | 8543 if (directive.validate() != null) { |
8391 return; | 8544 return; |
8392 } | 8545 } |
8393 } | 8546 } |
8394 StringLiteral uriLiteral = directive.uri; | 8547 StringLiteral uriLiteral = directive.uri; |
8395 errorListener.onError(new AnalysisError(librarySource, uriLiteral.offset, | 8548 errorListener.onError(new AnalysisError( |
8396 uriLiteral.length, CompileTimeErrorCode.URI_DOES_NOT_EXIST, | 8549 librarySource, |
| 8550 uriLiteral.offset, |
| 8551 uriLiteral.length, |
| 8552 CompileTimeErrorCode.URI_DOES_NOT_EXIST, |
8397 [directive.uriContent])); | 8553 [directive.uriContent])); |
8398 } | 8554 } |
8399 } | 8555 } |
8400 | 8556 |
8401 /** | 8557 /** |
8402 * Instances of the class `GenerateDartHintsTask` generate hints for a single Da
rt library. | 8558 * Instances of the class `GenerateDartHintsTask` generate hints for a single Da
rt library. |
8403 */ | 8559 */ |
8404 class GenerateDartHintsTask extends AnalysisTask { | 8560 class GenerateDartHintsTask extends AnalysisTask { |
8405 /** | 8561 /** |
8406 * The compilation units that comprise the library, with the defining compilat
ion unit appearing | 8562 * The compilation units that comprise the library, with the defining compilat
ion unit appearing |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8478 _hintMap = new HashMap<Source, List<AnalysisError>>(); | 8634 _hintMap = new HashMap<Source, List<AnalysisError>>(); |
8479 for (int i = 0; i < unitCount; i++) { | 8635 for (int i = 0; i < unitCount; i++) { |
8480 Source source = _units[i].data.element.source; | 8636 Source source = _units[i].data.element.source; |
8481 _hintMap[source] = errorListener.getErrorsForSource(source); | 8637 _hintMap[source] = errorListener.getErrorsForSource(source); |
8482 } | 8638 } |
8483 } | 8639 } |
8484 } | 8640 } |
8485 | 8641 |
8486 /// Generates lint feedback for a single Dart library. | 8642 /// Generates lint feedback for a single Dart library. |
8487 class GenerateDartLintsTask extends AnalysisTask { | 8643 class GenerateDartLintsTask extends AnalysisTask { |
8488 | |
8489 ///The compilation units that comprise the library, with the defining | 8644 ///The compilation units that comprise the library, with the defining |
8490 ///compilation unit appearing first in the list. | 8645 ///compilation unit appearing first in the list. |
8491 final List<TimestampedData<CompilationUnit>> _units; | 8646 final List<TimestampedData<CompilationUnit>> _units; |
8492 | 8647 |
8493 /// The element model for the library being analyzed. | 8648 /// The element model for the library being analyzed. |
8494 final LibraryElement libraryElement; | 8649 final LibraryElement libraryElement; |
8495 | 8650 |
8496 /// A mapping of analyzed sources to their associated lint warnings. | 8651 /// A mapping of analyzed sources to their associated lint warnings. |
8497 /// May be [null] if the task has not been performed or if analysis did not | 8652 /// May be [null] if the task has not been performed or if analysis did not |
8498 /// complete normally. | 8653 /// complete normally. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8608 @override | 8763 @override |
8609 accept(AnalysisTaskVisitor visitor) => visitor.visitGetContentTask(this); | 8764 accept(AnalysisTaskVisitor visitor) => visitor.visitGetContentTask(this); |
8610 | 8765 |
8611 @override | 8766 @override |
8612 void internalPerform() { | 8767 void internalPerform() { |
8613 _complete = true; | 8768 _complete = true; |
8614 try { | 8769 try { |
8615 TimestampedData<String> data = context.getContents(source); | 8770 TimestampedData<String> data = context.getContents(source); |
8616 _content = data.data; | 8771 _content = data.data; |
8617 _modificationTime = data.modificationTime; | 8772 _modificationTime = data.modificationTime; |
8618 AnalysisEngine.instance.instrumentationService.logFileRead( | 8773 AnalysisEngine.instance.instrumentationService |
8619 source.fullName, _modificationTime, _content); | 8774 .logFileRead(source.fullName, _modificationTime, _content); |
8620 } catch (exception, stackTrace) { | 8775 } catch (exception, stackTrace) { |
8621 errors.add(new AnalysisError( | 8776 if (source.exists()) { |
8622 source, 0, 0, ScannerErrorCode.UNABLE_GET_CONTENT, [exception])); | 8777 errors.add(new AnalysisError( |
| 8778 source, 0, 0, ScannerErrorCode.UNABLE_GET_CONTENT, [exception])); |
| 8779 } |
8623 throw new AnalysisException("Could not get contents of $source", | 8780 throw new AnalysisException("Could not get contents of $source", |
8624 new CaughtException(exception, stackTrace)); | 8781 new CaughtException(exception, stackTrace)); |
8625 } | 8782 } |
8626 } | 8783 } |
8627 } | 8784 } |
8628 | 8785 |
8629 /** | 8786 /** |
8630 * The information cached by an analysis context about an individual HTML file. | 8787 * The information cached by an analysis context about an individual HTML file. |
8631 */ | 8788 */ |
8632 class HtmlEntry extends SourceEntry { | 8789 class HtmlEntry extends SourceEntry { |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8846 _writeStateOn(buffer, "parseErrors", PARSE_ERRORS); | 9003 _writeStateOn(buffer, "parseErrors", PARSE_ERRORS); |
8847 _writeStateOn(buffer, "parsedUnit", PARSED_UNIT); | 9004 _writeStateOn(buffer, "parsedUnit", PARSED_UNIT); |
8848 _writeStateOn(buffer, "resolvedUnit", RESOLVED_UNIT); | 9005 _writeStateOn(buffer, "resolvedUnit", RESOLVED_UNIT); |
8849 _writeStateOn(buffer, "resolutionErrors", RESOLUTION_ERRORS); | 9006 _writeStateOn(buffer, "resolutionErrors", RESOLUTION_ERRORS); |
8850 _writeStateOn(buffer, "referencedLibraries", REFERENCED_LIBRARIES); | 9007 _writeStateOn(buffer, "referencedLibraries", REFERENCED_LIBRARIES); |
8851 _writeStateOn(buffer, "element", ELEMENT); | 9008 _writeStateOn(buffer, "element", ELEMENT); |
8852 } | 9009 } |
8853 } | 9010 } |
8854 | 9011 |
8855 /** | 9012 /** |
| 9013 * An event indicating when a source either starts or stops being implicitly |
| 9014 * analyzed. |
| 9015 */ |
| 9016 class ImplicitAnalysisEvent { |
| 9017 /** |
| 9018 * The source whose status has changed. |
| 9019 */ |
| 9020 final Source source; |
| 9021 |
| 9022 /** |
| 9023 * A flag indicating whether the source is now being analyzed. |
| 9024 */ |
| 9025 final bool isAnalyzed; |
| 9026 |
| 9027 /** |
| 9028 * Initialize a newly created event to indicate that the given [source] has |
| 9029 * changed it status to match the [isAnalyzed] flag. |
| 9030 */ |
| 9031 ImplicitAnalysisEvent(this.source, this.isAnalyzed); |
| 9032 |
| 9033 @override |
| 9034 String toString() => |
| 9035 '${isAnalyzed ? '' : 'not '}analyzing ${source.fullName}'; |
| 9036 } |
| 9037 |
| 9038 /** |
8856 * Instances of the class `IncrementalAnalysisCache` hold information used to pe
rform | 9039 * Instances of the class `IncrementalAnalysisCache` hold information used to pe
rform |
8857 * incremental analysis. | 9040 * incremental analysis. |
8858 * | 9041 * |
8859 * See [AnalysisContextImpl.setChangedContents]. | 9042 * See [AnalysisContextImpl.setChangedContents]. |
8860 */ | 9043 */ |
8861 class IncrementalAnalysisCache { | 9044 class IncrementalAnalysisCache { |
8862 final Source librarySource; | 9045 final Source librarySource; |
8863 | 9046 |
8864 final Source source; | 9047 final Source source; |
8865 | 9048 |
8866 final String oldContents; | 9049 final String oldContents; |
8867 | 9050 |
8868 final CompilationUnit resolvedUnit; | 9051 final CompilationUnit resolvedUnit; |
8869 | 9052 |
8870 String _newContents; | 9053 String _newContents; |
8871 | 9054 |
8872 int _offset = 0; | 9055 int _offset = 0; |
8873 | 9056 |
8874 int _oldLength = 0; | 9057 int _oldLength = 0; |
8875 | 9058 |
8876 int _newLength = 0; | 9059 int _newLength = 0; |
8877 | 9060 |
8878 IncrementalAnalysisCache(this.librarySource, this.source, this.resolvedUnit, | 9061 IncrementalAnalysisCache( |
8879 this.oldContents, String newContents, int offset, int oldLength, | 9062 this.librarySource, |
8880 int newLength) { | 9063 this.source, |
8881 this._newContents = newContents; | 9064 this.resolvedUnit, |
8882 this._offset = offset; | 9065 this.oldContents, |
8883 this._oldLength = oldLength; | 9066 this._newContents, |
8884 this._newLength = newLength; | 9067 this._offset, |
8885 } | 9068 this._oldLength, |
| 9069 this._newLength); |
8886 | 9070 |
8887 /** | 9071 /** |
8888 * Determine if the cache contains source changes that need to be analyzed | 9072 * Determine if the cache contains source changes that need to be analyzed |
8889 * | 9073 * |
8890 * @return `true` if the cache contains changes to be analyzed, else `false` | 9074 * @return `true` if the cache contains changes to be analyzed, else `false` |
8891 */ | 9075 */ |
8892 bool get hasWork => _oldLength > 0 || _newLength > 0; | 9076 bool get hasWork => _oldLength > 0 || _newLength > 0; |
8893 | 9077 |
8894 /** | 9078 /** |
8895 * Return the current contents for the receiver's source. | 9079 * Return the current contents for the receiver's source. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8959 * @param source the source being updated (not `null`) | 9143 * @param source the source being updated (not `null`) |
8960 * @param oldContents the original source contents prior to this update (may b
e `null`) | 9144 * @param oldContents the original source contents prior to this update (may b
e `null`) |
8961 * @param newContents the new contents after this incremental change (not `nul
l`) | 9145 * @param newContents the new contents after this incremental change (not `nul
l`) |
8962 * @param offset the offset at which the change occurred | 9146 * @param offset the offset at which the change occurred |
8963 * @param oldLength the length of the text being replaced | 9147 * @param oldLength the length of the text being replaced |
8964 * @param newLength the length of the replacement text | 9148 * @param newLength the length of the replacement text |
8965 * @param sourceEntry the cached entry for the given source or `null` if none | 9149 * @param sourceEntry the cached entry for the given source or `null` if none |
8966 * @return the cache used for incremental analysis or `null` if incremental an
alysis cannot | 9150 * @return the cache used for incremental analysis or `null` if incremental an
alysis cannot |
8967 * be performed | 9151 * be performed |
8968 */ | 9152 */ |
8969 static IncrementalAnalysisCache update(IncrementalAnalysisCache cache, | 9153 static IncrementalAnalysisCache update( |
8970 Source source, String oldContents, String newContents, int offset, | 9154 IncrementalAnalysisCache cache, |
8971 int oldLength, int newLength, SourceEntry sourceEntry) { | 9155 Source source, |
| 9156 String oldContents, |
| 9157 String newContents, |
| 9158 int offset, |
| 9159 int oldLength, |
| 9160 int newLength, |
| 9161 SourceEntry sourceEntry) { |
8972 // Determine the cache resolved unit | 9162 // Determine the cache resolved unit |
8973 Source librarySource = null; | 9163 Source librarySource = null; |
8974 CompilationUnit unit = null; | 9164 CompilationUnit unit = null; |
8975 if (sourceEntry is DartEntry) { | 9165 if (sourceEntry is DartEntry) { |
8976 DartEntry dartEntry = sourceEntry; | 9166 DartEntry dartEntry = sourceEntry; |
8977 List<Source> librarySources = dartEntry.librariesContaining; | 9167 List<Source> librarySources = dartEntry.librariesContaining; |
8978 if (librarySources.length == 1) { | 9168 if (librarySources.length == 1) { |
8979 librarySource = librarySources[0]; | 9169 librarySource = librarySources[0]; |
8980 if (librarySource != null) { | 9170 if (librarySource != null) { |
8981 unit = dartEntry.getValueInLibrary( | 9171 unit = dartEntry.getValueInLibrary( |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9387 class ObsoleteSourceAnalysisException extends AnalysisException { | 9577 class ObsoleteSourceAnalysisException extends AnalysisException { |
9388 /** | 9578 /** |
9389 * The source that was removed while it was being analyzed. | 9579 * The source that was removed while it was being analyzed. |
9390 */ | 9580 */ |
9391 Source _source; | 9581 Source _source; |
9392 | 9582 |
9393 /** | 9583 /** |
9394 * Initialize a newly created exception to represent the removal of the given | 9584 * Initialize a newly created exception to represent the removal of the given |
9395 * [source]. | 9585 * [source]. |
9396 */ | 9586 */ |
9397 ObsoleteSourceAnalysisException(Source source) : super( | 9587 ObsoleteSourceAnalysisException(Source source) |
9398 "The source '${source.fullName}' was removed while it was being analyz
ed") { | 9588 : super( |
| 9589 "The source '${source.fullName}' was removed while it was being anal
yzed") { |
9399 this._source = source; | 9590 this._source = source; |
9400 } | 9591 } |
9401 | 9592 |
9402 /** | 9593 /** |
9403 * Return the source that was removed while it was being analyzed. | 9594 * Return the source that was removed while it was being analyzed. |
9404 */ | 9595 */ |
9405 Source get source => _source; | 9596 Source get source => _source; |
9406 } | 9597 } |
9407 | 9598 |
9408 /** | 9599 /** |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10112 } | 10303 } |
10113 return null; | 10304 return null; |
10114 } | 10305 } |
10115 } | 10306 } |
10116 | 10307 |
10117 /** | 10308 /** |
10118 * An visitor that removes any resolution information from an AST structure when | 10309 * An visitor that removes any resolution information from an AST structure when |
10119 * used to visit that structure. | 10310 * used to visit that structure. |
10120 */ | 10311 */ |
10121 class ResolutionEraser extends GeneralizingAstVisitor<Object> { | 10312 class ResolutionEraser extends GeneralizingAstVisitor<Object> { |
| 10313 /** |
| 10314 * A flag indicating whether the elements associated with declarations should |
| 10315 * be erased. |
| 10316 */ |
| 10317 bool eraseDeclarations = true; |
| 10318 |
10122 @override | 10319 @override |
10123 Object visitAssignmentExpression(AssignmentExpression node) { | 10320 Object visitAssignmentExpression(AssignmentExpression node) { |
10124 node.staticElement = null; | 10321 node.staticElement = null; |
10125 node.propagatedElement = null; | 10322 node.propagatedElement = null; |
10126 return super.visitAssignmentExpression(node); | 10323 return super.visitAssignmentExpression(node); |
10127 } | 10324 } |
10128 | 10325 |
10129 @override | 10326 @override |
10130 Object visitBinaryExpression(BinaryExpression node) { | 10327 Object visitBinaryExpression(BinaryExpression node) { |
10131 node.staticElement = null; | 10328 node.staticElement = null; |
10132 node.propagatedElement = null; | 10329 node.propagatedElement = null; |
10133 return super.visitBinaryExpression(node); | 10330 return super.visitBinaryExpression(node); |
10134 } | 10331 } |
10135 | 10332 |
10136 @override | 10333 @override |
10137 Object visitBreakStatement(BreakStatement node) { | 10334 Object visitBreakStatement(BreakStatement node) { |
10138 node.target = null; | 10335 node.target = null; |
10139 return super.visitBreakStatement(node); | 10336 return super.visitBreakStatement(node); |
10140 } | 10337 } |
10141 | 10338 |
10142 @override | 10339 @override |
10143 Object visitCompilationUnit(CompilationUnit node) { | 10340 Object visitCompilationUnit(CompilationUnit node) { |
10144 node.element = null; | 10341 if (eraseDeclarations) { |
| 10342 node.element = null; |
| 10343 } |
10145 return super.visitCompilationUnit(node); | 10344 return super.visitCompilationUnit(node); |
10146 } | 10345 } |
10147 | 10346 |
10148 @override | 10347 @override |
10149 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 10348 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
10150 node.element = null; | 10349 if (eraseDeclarations) { |
| 10350 node.element = null; |
| 10351 } |
10151 return super.visitConstructorDeclaration(node); | 10352 return super.visitConstructorDeclaration(node); |
10152 } | 10353 } |
10153 | 10354 |
10154 @override | 10355 @override |
10155 Object visitConstructorName(ConstructorName node) { | 10356 Object visitConstructorName(ConstructorName node) { |
10156 node.staticElement = null; | 10357 node.staticElement = null; |
10157 return super.visitConstructorName(node); | 10358 return super.visitConstructorName(node); |
10158 } | 10359 } |
10159 | 10360 |
10160 @override | 10361 @override |
10161 Object visitContinueStatement(ContinueStatement node) { | 10362 Object visitContinueStatement(ContinueStatement node) { |
10162 node.target = null; | 10363 node.target = null; |
10163 return super.visitContinueStatement(node); | 10364 return super.visitContinueStatement(node); |
10164 } | 10365 } |
10165 | 10366 |
10166 @override | 10367 @override |
10167 Object visitDirective(Directive node) { | 10368 Object visitDirective(Directive node) { |
10168 node.element = null; | 10369 if (eraseDeclarations) { |
| 10370 node.element = null; |
| 10371 } |
10169 return super.visitDirective(node); | 10372 return super.visitDirective(node); |
10170 } | 10373 } |
10171 | 10374 |
10172 @override | 10375 @override |
10173 Object visitExpression(Expression node) { | 10376 Object visitExpression(Expression node) { |
10174 node.staticType = null; | 10377 node.staticType = null; |
10175 node.propagatedType = null; | 10378 node.propagatedType = null; |
10176 return super.visitExpression(node); | 10379 return super.visitExpression(node); |
10177 } | 10380 } |
10178 | 10381 |
10179 @override | 10382 @override |
10180 Object visitFunctionExpression(FunctionExpression node) { | 10383 Object visitFunctionExpression(FunctionExpression node) { |
10181 node.element = null; | 10384 if (eraseDeclarations) { |
| 10385 node.element = null; |
| 10386 } |
10182 return super.visitFunctionExpression(node); | 10387 return super.visitFunctionExpression(node); |
10183 } | 10388 } |
10184 | 10389 |
10185 @override | 10390 @override |
10186 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { | 10391 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
10187 node.staticElement = null; | 10392 node.staticElement = null; |
10188 node.propagatedElement = null; | 10393 node.propagatedElement = null; |
10189 return super.visitFunctionExpressionInvocation(node); | 10394 return super.visitFunctionExpressionInvocation(node); |
10190 } | 10395 } |
10191 | 10396 |
(...skipping 26 matching lines...) Expand all Loading... |
10218 | 10423 |
10219 @override | 10424 @override |
10220 Object visitRedirectingConstructorInvocation( | 10425 Object visitRedirectingConstructorInvocation( |
10221 RedirectingConstructorInvocation node) { | 10426 RedirectingConstructorInvocation node) { |
10222 node.staticElement = null; | 10427 node.staticElement = null; |
10223 return super.visitRedirectingConstructorInvocation(node); | 10428 return super.visitRedirectingConstructorInvocation(node); |
10224 } | 10429 } |
10225 | 10430 |
10226 @override | 10431 @override |
10227 Object visitSimpleIdentifier(SimpleIdentifier node) { | 10432 Object visitSimpleIdentifier(SimpleIdentifier node) { |
10228 node.staticElement = null; | 10433 if (eraseDeclarations || !node.inDeclarationContext()) { |
| 10434 node.staticElement = null; |
| 10435 } |
10229 node.propagatedElement = null; | 10436 node.propagatedElement = null; |
10230 return super.visitSimpleIdentifier(node); | 10437 return super.visitSimpleIdentifier(node); |
10231 } | 10438 } |
10232 | 10439 |
10233 @override | 10440 @override |
10234 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 10441 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
10235 node.staticElement = null; | 10442 node.staticElement = null; |
10236 return super.visitSuperConstructorInvocation(node); | 10443 return super.visitSuperConstructorInvocation(node); |
10237 } | 10444 } |
10238 | 10445 |
10239 /** | 10446 /** |
10240 * Remove any resolution information from the given AST structure. | 10447 * Remove any resolution information from the given AST structure. |
10241 */ | 10448 */ |
10242 static void erase(AstNode node) { | 10449 static void erase(AstNode node, {bool eraseDeclarations: true}) { |
10243 node.accept(new ResolutionEraser()); | 10450 ResolutionEraser eraser = new ResolutionEraser(); |
| 10451 eraser.eraseDeclarations = eraseDeclarations; |
| 10452 node.accept(eraser); |
10244 } | 10453 } |
10245 } | 10454 } |
10246 | 10455 |
10247 /** | 10456 /** |
10248 * The information produced by resolving a compilation unit as part of a | 10457 * The information produced by resolving a compilation unit as part of a |
10249 * specific library. | 10458 * specific library. |
10250 */ | 10459 */ |
10251 class ResolutionState { | 10460 class ResolutionState { |
10252 /** | 10461 /** |
10253 * The next resolution state or `null` if none. | 10462 * The next resolution state or `null` if none. |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10746 ResolverVisitor resolverVisitor = new ResolverVisitor( | 10955 ResolverVisitor resolverVisitor = new ResolverVisitor( |
10747 _libraryElement, source, typeProvider, errorListener, | 10956 _libraryElement, source, typeProvider, errorListener, |
10748 inheritanceManager: inheritanceManager); | 10957 inheritanceManager: inheritanceManager); |
10749 unit.accept(resolverVisitor); | 10958 unit.accept(resolverVisitor); |
10750 // | 10959 // |
10751 // Perform additional error checking. | 10960 // Perform additional error checking. |
10752 // | 10961 // |
10753 PerformanceStatistics.errors.makeCurrentWhile(() { | 10962 PerformanceStatistics.errors.makeCurrentWhile(() { |
10754 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); | 10963 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); |
10755 ErrorVerifier errorVerifier = new ErrorVerifier( | 10964 ErrorVerifier errorVerifier = new ErrorVerifier( |
10756 errorReporter, _libraryElement, typeProvider, inheritanceManager); | 10965 errorReporter, |
| 10966 _libraryElement, |
| 10967 typeProvider, |
| 10968 inheritanceManager, |
| 10969 context.analysisOptions.enableSuperMixins); |
10757 unit.accept(errorVerifier); | 10970 unit.accept(errorVerifier); |
10758 // TODO(paulberry): as a temporary workaround for issue 21572, | 10971 // TODO(paulberry): as a temporary workaround for issue 21572, |
10759 // ConstantVerifier is being run right after ConstantValueComputer, so we | 10972 // ConstantVerifier is being run right after ConstantValueComputer, so we |
10760 // don't need to run it here. Once issue 21572 is fixed, re-enable the | 10973 // don't need to run it here. Once issue 21572 is fixed, re-enable the |
10761 // call to ConstantVerifier. | 10974 // call to ConstantVerifier. |
10762 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter,
_libraryElement, typeProvider); | 10975 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter,
_libraryElement, typeProvider); |
10763 // unit.accept(constantVerifier); | 10976 // unit.accept(constantVerifier); |
10764 }); | 10977 }); |
10765 // | 10978 // |
10766 // Capture the results. | 10979 // Capture the results. |
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11840 PendingFuture pendingFuture = | 12053 PendingFuture pendingFuture = |
11841 new PendingFuture<T>(_context, source, computeValue); | 12054 new PendingFuture<T>(_context, source, computeValue); |
11842 if (!pendingFuture.evaluate(sourceEntry)) { | 12055 if (!pendingFuture.evaluate(sourceEntry)) { |
11843 _context._pendingFutureSources | 12056 _context._pendingFutureSources |
11844 .putIfAbsent(source, () => <PendingFuture>[]) | 12057 .putIfAbsent(source, () => <PendingFuture>[]) |
11845 .add(pendingFuture); | 12058 .add(pendingFuture); |
11846 } | 12059 } |
11847 return pendingFuture.future; | 12060 return pendingFuture.future; |
11848 } | 12061 } |
11849 } | 12062 } |
OLD | NEW |