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 | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
7 | 7 |
8 library engine; | 8 library engine; |
9 | 9 |
10 import 'dart:async'; | 10 import 'dart:async'; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 JavaSystem.currentTimeMillis(); | 201 JavaSystem.currentTimeMillis(); |
202 } | 202 } |
203 } | 203 } |
204 _partitions[i].put(source, entry); | 204 _partitions[i].put(source, entry); |
205 return; | 205 return; |
206 } | 206 } |
207 } | 207 } |
208 } | 208 } |
209 | 209 |
210 /** | 210 /** |
211 * Remove all information related to the given [source] from this cache. | 211 * Remove all information related to the given [source] from this cache and |
212 * return the entry associated with the source. | |
Paul Berry
2015/07/15 19:50:01
Document when we would return `null` here too.
Brian Wilkerson
2015/07/15 21:23:37
Done
| |
212 */ | 213 */ |
213 void remove(Source source) { | 214 SourceEntry remove(Source source) { |
214 int count = _partitions.length; | 215 int count = _partitions.length; |
215 for (int i = 0; i < count; i++) { | 216 for (int i = 0; i < count; i++) { |
216 if (_partitions[i].contains(source)) { | 217 if (_partitions[i].contains(source)) { |
217 if (_TRACE_CHANGES) { | 218 if (_TRACE_CHANGES) { |
218 try { | 219 try { |
219 AnalysisEngine.instance.logger.logInformation( | 220 AnalysisEngine.instance.logger.logInformation( |
220 "Removed the cache entry for ${source.fullName}'."); | 221 "Removed the cache entry for ${source.fullName}'."); |
221 } catch (exception) { | 222 } catch (exception) { |
222 // Ignored | 223 // Ignored |
223 JavaSystem.currentTimeMillis(); | 224 JavaSystem.currentTimeMillis(); |
224 } | 225 } |
225 } | 226 } |
226 _partitions[i].remove(source); | 227 return _partitions[i].remove(source); |
227 return; | |
228 } | 228 } |
229 } | 229 } |
230 return null; | |
230 } | 231 } |
231 | 232 |
232 /** | 233 /** |
233 * Record that the AST associated with the given [source] was just removed | 234 * Record that the AST associated with the given [source] was just removed |
234 * from the cache. | 235 * from the cache. |
235 */ | 236 */ |
236 void removedAst(Source source) { | 237 void removedAst(Source source) { |
237 int count = _partitions.length; | 238 int count = _partitions.length; |
238 for (int i = 0; i < count; i++) { | 239 for (int i = 0; i < count; i++) { |
239 if (_partitions[i].contains(source)) { | 240 if (_partitions[i].contains(source)) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 * that needs to be analyzed is not contained in the list, then it will be | 336 * that needs to be analyzed is not contained in the list, then it will be |
336 * treated as if it were at the end of the list. If the list is empty (or | 337 * treated as if it were at the end of the list. If the list is empty (or |
337 * `null`) then no sources will be given priority over other sources. | 338 * `null`) then no sources will be given priority over other sources. |
338 * | 339 * |
339 * Changes made to the list after this method returns will <b>not</b> be | 340 * Changes made to the list after this method returns will <b>not</b> be |
340 * reflected in the priority order. | 341 * reflected in the priority order. |
341 */ | 342 */ |
342 void set analysisPriorityOrder(List<Source> sources); | 343 void set analysisPriorityOrder(List<Source> sources); |
343 | 344 |
344 /** | 345 /** |
346 * The stream that is notified when a source either starts or stops being | |
347 * analyzed implicitly. | |
348 */ | |
349 Stream<AnalyzedSourcesEvent> get analyzedSources; | |
Paul Berry
2015/07/15 19:50:01
Similarly, consider renaming this to "implicitlyAn
Brian Wilkerson
2015/07/15 21:23:37
I struggled a bit with the name. I suppose what yo
| |
350 | |
351 /** | |
345 * Return the set of declared variables used when computing constant values. | 352 * Return the set of declared variables used when computing constant values. |
346 */ | 353 */ |
347 DeclaredVariables get declaredVariables; | 354 DeclaredVariables get declaredVariables; |
348 | 355 |
349 /** | 356 /** |
350 * Return a list containing all of the sources known to this context that | 357 * 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. | 358 * represent HTML files. The contents of the list can be incomplete. |
352 */ | 359 */ |
353 List<Source> get htmlSources; | 360 List<Source> get htmlSources; |
354 | 361 |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1027 * The [Stopwatch] of the current "perform tasks cycle". | 1034 * The [Stopwatch] of the current "perform tasks cycle". |
1028 */ | 1035 */ |
1029 Stopwatch _performAnalysisTaskStopwatch; | 1036 Stopwatch _performAnalysisTaskStopwatch; |
1030 | 1037 |
1031 /** | 1038 /** |
1032 * The controller for sending [SourcesChangedEvent]s. | 1039 * The controller for sending [SourcesChangedEvent]s. |
1033 */ | 1040 */ |
1034 StreamController<SourcesChangedEvent> _onSourcesChangedController; | 1041 StreamController<SourcesChangedEvent> _onSourcesChangedController; |
1035 | 1042 |
1036 /** | 1043 /** |
1044 * A subscription for a stream of events indicating when files are (and are | |
1045 * not) being implicitly analyzed. | |
1046 */ | |
1047 StreamController<AnalyzedSourcesEvent> _analyzedSourcesController; | |
1048 | |
1049 /** | |
1037 * The listeners that are to be notified when various analysis results are | 1050 * The listeners that are to be notified when various analysis results are |
1038 * produced in this context. | 1051 * produced in this context. |
1039 */ | 1052 */ |
1040 List<AnalysisListener> _listeners = new List<AnalysisListener>(); | 1053 List<AnalysisListener> _listeners = new List<AnalysisListener>(); |
1041 | 1054 |
1042 /** | 1055 /** |
1043 * The most recently incrementally resolved source, or `null` when it was | 1056 * The most recently incrementally resolved source, or `null` when it was |
1044 * already validated, or the most recent change was not incrementally resolved . | 1057 * already validated, or the most recent change was not incrementally resolved . |
1045 */ | 1058 */ |
1046 Source incrementalResolutionValidation_lastUnitSource; | 1059 Source incrementalResolutionValidation_lastUnitSource; |
(...skipping 30 matching lines...) Expand all Loading... | |
1077 * Initialize a newly created analysis context. | 1090 * Initialize a newly created analysis context. |
1078 */ | 1091 */ |
1079 AnalysisContextImpl() { | 1092 AnalysisContextImpl() { |
1080 _resultRecorder = new AnalysisContextImpl_AnalysisTaskResultRecorder(this); | 1093 _resultRecorder = new AnalysisContextImpl_AnalysisTaskResultRecorder(this); |
1081 _privatePartition = new UniversalCachePartition(this, | 1094 _privatePartition = new UniversalCachePartition(this, |
1082 AnalysisOptionsImpl.DEFAULT_CACHE_SIZE, | 1095 AnalysisOptionsImpl.DEFAULT_CACHE_SIZE, |
1083 new AnalysisContextImpl_ContextRetentionPolicy(this)); | 1096 new AnalysisContextImpl_ContextRetentionPolicy(this)); |
1084 _cache = createCacheFromSourceFactory(null); | 1097 _cache = createCacheFromSourceFactory(null); |
1085 _onSourcesChangedController = | 1098 _onSourcesChangedController = |
1086 new StreamController<SourcesChangedEvent>.broadcast(); | 1099 new StreamController<SourcesChangedEvent>.broadcast(); |
1100 _analyzedSourcesController = | |
1101 new StreamController<AnalyzedSourcesEvent>.broadcast(); | |
1087 } | 1102 } |
1088 | 1103 |
1089 @override | 1104 @override |
1090 AnalysisCache get analysisCache => _cache; | 1105 AnalysisCache get analysisCache => _cache; |
1091 | 1106 |
1092 @override | 1107 @override |
1093 AnalysisOptions get analysisOptions => _options; | 1108 AnalysisOptions get analysisOptions => _options; |
1094 | 1109 |
1095 @override | 1110 @override |
1096 void set analysisOptions(AnalysisOptions options) { | 1111 void set analysisOptions(AnalysisOptions options) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1168 for (var source in _priorityOrder) { | 1183 for (var source in _priorityOrder) { |
1169 SourceEntry entry = _getReadableSourceEntry(source); | 1184 SourceEntry entry = _getReadableSourceEntry(source); |
1170 if (entry == null) { | 1185 if (entry == null) { |
1171 _createSourceEntry(source, false); | 1186 _createSourceEntry(source, false); |
1172 } | 1187 } |
1173 } | 1188 } |
1174 } | 1189 } |
1175 } | 1190 } |
1176 | 1191 |
1177 @override | 1192 @override |
1193 Stream<AnalyzedSourcesEvent> get analyzedSources => | |
1194 _analyzedSourcesController.stream; | |
1195 | |
1196 @override | |
1178 set contentCache(ContentCache value) { | 1197 set contentCache(ContentCache value) { |
1179 _contentCache = value; | 1198 _contentCache = value; |
1180 } | 1199 } |
1181 | 1200 |
1182 @override | 1201 @override |
1183 DeclaredVariables get declaredVariables => _declaredVariables; | 1202 DeclaredVariables get declaredVariables => _declaredVariables; |
1184 | 1203 |
1185 @override | 1204 @override |
1186 List<AnalysisTarget> get explicitTargets { | 1205 List<AnalysisTarget> get explicitTargets { |
1187 List<AnalysisTarget> targets = <AnalysisTarget>[]; | 1206 List<AnalysisTarget> targets = <AnalysisTarget>[]; |
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2403 // during resolution. | 2422 // during resolution. |
2404 // | 2423 // |
2405 if (thrownException == null) { | 2424 if (thrownException == null) { |
2406 var message = "In recordResolveDartLibraryCycleTaskResults, " | 2425 var message = "In recordResolveDartLibraryCycleTaskResults, " |
2407 "resolvedLibraries was null and there was no thrown exception"; | 2426 "resolvedLibraries was null and there was no thrown exception"; |
2408 unitEntry.recordResolutionError( | 2427 unitEntry.recordResolutionError( |
2409 new CaughtException(new AnalysisException(message), null)); | 2428 new CaughtException(new AnalysisException(message), null)); |
2410 } else { | 2429 } else { |
2411 unitEntry.recordResolutionError(thrownException); | 2430 unitEntry.recordResolutionError(thrownException); |
2412 } | 2431 } |
2413 _cache.remove(unitSource); | 2432 _removeFromCache(unitSource); |
2414 if (thrownException != null) { | 2433 if (thrownException != null) { |
2415 throw new AnalysisException('<rethrow>', thrownException); | 2434 throw new AnalysisException('<rethrow>', thrownException); |
2416 } | 2435 } |
2417 return unitEntry; | 2436 return unitEntry; |
2418 } | 2437 } |
2419 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); | 2438 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); |
2420 RecordingErrorListener errorListener = resolver.errorListener; | 2439 RecordingErrorListener errorListener = resolver.errorListener; |
2421 for (ResolvableLibrary library in resolvedLibraries) { | 2440 for (ResolvableLibrary library in resolvedLibraries) { |
2422 Source librarySource = library.librarySource; | 2441 Source librarySource = library.librarySource; |
2423 for (Source source in library.compilationUnitSources) { | 2442 for (Source source in library.compilationUnitSources) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2476 // during resolution. | 2495 // during resolution. |
2477 // | 2496 // |
2478 if (thrownException == null) { | 2497 if (thrownException == null) { |
2479 String message = "In recordResolveDartLibraryTaskResults, " | 2498 String message = "In recordResolveDartLibraryTaskResults, " |
2480 "resolvedLibraries was null and there was no thrown exception"; | 2499 "resolvedLibraries was null and there was no thrown exception"; |
2481 unitEntry.recordResolutionError( | 2500 unitEntry.recordResolutionError( |
2482 new CaughtException(new AnalysisException(message), null)); | 2501 new CaughtException(new AnalysisException(message), null)); |
2483 } else { | 2502 } else { |
2484 unitEntry.recordResolutionError(thrownException); | 2503 unitEntry.recordResolutionError(thrownException); |
2485 } | 2504 } |
2486 _cache.remove(unitSource); | 2505 _removeFromCache(unitSource); |
2487 if (thrownException != null) { | 2506 if (thrownException != null) { |
2488 throw new AnalysisException('<rethrow>', thrownException); | 2507 throw new AnalysisException('<rethrow>', thrownException); |
2489 } | 2508 } |
2490 return unitEntry; | 2509 return unitEntry; |
2491 } | 2510 } |
2492 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); | 2511 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); |
2493 RecordingErrorListener errorListener = resolver.errorListener; | 2512 RecordingErrorListener errorListener = resolver.errorListener; |
2494 for (Library library in resolvedLibraries) { | 2513 for (Library library in resolvedLibraries) { |
2495 Source librarySource = library.librarySource; | 2514 Source librarySource = library.librarySource; |
2496 for (Source source in library.compilationUnitSources) { | 2515 for (Source source in library.compilationUnitSources) { |
2497 CompilationUnit unit = library.getAST(source); | 2516 CompilationUnit unit = library.getAST(source); |
2498 List<AnalysisError> errors = errorListener.getErrorsForSource(source); | 2517 List<AnalysisError> errors = errorListener.getErrorsForSource(source); |
2499 LineInfo lineInfo = getLineInfo(source); | 2518 LineInfo lineInfo = getLineInfo(source); |
2500 DartEntry dartEntry = _cache.get(source); | 2519 DartEntry dartEntry = _cache.get(source); |
2501 if (thrownException == null) { | 2520 if (thrownException == null) { |
2502 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo); | 2521 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo); |
2503 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); | 2522 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
2504 dartEntry.setValueInLibrary( | 2523 dartEntry.setValueInLibrary( |
2505 DartEntry.RESOLVED_UNIT, librarySource, unit); | 2524 DartEntry.RESOLVED_UNIT, librarySource, unit); |
2506 dartEntry.setValueInLibrary( | 2525 dartEntry.setValueInLibrary( |
2507 DartEntry.RESOLUTION_ERRORS, librarySource, errors); | 2526 DartEntry.RESOLUTION_ERRORS, librarySource, errors); |
2508 if (source == librarySource) { | 2527 if (source == librarySource) { |
2509 _recordElementData( | 2528 _recordElementData( |
2510 dartEntry, library.libraryElement, librarySource, htmlSource); | 2529 dartEntry, library.libraryElement, librarySource, htmlSource); |
2511 } | 2530 } |
2512 _cache.storedAst(source); | 2531 _cache.storedAst(source); |
2513 } else { | 2532 } else { |
2514 dartEntry.recordResolutionErrorInLibrary( | 2533 dartEntry.recordResolutionErrorInLibrary( |
2515 librarySource, thrownException); | 2534 librarySource, thrownException); |
2516 _cache.remove(source); | 2535 _removeFromCache(source); |
2517 } | 2536 } |
2518 if (source != librarySource) { | 2537 if (source != librarySource) { |
2519 _workManager.add(source, SourcePriority.PRIORITY_PART); | 2538 _workManager.add(source, SourcePriority.PRIORITY_PART); |
2520 } | 2539 } |
2521 ChangeNoticeImpl notice = getNotice(source); | 2540 ChangeNoticeImpl notice = getNotice(source); |
2522 notice.resolvedDartUnit = unit; | 2541 notice.resolvedDartUnit = unit; |
2523 notice.setErrors(dartEntry.allErrors, lineInfo); | 2542 notice.setErrors(dartEntry.allErrors, lineInfo); |
2524 } | 2543 } |
2525 } | 2544 } |
2526 } | 2545 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2608 } | 2627 } |
2609 } | 2628 } |
2610 int count = changedSources.length; | 2629 int count = changedSources.length; |
2611 for (int i = 0; i < count; i++) { | 2630 for (int i = 0; i < count; i++) { |
2612 _sourceChanged(changedSources[i]); | 2631 _sourceChanged(changedSources[i]); |
2613 } | 2632 } |
2614 int removalCount = 0; | 2633 int removalCount = 0; |
2615 for (Source source in missingSources) { | 2634 for (Source source in missingSources) { |
2616 if (getLibrariesContaining(source).isEmpty && | 2635 if (getLibrariesContaining(source).isEmpty && |
2617 getLibrariesDependingOn(source).isEmpty) { | 2636 getLibrariesDependingOn(source).isEmpty) { |
2618 _cache.remove(source); | 2637 _removeFromCache(source); |
2619 removalCount++; | 2638 removalCount++; |
2620 } | 2639 } |
2621 } | 2640 } |
2622 int consistencyCheckEnd = JavaSystem.nanoTime(); | 2641 int consistencyCheckEnd = JavaSystem.nanoTime(); |
2623 if (changedSources.length > 0 || missingSources.length > 0) { | 2642 if (changedSources.length > 0 || missingSources.length > 0) { |
2624 StringBuffer buffer = new StringBuffer(); | 2643 StringBuffer buffer = new StringBuffer(); |
2625 buffer.write("Consistency check took "); | 2644 buffer.write("Consistency check took "); |
2626 buffer.write((consistencyCheckEnd - consistencyCheckStart) / 1000000.0); | 2645 buffer.write((consistencyCheckEnd - consistencyCheckStart) / 1000000.0); |
2627 buffer.writeln(" ms and found"); | 2646 buffer.writeln(" ms and found"); |
2628 buffer.write(" "); | 2647 buffer.write(" "); |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3378 * Create a source entry for the given [source]. Return the source entry that | 3397 * 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. | 3398 * was created, or `null` if the source should not be tracked by this context. |
3380 */ | 3399 */ |
3381 SourceEntry _createSourceEntry(Source source, bool explicitlyAdded) { | 3400 SourceEntry _createSourceEntry(Source source, bool explicitlyAdded) { |
3382 String name = source.shortName; | 3401 String name = source.shortName; |
3383 if (AnalysisEngine.isHtmlFileName(name)) { | 3402 if (AnalysisEngine.isHtmlFileName(name)) { |
3384 HtmlEntry htmlEntry = new HtmlEntry(); | 3403 HtmlEntry htmlEntry = new HtmlEntry(); |
3385 htmlEntry.modificationTime = getModificationStamp(source); | 3404 htmlEntry.modificationTime = getModificationStamp(source); |
3386 htmlEntry.explicitlyAdded = explicitlyAdded; | 3405 htmlEntry.explicitlyAdded = explicitlyAdded; |
3387 _cache.put(source, htmlEntry); | 3406 _cache.put(source, htmlEntry); |
3407 if (!explicitlyAdded) { | |
3408 _analyzedSourcesController.add(new AnalyzedSourcesEvent(source, true)); | |
3409 } | |
3388 return htmlEntry; | 3410 return htmlEntry; |
3389 } else { | 3411 } else { |
3390 DartEntry dartEntry = new DartEntry(); | 3412 DartEntry dartEntry = new DartEntry(); |
3391 dartEntry.modificationTime = getModificationStamp(source); | 3413 dartEntry.modificationTime = getModificationStamp(source); |
3392 dartEntry.explicitlyAdded = explicitlyAdded; | 3414 dartEntry.explicitlyAdded = explicitlyAdded; |
3393 _cache.put(source, dartEntry); | 3415 _cache.put(source, dartEntry); |
3416 if (!explicitlyAdded) { | |
3417 _analyzedSourcesController.add(new AnalyzedSourcesEvent(source, true)); | |
3418 } | |
3394 return dartEntry; | 3419 return dartEntry; |
3395 } | 3420 } |
3396 } | 3421 } |
3397 | 3422 |
3398 /** | 3423 /** |
3399 * Return a list containing all of the change notices that are waiting to be | 3424 * 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 | 3425 * returned. If there are no notices, then return either `null` or an empty |
3401 * list, depending on the value of [nullIfEmpty]. | 3426 * list, depending on the value of [nullIfEmpty]. |
3402 */ | 3427 */ |
3403 List<ChangeNotice> _getChangeNotices(bool nullIfEmpty) { | 3428 List<ChangeNotice> _getChangeNotices(bool nullIfEmpty) { |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4101 bool _isTooBigHtmlSourceEntry(Source source, SourceEntry sourceEntry) => | 4126 bool _isTooBigHtmlSourceEntry(Source source, SourceEntry sourceEntry) => |
4102 false; | 4127 false; |
4103 | 4128 |
4104 /** | 4129 /** |
4105 * Log the given debugging [message]. | 4130 * Log the given debugging [message]. |
4106 */ | 4131 */ |
4107 void _logInformation(String message) { | 4132 void _logInformation(String message) { |
4108 AnalysisEngine.instance.logger.logInformation(message); | 4133 AnalysisEngine.instance.logger.logInformation(message); |
4109 } | 4134 } |
4110 | 4135 |
4136 /** | |
4137 * Notify all of the analysis listeners that a task is about to be performed. | |
4138 */ | |
4139 void _notifyAboutToPerformTask(String taskDescription) { | |
4140 int count = _listeners.length; | |
4141 for (int i = 0; i < count; i++) { | |
4142 _listeners[i].aboutToPerformTask(this, taskDescription); | |
4143 } | |
4144 } | |
4145 | |
4111 // /** | 4146 // /** |
4112 // * Notify all of the analysis listeners that the given source is no longer i ncluded in the set of | 4147 // * 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. | 4148 // * sources that are being analyzed. |
4114 // * | 4149 // * |
4115 // * @param source the source that is no longer being analyzed | 4150 // * @param source the source that is no longer being analyzed |
4116 // */ | 4151 // */ |
4117 // void _notifyExcludedSource(Source source) { | 4152 // void _notifyExcludedSource(Source source) { |
4118 // int count = _listeners.length; | 4153 // int count = _listeners.length; |
4119 // for (int i = 0; i < count; i++) { | 4154 // for (int i = 0; i < count; i++) { |
4120 // _listeners[i].excludedSource(this, source); | 4155 // _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 | 4215 // * @param unit the result of resolving the source |
4181 // */ | 4216 // */ |
4182 // void _notifyResolvedHtml(Source source, ht.HtmlUnit unit) { | 4217 // void _notifyResolvedHtml(Source source, ht.HtmlUnit unit) { |
4183 // int count = _listeners.length; | 4218 // int count = _listeners.length; |
4184 // for (int i = 0; i < count; i++) { | 4219 // for (int i = 0; i < count; i++) { |
4185 // _listeners[i].resolvedHtml(this, source, unit); | 4220 // _listeners[i].resolvedHtml(this, source, unit); |
4186 // } | 4221 // } |
4187 // } | 4222 // } |
4188 | 4223 |
4189 /** | 4224 /** |
4190 * Notify all of the analysis listeners that a task is about to be performed. | |
4191 */ | |
4192 void _notifyAboutToPerformTask(String taskDescription) { | |
4193 int count = _listeners.length; | |
4194 for (int i = 0; i < count; i++) { | |
4195 _listeners[i].aboutToPerformTask(this, taskDescription); | |
4196 } | |
4197 } | |
4198 | |
4199 /** | |
4200 * Notify all of the analysis listeners that the errors associated with the | 4225 * Notify all of the analysis listeners that the errors associated with the |
4201 * given [source] has been updated to the given [errors]. | 4226 * given [source] has been updated to the given [errors]. |
4202 */ | 4227 */ |
4203 void _notifyErrors( | 4228 void _notifyErrors( |
4204 Source source, List<AnalysisError> errors, LineInfo lineInfo) { | 4229 Source source, List<AnalysisError> errors, LineInfo lineInfo) { |
4205 int count = _listeners.length; | 4230 int count = _listeners.length; |
4206 for (int i = 0; i < count; i++) { | 4231 for (int i = 0; i < count; i++) { |
4207 _listeners[i].computedErrors(this, source, errors, lineInfo); | 4232 _listeners[i].computedErrors(this, source, errors, lineInfo); |
4208 } | 4233 } |
4209 } | 4234 } |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4562 LineInfo lineInfo = task.lineInfo; | 4587 LineInfo lineInfo = task.lineInfo; |
4563 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo); | 4588 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo); |
4564 dartEntry.setValue(DartEntry.TOKEN_STREAM, task.tokenStream); | 4589 dartEntry.setValue(DartEntry.TOKEN_STREAM, task.tokenStream); |
4565 dartEntry.setValue(DartEntry.SCAN_ERRORS, task.errors); | 4590 dartEntry.setValue(DartEntry.SCAN_ERRORS, task.errors); |
4566 _cache.storedAst(source); | 4591 _cache.storedAst(source); |
4567 ChangeNoticeImpl notice = getNotice(source); | 4592 ChangeNoticeImpl notice = getNotice(source); |
4568 notice.setErrors(dartEntry.allErrors, lineInfo); | 4593 notice.setErrors(dartEntry.allErrors, lineInfo); |
4569 return dartEntry; | 4594 return dartEntry; |
4570 } | 4595 } |
4571 | 4596 |
4597 void _removeFromCache(Source source) { | |
4598 SourceEntry entry = _cache.remove(source); | |
4599 if (entry != null && entry.explicitlyAdded) { | |
4600 _analyzedSourcesController.add(new AnalyzedSourcesEvent(source, false)); | |
4601 } | |
4602 } | |
4603 | |
4572 /** | 4604 /** |
4573 * Remove the given [librarySource] from the list of containing libraries for | 4605 * Remove the given [librarySource] from the list of containing libraries for |
4574 * all of the parts referenced by the given [dartEntry]. | 4606 * all of the parts referenced by the given [dartEntry]. |
4575 */ | 4607 */ |
4576 void _removeFromParts(Source librarySource, DartEntry dartEntry) { | 4608 void _removeFromParts(Source librarySource, DartEntry dartEntry) { |
4577 List<Source> oldParts = dartEntry.getValue(DartEntry.INCLUDED_PARTS); | 4609 List<Source> oldParts = dartEntry.getValue(DartEntry.INCLUDED_PARTS); |
4578 for (int i = 0; i < oldParts.length; i++) { | 4610 for (int i = 0; i < oldParts.length; i++) { |
4579 Source partSource = oldParts[i]; | 4611 Source partSource = oldParts[i]; |
4580 DartEntry partEntry = _getReadableDartEntry(partSource); | 4612 DartEntry partEntry = _getReadableDartEntry(partSource); |
4581 if (partEntry != null && !identical(partEntry, dartEntry)) { | 4613 if (partEntry != null && !identical(partEntry, dartEntry)) { |
4582 partEntry.removeContainingLibrary(librarySource); | 4614 partEntry.removeContainingLibrary(librarySource); |
4583 if (partEntry.containingLibraries.length == 0 && !exists(partSource)) { | 4615 if (partEntry.containingLibraries.length == 0 && !exists(partSource)) { |
4584 _cache.remove(partSource); | 4616 _removeFromCache(partSource); |
4585 } | 4617 } |
4586 } | 4618 } |
4587 } | 4619 } |
4588 } | 4620 } |
4589 | 4621 |
4590 /** | 4622 /** |
4591 * Remove the given libraries that are keys in the given map from the list of | 4623 * 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. | 4624 * containing libraries for each of the parts in the corresponding value. |
4593 */ | 4625 */ |
4594 void _removeFromPartsUsingMap(HashMap<Source, List<Source>> oldPartMap) { | 4626 void _removeFromPartsUsingMap(HashMap<Source, List<Source>> oldPartMap) { |
4595 oldPartMap.forEach((Source librarySource, List<Source> oldParts) { | 4627 oldPartMap.forEach((Source librarySource, List<Source> oldParts) { |
4596 for (int i = 0; i < oldParts.length; i++) { | 4628 for (int i = 0; i < oldParts.length; i++) { |
4597 Source partSource = oldParts[i]; | 4629 Source partSource = oldParts[i]; |
4598 if (partSource != librarySource) { | 4630 if (partSource != librarySource) { |
4599 DartEntry partEntry = _getReadableDartEntry(partSource); | 4631 DartEntry partEntry = _getReadableDartEntry(partSource); |
4600 if (partEntry != null) { | 4632 if (partEntry != null) { |
4601 partEntry.removeContainingLibrary(librarySource); | 4633 partEntry.removeContainingLibrary(librarySource); |
4602 if (partEntry.containingLibraries.length == 0 && | 4634 if (partEntry.containingLibraries.length == 0 && |
4603 !exists(partSource)) { | 4635 !exists(partSource)) { |
4604 _cache.remove(partSource); | 4636 _removeFromCache(partSource); |
4605 } | 4637 } |
4606 } | 4638 } |
4607 } | 4639 } |
4608 } | 4640 } |
4609 }); | 4641 }); |
4610 } | 4642 } |
4611 | 4643 |
4612 /** | 4644 /** |
4613 * Remove the given [source] from the priority order if it is in the list. | 4645 * Remove the given [source] from the priority order if it is in the list. |
4614 */ | 4646 */ |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4711 libraries.add(librarySource); | 4743 libraries.add(librarySource); |
4712 for (Source dependentLibrary | 4744 for (Source dependentLibrary |
4713 in getLibrariesDependingOn(librarySource)) { | 4745 in getLibrariesDependingOn(librarySource)) { |
4714 libraries.add(dependentLibrary); | 4746 libraries.add(dependentLibrary); |
4715 } | 4747 } |
4716 } | 4748 } |
4717 for (Source librarySource in libraries) { | 4749 for (Source librarySource in libraries) { |
4718 _invalidateLibraryResolution(librarySource); | 4750 _invalidateLibraryResolution(librarySource); |
4719 } | 4751 } |
4720 } | 4752 } |
4721 _cache.remove(source); | 4753 _removeFromCache(source); |
4722 _workManager.remove(source); | 4754 _workManager.remove(source); |
4723 _removeFromPriorityOrder(source); | 4755 _removeFromPriorityOrder(source); |
4724 } | 4756 } |
4725 | 4757 |
4726 /** | 4758 /** |
4727 * TODO(scheglov) A hackish, limited incremental resolution implementation. | 4759 * TODO(scheglov) A hackish, limited incremental resolution implementation. |
4728 */ | 4760 */ |
4729 bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) { | 4761 bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) { |
4730 return PerformanceStatistics.incrementalAnalysis.makeCurrentWhile(() { | 4762 return PerformanceStatistics.incrementalAnalysis.makeCurrentWhile(() { |
4731 incrementalResolutionValidation_lastUnitSource = null; | 4763 incrementalResolutionValidation_lastUnitSource = null; |
(...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6587 E visitResolveHtmlTask(ResolveHtmlTask task); | 6619 E visitResolveHtmlTask(ResolveHtmlTask task); |
6588 | 6620 |
6589 /** | 6621 /** |
6590 * Visit the given [task], returning the result of the visit. This method will | 6622 * Visit the given [task], returning the result of the visit. This method will |
6591 * throw an AnalysisException if the visitor throws an exception. | 6623 * throw an AnalysisException if the visitor throws an exception. |
6592 */ | 6624 */ |
6593 E visitScanDartTask(ScanDartTask task); | 6625 E visitScanDartTask(ScanDartTask task); |
6594 } | 6626 } |
6595 | 6627 |
6596 /** | 6628 /** |
6629 * An event indicating when a source either starts or stops being implicitly | |
6630 * analyzed. | |
6631 */ | |
6632 class AnalyzedSourcesEvent { | |
6633 /** | |
6634 * The source whose status has changed. | |
6635 */ | |
6636 final Source source; | |
6637 | |
6638 /** | |
6639 * A flag indicating whether the source is now being analyzed. | |
6640 */ | |
6641 final bool isAnalyzed; | |
6642 | |
6643 /** | |
6644 * Initialize a newly created event to indicate that the given [source] has | |
6645 * changed it status to match the [isAnalyzed] flag. | |
6646 */ | |
6647 AnalyzedSourcesEvent(this.source, this.isAnalyzed); | |
6648 | |
6649 @override | |
6650 String toString() => | |
6651 '${isAnalyzed ? '' : 'not '}analyzing ${source.fullName}'; | |
6652 } | |
6653 | |
6654 /** | |
6597 * A `CachedResult` is a single analysis result that is stored in a | 6655 * A `CachedResult` is a single analysis result that is stored in a |
6598 * [SourceEntry]. | 6656 * [SourceEntry]. |
6599 */ | 6657 */ |
6600 class CachedResult<E> { | 6658 class CachedResult<E> { |
6601 /** | 6659 /** |
6602 * The state of the cached value. | 6660 * The state of the cached value. |
6603 */ | 6661 */ |
6604 CacheState state; | 6662 CacheState state; |
6605 | 6663 |
6606 /** | 6664 /** |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6745 | 6803 |
6746 /** | 6804 /** |
6747 * Associate the given [entry] with the given [source]. | 6805 * Associate the given [entry] with the given [source]. |
6748 */ | 6806 */ |
6749 void put(Source source, SourceEntry entry) { | 6807 void put(Source source, SourceEntry entry) { |
6750 entry.fixExceptionState(); | 6808 entry.fixExceptionState(); |
6751 _sourceMap[source] = entry; | 6809 _sourceMap[source] = entry; |
6752 } | 6810 } |
6753 | 6811 |
6754 /** | 6812 /** |
6755 * Remove all information related to the given [source] from this cache. | 6813 * Remove all information related to the given [source] from this partition |
6814 * and return the entry associated with the source. | |
Paul Berry
2015/07/15 19:50:01
Document when we might return `null`.
Brian Wilkerson
2015/07/15 21:23:37
Done
| |
6756 */ | 6815 */ |
6757 void remove(Source source) { | 6816 SourceEntry remove(Source source) { |
6758 _recentlyUsed.remove(source); | 6817 _recentlyUsed.remove(source); |
6759 _sourceMap.remove(source); | 6818 return _sourceMap.remove(source); |
6760 } | 6819 } |
6761 | 6820 |
6762 /** | 6821 /** |
6763 * Record that the AST associated with the given [source] was just removed | 6822 * Record that the AST associated with the given [source] was just removed |
6764 * from the cache. | 6823 * from the cache. |
6765 */ | 6824 */ |
6766 void removedAst(Source source) { | 6825 void removedAst(Source source) { |
6767 _recentlyUsed.remove(source); | 6826 _recentlyUsed.remove(source); |
6768 } | 6827 } |
6769 | 6828 |
(...skipping 5070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11840 PendingFuture pendingFuture = | 11899 PendingFuture pendingFuture = |
11841 new PendingFuture<T>(_context, source, computeValue); | 11900 new PendingFuture<T>(_context, source, computeValue); |
11842 if (!pendingFuture.evaluate(sourceEntry)) { | 11901 if (!pendingFuture.evaluate(sourceEntry)) { |
11843 _context._pendingFutureSources | 11902 _context._pendingFutureSources |
11844 .putIfAbsent(source, () => <PendingFuture>[]) | 11903 .putIfAbsent(source, () => <PendingFuture>[]) |
11845 .add(pendingFuture); | 11904 .add(pendingFuture); |
11846 } | 11905 } |
11847 return pendingFuture.future; | 11906 return pendingFuture.future; |
11848 } | 11907 } |
11849 } | 11908 } |
OLD | NEW |