| 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 library engine; | 5 library engine; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:math' as math; | 9 import 'dart:math' as math; |
| 10 | 10 |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 * If the resolved AST can't be computed for some reason, the future will be | 546 * If the resolved AST can't be computed for some reason, the future will be |
| 547 * completed with an error. One possible error is AnalysisNotScheduledError, | 547 * completed with an error. One possible error is AnalysisNotScheduledError, |
| 548 * which means that the resolved AST can't be computed because the given | 548 * which means that the resolved AST can't be computed because the given |
| 549 * source file is not scheduled to be analyzed within the context of the | 549 * source file is not scheduled to be analyzed within the context of the |
| 550 * given library. | 550 * given library. |
| 551 */ | 551 */ |
| 552 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync( | 552 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync( |
| 553 Source source, Source librarySource); | 553 Source source, Source librarySource); |
| 554 | 554 |
| 555 /** | 555 /** |
| 556 * Perform work until the given [result] has been computed for the given |
| 557 * [target]. Return the computed value. |
| 558 */ |
| 559 Object /*V*/ computeResult(AnalysisTarget target, ResultDescriptor /*<V>*/ res
ult); |
| 560 |
| 561 /** |
| 556 * Notifies the context that the client is going to stop using this context. | 562 * Notifies the context that the client is going to stop using this context. |
| 557 */ | 563 */ |
| 558 void dispose(); | 564 void dispose(); |
| 559 | 565 |
| 560 /** | 566 /** |
| 561 * Return `true` if the given [source] exists. | 567 * Return `true` if the given [source] exists. |
| 562 * | 568 * |
| 563 * This method should be used rather than the method [Source.exists] because | 569 * This method should be used rather than the method [Source.exists] because |
| 564 * contexts can have local overrides of the content of a source that the | 570 * contexts can have local overrides of the content of a source that the |
| 565 * source is not aware of and a source with local content is considered to | 571 * 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... |
| 711 /** | 717 /** |
| 712 * Return the fully resolved HTML unit defined by the given [htmlSource], or | 718 * Return the fully resolved HTML unit defined by the given [htmlSource], or |
| 713 * `null` if the resolved unit is not already computed. | 719 * `null` if the resolved unit is not already computed. |
| 714 * | 720 * |
| 715 * See [resolveHtmlUnit]. | 721 * See [resolveHtmlUnit]. |
| 716 */ | 722 */ |
| 717 @deprecated | 723 @deprecated |
| 718 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource); | 724 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource); |
| 719 | 725 |
| 720 /** | 726 /** |
| 727 * Return the value of the given [result] for the given [target]. |
| 728 * |
| 729 * If the corresponding [target] does not exist, or the [result] is not |
| 730 * computed yet, then the default value is returned. |
| 731 */ |
| 732 Object /*V*/ getResult(AnalysisTarget target, ResultDescriptor /*<V>*/ result)
; |
| 733 |
| 734 /** |
| 721 * Return a list of the sources being analyzed in this context whose full path | 735 * Return a list of the sources being analyzed in this context whose full path |
| 722 * is equal to the given [path]. | 736 * is equal to the given [path]. |
| 723 */ | 737 */ |
| 724 List<Source> getSourcesWithFullName(String path); | 738 List<Source> getSourcesWithFullName(String path); |
| 725 | 739 |
| 726 /** | 740 /** |
| 727 * Invalidates hints in the given [librarySource] and included parts. | 741 * Invalidates hints in the given [librarySource] and included parts. |
| 728 */ | 742 */ |
| 729 void invalidateLibraryHints(Source librarySource); | 743 void invalidateLibraryHints(Source librarySource); |
| 730 | 744 |
| (...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1798 CacheState.ERROR) { | 1812 CacheState.ERROR) { |
| 1799 throw sourceEntry.exception; | 1813 throw sourceEntry.exception; |
| 1800 } | 1814 } |
| 1801 return sourceEntry.getValueInLibrary( | 1815 return sourceEntry.getValueInLibrary( |
| 1802 DartEntry.RESOLVED_UNIT, librarySource); | 1816 DartEntry.RESOLVED_UNIT, librarySource); |
| 1803 } | 1817 } |
| 1804 throw new AnalysisNotScheduledError(); | 1818 throw new AnalysisNotScheduledError(); |
| 1805 }); | 1819 }); |
| 1806 } | 1820 } |
| 1807 | 1821 |
| 1822 @override |
| 1823 Object computeResult(AnalysisTarget target, ResultDescriptor result) { |
| 1824 return result.defaultValue; |
| 1825 } |
| 1826 |
| 1808 /** | 1827 /** |
| 1809 * Create an analysis cache based on the given source [factory]. | 1828 * Create an analysis cache based on the given source [factory]. |
| 1810 */ | 1829 */ |
| 1811 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { | 1830 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { |
| 1812 if (factory == null) { | 1831 if (factory == null) { |
| 1813 return new AnalysisCache(<CachePartition>[_privatePartition]); | 1832 return new AnalysisCache(<CachePartition>[_privatePartition]); |
| 1814 } | 1833 } |
| 1815 DartSdk sdk = factory.dartSdk; | 1834 DartSdk sdk = factory.dartSdk; |
| 1816 if (sdk == null) { | 1835 if (sdk == null) { |
| 1817 return new AnalysisCache(<CachePartition>[_privatePartition]); | 1836 return new AnalysisCache(<CachePartition>[_privatePartition]); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2176 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { | 2195 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { |
| 2177 SourceEntry sourceEntry = getReadableSourceEntryOrNull(htmlSource); | 2196 SourceEntry sourceEntry = getReadableSourceEntryOrNull(htmlSource); |
| 2178 if (sourceEntry is HtmlEntry) { | 2197 if (sourceEntry is HtmlEntry) { |
| 2179 HtmlEntry htmlEntry = sourceEntry; | 2198 HtmlEntry htmlEntry = sourceEntry; |
| 2180 return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); | 2199 return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
| 2181 } | 2200 } |
| 2182 return null; | 2201 return null; |
| 2183 } | 2202 } |
| 2184 | 2203 |
| 2185 @override | 2204 @override |
| 2205 Object getResult(AnalysisTarget target, ResultDescriptor result) { |
| 2206 return result.defaultValue; |
| 2207 } |
| 2208 |
| 2209 @override |
| 2186 List<Source> getSourcesWithFullName(String path) { | 2210 List<Source> getSourcesWithFullName(String path) { |
| 2187 List<Source> sources = <Source>[]; | 2211 List<Source> sources = <Source>[]; |
| 2188 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); | 2212 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); |
| 2189 while (iterator.moveNext()) { | 2213 while (iterator.moveNext()) { |
| 2190 if (iterator.key.fullName == path) { | 2214 if (iterator.key.fullName == path) { |
| 2191 sources.add(iterator.key); | 2215 sources.add(iterator.key); |
| 2192 } | 2216 } |
| 2193 } | 2217 } |
| 2194 return sources; | 2218 return sources; |
| 2195 } | 2219 } |
| (...skipping 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4162 if (_isClient(exported, htmlSource, visitedLibraries)) { | 4186 if (_isClient(exported, htmlSource, visitedLibraries)) { |
| 4163 return true; | 4187 return true; |
| 4164 } | 4188 } |
| 4165 } | 4189 } |
| 4166 return false; | 4190 return false; |
| 4167 } | 4191 } |
| 4168 | 4192 |
| 4169 bool _isTooBigHtmlSourceEntry(Source source, SourceEntry sourceEntry) => | 4193 bool _isTooBigHtmlSourceEntry(Source source, SourceEntry sourceEntry) => |
| 4170 false; | 4194 false; |
| 4171 | 4195 |
| 4172 /** | |
| 4173 * Log the given debugging [message]. | |
| 4174 */ | |
| 4175 void _logInformation(String message) { | |
| 4176 AnalysisEngine.instance.logger.logInformation(message); | |
| 4177 } | |
| 4178 | |
| 4179 /** | |
| 4180 * Notify all of the analysis listeners that a task is about to be performed. | |
| 4181 */ | |
| 4182 void _notifyAboutToPerformTask(String taskDescription) { | |
| 4183 int count = _listeners.length; | |
| 4184 for (int i = 0; i < count; i++) { | |
| 4185 _listeners[i].aboutToPerformTask(this, taskDescription); | |
| 4186 } | |
| 4187 } | |
| 4188 | |
| 4189 // /** | 4196 // /** |
| 4190 // * Notify all of the analysis listeners that the given source is no longer i
ncluded in the set of | 4197 // * Notify all of the analysis listeners that the given source is no longer i
ncluded in the set of |
| 4191 // * sources that are being analyzed. | 4198 // * sources that are being analyzed. |
| 4192 // * | 4199 // * |
| 4193 // * @param source the source that is no longer being analyzed | 4200 // * @param source the source that is no longer being analyzed |
| 4194 // */ | 4201 // */ |
| 4195 // void _notifyExcludedSource(Source source) { | 4202 // void _notifyExcludedSource(Source source) { |
| 4196 // int count = _listeners.length; | 4203 // int count = _listeners.length; |
| 4197 // for (int i = 0; i < count; i++) { | 4204 // for (int i = 0; i < count; i++) { |
| 4198 // _listeners[i].excludedSource(this, source); | 4205 // _listeners[i].excludedSource(this, source); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4258 // * @param unit the result of resolving the source | 4265 // * @param unit the result of resolving the source |
| 4259 // */ | 4266 // */ |
| 4260 // void _notifyResolvedHtml(Source source, ht.HtmlUnit unit) { | 4267 // void _notifyResolvedHtml(Source source, ht.HtmlUnit unit) { |
| 4261 // int count = _listeners.length; | 4268 // int count = _listeners.length; |
| 4262 // for (int i = 0; i < count; i++) { | 4269 // for (int i = 0; i < count; i++) { |
| 4263 // _listeners[i].resolvedHtml(this, source, unit); | 4270 // _listeners[i].resolvedHtml(this, source, unit); |
| 4264 // } | 4271 // } |
| 4265 // } | 4272 // } |
| 4266 | 4273 |
| 4267 /** | 4274 /** |
| 4275 * Log the given debugging [message]. |
| 4276 */ |
| 4277 void _logInformation(String message) { |
| 4278 AnalysisEngine.instance.logger.logInformation(message); |
| 4279 } |
| 4280 |
| 4281 /** |
| 4282 * Notify all of the analysis listeners that a task is about to be performed. |
| 4283 */ |
| 4284 void _notifyAboutToPerformTask(String taskDescription) { |
| 4285 int count = _listeners.length; |
| 4286 for (int i = 0; i < count; i++) { |
| 4287 _listeners[i].aboutToPerformTask(this, taskDescription); |
| 4288 } |
| 4289 } |
| 4290 |
| 4291 /** |
| 4268 * Notify all of the analysis listeners that the errors associated with the | 4292 * Notify all of the analysis listeners that the errors associated with the |
| 4269 * given [source] has been updated to the given [errors]. | 4293 * given [source] has been updated to the given [errors]. |
| 4270 */ | 4294 */ |
| 4271 void _notifyErrors( | 4295 void _notifyErrors( |
| 4272 Source source, List<AnalysisError> errors, LineInfo lineInfo) { | 4296 Source source, List<AnalysisError> errors, LineInfo lineInfo) { |
| 4273 int count = _listeners.length; | 4297 int count = _listeners.length; |
| 4274 for (int i = 0; i < count; i++) { | 4298 for (int i = 0; i < count; i++) { |
| 4275 _listeners[i].computedErrors(this, source, errors, lineInfo); | 4299 _listeners[i].computedErrors(this, source, errors, lineInfo); |
| 4276 } | 4300 } |
| 4277 } | 4301 } |
| (...skipping 7715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11993 PendingFuture pendingFuture = | 12017 PendingFuture pendingFuture = |
| 11994 new PendingFuture<T>(_context, source, computeValue); | 12018 new PendingFuture<T>(_context, source, computeValue); |
| 11995 if (!pendingFuture.evaluate(sourceEntry)) { | 12019 if (!pendingFuture.evaluate(sourceEntry)) { |
| 11996 _context._pendingFutureSources | 12020 _context._pendingFutureSources |
| 11997 .putIfAbsent(source, () => <PendingFuture>[]) | 12021 .putIfAbsent(source, () => <PendingFuture>[]) |
| 11998 .add(pendingFuture); | 12022 .add(pendingFuture); |
| 11999 } | 12023 } |
| 12000 return pendingFuture.future; | 12024 return pendingFuture.future; |
| 12001 } | 12025 } |
| 12002 } | 12026 } |
| OLD | NEW |