| 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 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 // DartEntry dartEntry = (DartEntry) sourceEntry; | 1205 // DartEntry dartEntry = (DartEntry) sourceEntry; |
| 1206 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && dartEntry.getValu
e(DartEntry.IS_CLIENT)) { | 1206 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && dartEntry.getValu
e(DartEntry.IS_CLIENT)) { |
| 1207 sources.add(source); | 1207 sources.add(source); |
| 1208 // } | 1208 // } |
| 1209 } | 1209 } |
| 1210 } | 1210 } |
| 1211 return sources; | 1211 return sources; |
| 1212 } | 1212 } |
| 1213 | 1213 |
| 1214 @override | 1214 @override |
| 1215 bool validateSourceCacheConsistency(Source source) { |
| 1216 SourceEntry entry = _cache.get(source); |
| 1217 if (entry != null) { |
| 1218 int sourceTime = getModificationStamp(source); |
| 1219 if (sourceTime != entry.modificationTime) { |
| 1220 _sourceChanged(source); |
| 1221 return true; |
| 1222 } |
| 1223 if (entry.exception != null) { |
| 1224 if (!exists(source)) { |
| 1225 if (getLibrariesContaining(source).isEmpty && |
| 1226 getLibrariesDependingOn(source).isEmpty) { |
| 1227 _cache.remove(source); |
| 1228 } |
| 1229 } |
| 1230 } |
| 1231 } |
| 1232 return false; |
| 1233 } |
| 1234 |
| 1235 @override |
| 1215 List<Source> get launchableServerLibrarySources { | 1236 List<Source> get launchableServerLibrarySources { |
| 1216 // TODO(brianwilkerson) This needs to filter out libraries that reference | 1237 // TODO(brianwilkerson) This needs to filter out libraries that reference |
| 1217 // dart:html, either directly or indirectly. | 1238 // dart:html, either directly or indirectly. |
| 1218 List<Source> sources = new List<Source>(); | 1239 List<Source> sources = new List<Source>(); |
| 1219 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); | 1240 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); |
| 1220 while (iterator.moveNext()) { | 1241 while (iterator.moveNext()) { |
| 1221 Source source = iterator.key; | 1242 Source source = iterator.key; |
| 1222 SourceEntry sourceEntry = iterator.value; | 1243 SourceEntry sourceEntry = iterator.value; |
| 1223 if (sourceEntry.kind == SourceKind.LIBRARY && !source.isInSystemLibrary) { | 1244 if (sourceEntry.kind == SourceKind.LIBRARY && !source.isInSystemLibrary) { |
| 1224 // DartEntry dartEntry = (DartEntry) sourceEntry; | 1245 // DartEntry dartEntry = (DartEntry) sourceEntry; |
| (...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2262 @override | 2283 @override |
| 2263 AnalysisResult performAnalysisTask() { | 2284 AnalysisResult performAnalysisTask() { |
| 2264 if (_TRACE_PERFORM_TASK) { | 2285 if (_TRACE_PERFORM_TASK) { |
| 2265 print("----------------------------------------"); | 2286 print("----------------------------------------"); |
| 2266 } | 2287 } |
| 2267 return PerformanceStatistics.performAnaysis.makeCurrentWhile(() { | 2288 return PerformanceStatistics.performAnaysis.makeCurrentWhile(() { |
| 2268 int getStart = JavaSystem.currentTimeMillis(); | 2289 int getStart = JavaSystem.currentTimeMillis(); |
| 2269 AnalysisTask task = PerformanceStatistics.nextTask | 2290 AnalysisTask task = PerformanceStatistics.nextTask |
| 2270 .makeCurrentWhile(() => nextAnalysisTask); | 2291 .makeCurrentWhile(() => nextAnalysisTask); |
| 2271 int getEnd = JavaSystem.currentTimeMillis(); | 2292 int getEnd = JavaSystem.currentTimeMillis(); |
| 2272 if (task == null && _validateCacheConsistency()) { | |
| 2273 task = nextAnalysisTask; | |
| 2274 } | |
| 2275 if (task == null) { | 2293 if (task == null) { |
| 2276 _validateLastIncrementalResolutionResult(); | 2294 _validateLastIncrementalResolutionResult(); |
| 2277 if (_performAnalysisTaskStopwatch != null) { | 2295 if (_performAnalysisTaskStopwatch != null) { |
| 2278 AnalysisEngine.instance.instrumentationService.logPerformance( | 2296 AnalysisEngine.instance.instrumentationService.logPerformance( |
| 2279 AnalysisPerformanceKind.FULL, _performAnalysisTaskStopwatch, | 2297 AnalysisPerformanceKind.FULL, _performAnalysisTaskStopwatch, |
| 2280 'context_id=$_id'); | 2298 'context_id=$_id'); |
| 2281 _performAnalysisTaskStopwatch = null; | 2299 _performAnalysisTaskStopwatch = null; |
| 2282 } | 2300 } |
| 2283 return new AnalysisResult( | 2301 return new AnalysisResult( |
| 2284 _getChangeNotices(true), getEnd - getStart, null, -1); | 2302 _getChangeNotices(true), getEnd - getStart, null, -1); |
| (...skipping 1734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4019 return true; | 4037 return true; |
| 4020 } | 4038 } |
| 4021 } | 4039 } |
| 4022 return false; | 4040 return false; |
| 4023 } | 4041 } |
| 4024 | 4042 |
| 4025 bool _isTooBigHtmlSourceEntry(Source source, SourceEntry sourceEntry) => | 4043 bool _isTooBigHtmlSourceEntry(Source source, SourceEntry sourceEntry) => |
| 4026 false; | 4044 false; |
| 4027 | 4045 |
| 4028 /** | 4046 /** |
| 4029 * Log the given debugging [message]. | |
| 4030 */ | |
| 4031 void _logInformation(String message) { | |
| 4032 AnalysisEngine.instance.logger.logInformation(message); | |
| 4033 } | |
| 4034 | |
| 4035 /** | |
| 4036 * Notify all of the analysis listeners that a task is about to be performed. | 4047 * Notify all of the analysis listeners that a task is about to be performed. |
| 4037 */ | 4048 */ |
| 4038 void _notifyAboutToPerformTask(String taskDescription) { | 4049 void _notifyAboutToPerformTask(String taskDescription) { |
| 4039 int count = _listeners.length; | 4050 int count = _listeners.length; |
| 4040 for (int i = 0; i < count; i++) { | 4051 for (int i = 0; i < count; i++) { |
| 4041 _listeners[i].aboutToPerformTask(this, taskDescription); | 4052 _listeners[i].aboutToPerformTask(this, taskDescription); |
| 4042 } | 4053 } |
| 4043 } | 4054 } |
| 4044 | 4055 |
| 4045 // /** | 4056 // /** |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4724 LineInfo lineInfo = getLineInfo(unitSource); | 4735 LineInfo lineInfo = getLineInfo(unitSource); |
| 4725 ChangeNoticeImpl notice = getNotice(unitSource); | 4736 ChangeNoticeImpl notice = getNotice(unitSource); |
| 4726 notice.resolvedDartUnit = oldUnit; | 4737 notice.resolvedDartUnit = oldUnit; |
| 4727 notice.setErrors(dartEntry.allErrors, lineInfo); | 4738 notice.setErrors(dartEntry.allErrors, lineInfo); |
| 4728 } | 4739 } |
| 4729 // OK | 4740 // OK |
| 4730 return true; | 4741 return true; |
| 4731 }); | 4742 }); |
| 4732 } | 4743 } |
| 4733 | 4744 |
| 4734 /** | |
| 4735 * Check the cache for any invalid entries (entries whose modification time | |
| 4736 * does not match the modification time of the source associated with the | |
| 4737 * entry). Invalid entries will be marked as invalid so that the source will | |
| 4738 * be re-analyzed. Return `true` if at least one entry was invalid. | |
| 4739 */ | |
| 4740 bool _validateCacheConsistency() { | |
| 4741 int consistencyCheckStart = JavaSystem.nanoTime(); | |
| 4742 List<Source> changedSources = new List<Source>(); | |
| 4743 List<Source> missingSources = new List<Source>(); | |
| 4744 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); | |
| 4745 while (iterator.moveNext()) { | |
| 4746 Source source = iterator.key; | |
| 4747 SourceEntry sourceEntry = iterator.value; | |
| 4748 int sourceTime = getModificationStamp(source); | |
| 4749 if (sourceTime != sourceEntry.modificationTime) { | |
| 4750 changedSources.add(source); | |
| 4751 } | |
| 4752 if (sourceEntry.exception != null) { | |
| 4753 if (!exists(source)) { | |
| 4754 missingSources.add(source); | |
| 4755 } | |
| 4756 } | |
| 4757 } | |
| 4758 int count = changedSources.length; | |
| 4759 for (int i = 0; i < count; i++) { | |
| 4760 _sourceChanged(changedSources[i]); | |
| 4761 } | |
| 4762 int removalCount = 0; | |
| 4763 for (Source source in missingSources) { | |
| 4764 if (getLibrariesContaining(source).isEmpty && | |
| 4765 getLibrariesDependingOn(source).isEmpty) { | |
| 4766 _cache.remove(source); | |
| 4767 removalCount++; | |
| 4768 } | |
| 4769 } | |
| 4770 int consistencyCheckEnd = JavaSystem.nanoTime(); | |
| 4771 if (changedSources.length > 0 || missingSources.length > 0) { | |
| 4772 StringBuffer buffer = new StringBuffer(); | |
| 4773 buffer.write("Consistency check took "); | |
| 4774 buffer.write((consistencyCheckEnd - consistencyCheckStart) / 1000000.0); | |
| 4775 buffer.writeln(" ms and found"); | |
| 4776 buffer.write(" "); | |
| 4777 buffer.write(changedSources.length); | |
| 4778 buffer.writeln(" inconsistent entries"); | |
| 4779 buffer.write(" "); | |
| 4780 buffer.write(missingSources.length); | |
| 4781 buffer.write(" missing sources ("); | |
| 4782 buffer.write(removalCount); | |
| 4783 buffer.writeln(" removed"); | |
| 4784 for (Source source in missingSources) { | |
| 4785 buffer.write(" "); | |
| 4786 buffer.writeln(source.fullName); | |
| 4787 } | |
| 4788 _logInformation(buffer.toString()); | |
| 4789 } | |
| 4790 return changedSources.length > 0; | |
| 4791 } | |
| 4792 | |
| 4793 void _validateLastIncrementalResolutionResult() { | 4745 void _validateLastIncrementalResolutionResult() { |
| 4794 if (incrementalResolutionValidation_lastUnitSource == null || | 4746 if (incrementalResolutionValidation_lastUnitSource == null || |
| 4795 incrementalResolutionValidation_lastLibrarySource == null || | 4747 incrementalResolutionValidation_lastLibrarySource == null || |
| 4796 incrementalResolutionValidation_lastUnit == null) { | 4748 incrementalResolutionValidation_lastUnit == null) { |
| 4797 return; | 4749 return; |
| 4798 } | 4750 } |
| 4799 CompilationUnit fullUnit = getResolvedCompilationUnit2( | 4751 CompilationUnit fullUnit = getResolvedCompilationUnit2( |
| 4800 incrementalResolutionValidation_lastUnitSource, | 4752 incrementalResolutionValidation_lastUnitSource, |
| 4801 incrementalResolutionValidation_lastLibrarySource); | 4753 incrementalResolutionValidation_lastLibrarySource); |
| 4802 if (fullUnit != null) { | 4754 if (fullUnit != null) { |
| (...skipping 4382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9185 * Returns a statistics about this context. | 9137 * Returns a statistics about this context. |
| 9186 */ | 9138 */ |
| 9187 AnalysisContextStatistics get statistics; | 9139 AnalysisContextStatistics get statistics; |
| 9188 | 9140 |
| 9189 /** | 9141 /** |
| 9190 * Sets the [TypeProvider] for this context. | 9142 * Sets the [TypeProvider] for this context. |
| 9191 */ | 9143 */ |
| 9192 void set typeProvider(TypeProvider typeProvider); | 9144 void set typeProvider(TypeProvider typeProvider); |
| 9193 | 9145 |
| 9194 /** | 9146 /** |
| 9147 * Check whether the cache entry for the given [source] is valid, i.e. the |
| 9148 * entry modification time matches the modification time of the [source]. |
| 9149 * If not, the entry is marked as invalid so that the source will be |
| 9150 * re-analyzed, and `true` is returned. |
| 9151 */ |
| 9152 bool validateSourceCacheConsistency(Source source); |
| 9153 |
| 9154 /** |
| 9195 * A factory to override how [TypeResolverVisitor] is created. | 9155 * A factory to override how [TypeResolverVisitor] is created. |
| 9196 */ | 9156 */ |
| 9197 TypeResolverVisitorFactory get typeResolverVisitorFactory; | 9157 TypeResolverVisitorFactory get typeResolverVisitorFactory; |
| 9198 | 9158 |
| 9199 /** | 9159 /** |
| 9200 * Return a list containing the sources of the libraries that are exported by | 9160 * Return a list containing the sources of the libraries that are exported by |
| 9201 * the library with the given [source]. The list will be empty if the given | 9161 * the library with the given [source]. The list will be empty if the given |
| 9202 * source is invalid, if the given source does not represent a library, or if | 9162 * source is invalid, if the given source does not represent a library, or if |
| 9203 * the library does not export any other libraries. | 9163 * the library does not export any other libraries. |
| 9204 * | 9164 * |
| (...skipping 2615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11820 PendingFuture pendingFuture = | 11780 PendingFuture pendingFuture = |
| 11821 new PendingFuture<T>(_context, source, computeValue); | 11781 new PendingFuture<T>(_context, source, computeValue); |
| 11822 if (!pendingFuture.evaluate(sourceEntry)) { | 11782 if (!pendingFuture.evaluate(sourceEntry)) { |
| 11823 _context._pendingFutureSources | 11783 _context._pendingFutureSources |
| 11824 .putIfAbsent(source, () => <PendingFuture>[]) | 11784 .putIfAbsent(source, () => <PendingFuture>[]) |
| 11825 .add(pendingFuture); | 11785 .add(pendingFuture); |
| 11826 } | 11786 } |
| 11827 return pendingFuture.future; | 11787 return pendingFuture.future; |
| 11828 } | 11788 } |
| 11829 } | 11789 } |
| OLD | NEW |