Chromium Code Reviews| 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:math" as math; | 10 import "dart:math" as math; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 import 'java_engine.dart'; | 26 import 'java_engine.dart'; |
| 27 import 'parser.dart' show Parser, IncrementalParser; | 27 import 'parser.dart' show Parser, IncrementalParser; |
| 28 import 'resolver.dart'; | 28 import 'resolver.dart'; |
| 29 import 'scanner.dart'; | 29 import 'scanner.dart'; |
| 30 import 'sdk.dart' show DartSdk; | 30 import 'sdk.dart' show DartSdk; |
| 31 import 'source.dart'; | 31 import 'source.dart'; |
| 32 import 'utilities_collection.dart'; | 32 import 'utilities_collection.dart'; |
| 33 import 'utilities_general.dart'; | 33 import 'utilities_general.dart'; |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * Type of callback functions used by PendingFuture. Functions of this type | |
| 37 * should perform a computation based on the data in [sourceEntry] and return | |
| 38 * it. If the computation can't be performed yet because more analysis is | |
| 39 * needed, null should be returned. | |
| 40 * | |
| 41 * The function may also throw an exception, in which case the corresponding | |
| 42 * future will be completed with failure. | |
| 43 */ | |
| 44 typedef T PendingFutureComputer<T>(SourceEntry sourceEntry); | |
| 45 | |
| 46 /** | |
| 36 * Instances of the class `AnalysisCache` implement an LRU cache of information related to | 47 * Instances of the class `AnalysisCache` implement an LRU cache of information related to |
| 37 * analysis. | 48 * analysis. |
| 38 */ | 49 */ |
| 39 class AnalysisCache { | 50 class AnalysisCache { |
| 40 /** | 51 /** |
| 41 * A flag used to control whether trace information should be produced when th e content of the | 52 * A flag used to control whether trace information should be produced when th e content of the |
| 42 * cache is modified. | 53 * cache is modified. |
| 43 */ | 54 */ |
| 44 static bool _TRACE_CHANGES = false; | 55 static bool _TRACE_CHANGES = false; |
| 45 | 56 |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 674 * Return the element model corresponding to the library defined by the given source, or | 685 * Return the element model corresponding to the library defined by the given source, or |
| 675 * `null` if the element model does not currently exist or if the library cann ot be analyzed | 686 * `null` if the element model does not currently exist or if the library cann ot be analyzed |
| 676 * for some reason. | 687 * for some reason. |
| 677 * | 688 * |
| 678 * @param source the source defining the library whose element model is to be returned | 689 * @param source the source defining the library whose element model is to be returned |
| 679 * @return the element model corresponding to the library defined by the given source | 690 * @return the element model corresponding to the library defined by the given source |
| 680 */ | 691 */ |
| 681 LibraryElement getLibraryElement(Source source); | 692 LibraryElement getLibraryElement(Source source); |
| 682 | 693 |
| 683 /** | 694 /** |
| 695 * Return a future which will be completed with the element model for the | |
| 696 * given source once that element model is up to date. | |
| 697 * | |
| 698 * If the element model for the source can't be computed for some reason, the | |
| 699 * future will be completed with an error. One possible error is | |
| 700 * AnalysisNotScheduledError, which means that the element model can't be | |
| 701 * computed because the given source file is not scheduled to be analyzed. | |
| 702 * (This could happen, for example, because the source file is not known to | |
| 703 * the context, or because it's a part file for which there is no | |
| 704 * corresponding library). | |
| 705 */ | |
| 706 Future<LibraryElement> getLibraryElementFuture(Source source); | |
| 707 | |
| 708 /** | |
| 684 * Return the line information for the given source, or `null` if the line inf ormation is | 709 * Return the line information for the given source, or `null` if the line inf ormation is |
| 685 * not known. The line information is used to map offsets from the beginning o f the source to line | 710 * not known. The line information is used to map offsets from the beginning o f the source to line |
| 686 * and column pairs. | 711 * and column pairs. |
| 687 * | 712 * |
| 688 * @param source the source whose line information is to be returned | 713 * @param source the source whose line information is to be returned |
| 689 * @return the line information for the given source | 714 * @return the line information for the given source |
| 690 * See [computeLineInfo]. | 715 * See [computeLineInfo]. |
| 691 */ | 716 */ |
| 692 LineInfo getLineInfo(Source source); | 717 LineInfo getLineInfo(Source source); |
| 693 | 718 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 725 * @param unitSource the source of the compilation unit | 750 * @param unitSource the source of the compilation unit |
| 726 * @param librarySource the source of the defining compilation unit of the lib rary containing the | 751 * @param librarySource the source of the defining compilation unit of the lib rary containing the |
| 727 * compilation unit | 752 * compilation unit |
| 728 * @return a fully resolved AST for the compilation unit | 753 * @return a fully resolved AST for the compilation unit |
| 729 * See [resolveCompilationUnit]. | 754 * See [resolveCompilationUnit]. |
| 730 */ | 755 */ |
| 731 CompilationUnit getResolvedCompilationUnit2(Source unitSource, | 756 CompilationUnit getResolvedCompilationUnit2(Source unitSource, |
| 732 Source librarySource); | 757 Source librarySource); |
| 733 | 758 |
| 734 /** | 759 /** |
| 760 * Return a future which will be completed with the fully resolved AST for a | |
| 761 * single compilation unit within the given library, once that AST is up to | |
| 762 * date. | |
| 763 * | |
| 764 * If the resolved AST can't be computed for some reason, the future will be | |
| 765 * completed with an error. One possible error is AnalysisNotScheduledError, | |
| 766 * which means that the resolved AST can't be computed because the given | |
| 767 * source file is not scheduled to be analyzed within the context of the | |
| 768 * given library. | |
| 769 */ | |
| 770 Future<CompilationUnit> getResolvedCompilationUnitFuture(Source source, | |
|
danrubel
2014/12/12 16:06:15
How do I cancel waiting for this when I realize th
Paul Berry
2014/12/12 17:36:38
As discussed over VC, I'll make a follow-up CL tha
| |
| 771 LibraryElement library); | |
|
scheglov
2014/12/12 03:41:56
It would be slightly easier for clients to get lib
Brian Wilkerson
2014/12/12 15:13:12
In some cases, yes, in some cases no. And it's mor
scheglov
2014/12/12 15:25:09
It's much easier and cheaper for the client to go
Brian Wilkerson
2014/12/12 15:31:42
Right. I'd forgotten that.
Paul Berry
2014/12/12 17:36:38
Good point. Also, in this case, the client alread
| |
| 772 | |
| 773 /** | |
| 735 * Return a fully resolved HTML unit, or `null` if the resolved unit is not al ready | 774 * Return a fully resolved HTML unit, or `null` if the resolved unit is not al ready |
| 736 * computed. | 775 * computed. |
| 737 * | 776 * |
| 738 * @param htmlSource the source of the HTML unit | 777 * @param htmlSource the source of the HTML unit |
| 739 * @return a fully resolved HTML unit | 778 * @return a fully resolved HTML unit |
| 740 * See [resolveHtmlUnit]. | 779 * See [resolveHtmlUnit]. |
| 741 */ | 780 */ |
| 742 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource); | 781 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource); |
| 743 | 782 |
| 744 /** | 783 /** |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 943 * A table mapping the sources known to the context to the information known a bout the source. | 982 * A table mapping the sources known to the context to the information known a bout the source. |
| 944 */ | 983 */ |
| 945 AnalysisCache _cache; | 984 AnalysisCache _cache; |
| 946 | 985 |
| 947 /** | 986 /** |
| 948 * An array containing sources for which data should not be flushed. | 987 * An array containing sources for which data should not be flushed. |
| 949 */ | 988 */ |
| 950 List<Source> _priorityOrder = Source.EMPTY_ARRAY; | 989 List<Source> _priorityOrder = Source.EMPTY_ARRAY; |
| 951 | 990 |
| 952 /** | 991 /** |
| 992 * A map from all sources for which there are futures pending to a list of | |
| 993 * the corresponding PendingFuture objects. These sources will be analyzed | |
| 994 * in the same way as priority sources, except with higher priority. | |
| 995 * | |
| 996 * TODO(paulberry): since the size of this map is not constrained (as it is | |
| 997 * for _priorityOrder), we run the risk of creating an analysis loop if | |
| 998 * re-caching one AST structure causes the AST structure for another source | |
| 999 * with pending futures to be flushed. However, this is unlikely to happen | |
| 1000 * in practice since sources are removed from this hash set as soon as their | |
| 1001 * futures have completed. | |
| 1002 */ | |
| 1003 HashMap<Source, List<PendingFuture>> _pendingFutureSources = | |
| 1004 new HashMap<Source, List<PendingFuture>>(); | |
| 1005 | |
| 1006 /** | |
| 953 * An array containing sources whose AST structure is needed in order to resol ve the next library | 1007 * An array containing sources whose AST structure is needed in order to resol ve the next library |
| 954 * to be resolved. | 1008 * to be resolved. |
| 955 */ | 1009 */ |
| 956 HashSet<Source> _neededForResolution = null; | 1010 HashSet<Source> _neededForResolution = null; |
| 957 | 1011 |
| 958 /** | 1012 /** |
| 959 * A table mapping sources to the change notices that are waiting to be return ed related to that | 1013 * A table mapping sources to the change notices that are waiting to be return ed related to that |
| 960 * source. | 1014 * source. |
| 961 */ | 1015 */ |
| 962 HashMap<Source, ChangeNoticeImpl> _pendingNotices = | 1016 HashMap<Source, ChangeNoticeImpl> _pendingNotices = |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1152 // Look for incremental analysis | 1206 // Look for incremental analysis |
| 1153 // | 1207 // |
| 1154 if (_incrementalAnalysisCache != null && | 1208 if (_incrementalAnalysisCache != null && |
| 1155 _incrementalAnalysisCache.hasWork) { | 1209 _incrementalAnalysisCache.hasWork) { |
| 1156 AnalysisTask task = | 1210 AnalysisTask task = |
| 1157 new IncrementalAnalysisTask(this, _incrementalAnalysisCache); | 1211 new IncrementalAnalysisTask(this, _incrementalAnalysisCache); |
| 1158 _incrementalAnalysisCache = null; | 1212 _incrementalAnalysisCache = null; |
| 1159 return task; | 1213 return task; |
| 1160 } | 1214 } |
| 1161 // | 1215 // |
| 1216 // Look for a source that needs to be analyzed because it has futures | |
| 1217 // pending. | |
| 1218 // | |
| 1219 if (_pendingFutureSources.isNotEmpty) { | |
| 1220 List<Source> sourcesToRemove = <Source>[]; | |
| 1221 AnalysisTask task; | |
| 1222 for (Source source in _pendingFutureSources.keys) { | |
| 1223 SourceEntry sourceEntry = _cache.get(source); | |
| 1224 List<PendingFuture> pendingFutures = _pendingFutureSources[source]; | |
| 1225 for (int i = 0; i < pendingFutures.length; ) { | |
| 1226 if (pendingFutures[i].evaluate(sourceEntry)) { | |
|
Brian Wilkerson
2014/12/12 15:13:12
Could the evaluation of the pending future ever ca
Paul Berry
2014/12/12 17:36:38
You are right in general that it's not safe to mod
| |
| 1227 pendingFutures.removeAt(i); | |
| 1228 } else { | |
| 1229 i++; | |
| 1230 } | |
| 1231 } | |
| 1232 if (pendingFutures.isEmpty) { | |
| 1233 sourcesToRemove.add(source); | |
| 1234 continue; | |
| 1235 } | |
| 1236 AnalysisContextImpl_TaskData taskData = | |
| 1237 _getNextAnalysisTaskForSource(source, sourceEntry, true, hintsEnable d); | |
| 1238 task = taskData.task; | |
| 1239 if (task != null) { | |
| 1240 break; | |
| 1241 } else if (taskData.isBlocked) { | |
| 1242 hasBlockedTask = true; | |
| 1243 } else { | |
| 1244 // There is no more work to do for this task, so forcibly complete | |
| 1245 // all its pending futures. | |
| 1246 for (PendingFuture pendingFuture in pendingFutures) { | |
| 1247 pendingFuture.forciblyComplete(); | |
| 1248 } | |
| 1249 sourcesToRemove.add(source); | |
| 1250 } | |
| 1251 } | |
| 1252 for (Source source in sourcesToRemove) { | |
| 1253 _pendingFutureSources.remove(source); | |
|
Brian Wilkerson
2014/12/12 15:13:12
Could the evaluation of a pending future (on line
Paul Berry
2014/12/12 17:36:38
No, for the same reasons stated above.
| |
| 1254 } | |
| 1255 if (task != null) { | |
| 1256 return task; | |
| 1257 } | |
| 1258 } | |
| 1259 // | |
| 1162 // Look for a priority source that needs to be analyzed. | 1260 // Look for a priority source that needs to be analyzed. |
| 1163 // | 1261 // |
| 1164 int priorityCount = _priorityOrder.length; | 1262 int priorityCount = _priorityOrder.length; |
| 1165 for (int i = 0; i < priorityCount; i++) { | 1263 for (int i = 0; i < priorityCount; i++) { |
| 1166 Source source = _priorityOrder[i]; | 1264 Source source = _priorityOrder[i]; |
| 1167 AnalysisContextImpl_TaskData taskData = | 1265 AnalysisContextImpl_TaskData taskData = |
| 1168 _getNextAnalysisTaskForSource(source, _cache.get(source), true, hintsE nabled); | 1266 _getNextAnalysisTaskForSource(source, _cache.get(source), true, hintsE nabled); |
| 1169 AnalysisTask task = taskData.task; | 1267 AnalysisTask task = taskData.task; |
| 1170 if (task != null) { | 1268 if (task != null) { |
| 1171 return task; | 1269 return task; |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1900 @override | 1998 @override |
| 1901 LibraryElement getLibraryElement(Source source) { | 1999 LibraryElement getLibraryElement(Source source) { |
| 1902 SourceEntry sourceEntry = getReadableSourceEntryOrNull(source); | 2000 SourceEntry sourceEntry = getReadableSourceEntryOrNull(source); |
| 1903 if (sourceEntry is DartEntry) { | 2001 if (sourceEntry is DartEntry) { |
| 1904 return sourceEntry.getValue(DartEntry.ELEMENT); | 2002 return sourceEntry.getValue(DartEntry.ELEMENT); |
| 1905 } | 2003 } |
| 1906 return null; | 2004 return null; |
| 1907 } | 2005 } |
| 1908 | 2006 |
| 1909 @override | 2007 @override |
| 2008 Future<LibraryElement> getLibraryElementFuture(Source source) { | |
| 2009 return _getFuture(source, (SourceEntry sourceEntry) { | |
| 2010 if (sourceEntry is DartEntry) { | |
| 2011 if (sourceEntry.hasErrorState()) { | |
|
Brian Wilkerson
2014/12/12 15:13:12
I think that this should be checking explicitly fo
Paul Berry
2014/12/12 17:36:38
Fair enough. This code is gone now as a result of
| |
| 2012 throw sourceEntry.exception; | |
| 2013 } | |
| 2014 return sourceEntry.getValue(DartEntry.ELEMENT); | |
| 2015 } | |
| 2016 throw new AnalysisNotScheduledError(); | |
| 2017 }); | |
| 2018 } | |
| 2019 | |
| 2020 @override | |
| 1910 LineInfo getLineInfo(Source source) { | 2021 LineInfo getLineInfo(Source source) { |
| 1911 SourceEntry sourceEntry = getReadableSourceEntryOrNull(source); | 2022 SourceEntry sourceEntry = getReadableSourceEntryOrNull(source); |
| 1912 if (sourceEntry != null) { | 2023 if (sourceEntry != null) { |
| 1913 return sourceEntry.getValue(SourceEntry.LINE_INFO); | 2024 return sourceEntry.getValue(SourceEntry.LINE_INFO); |
| 1914 } | 2025 } |
| 1915 return null; | 2026 return null; |
| 1916 } | 2027 } |
| 1917 | 2028 |
| 1918 @override | 2029 @override |
| 1919 int getModificationStamp(Source source) { | 2030 int getModificationStamp(Source source) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1979 SourceEntry sourceEntry = getReadableSourceEntryOrNull(unitSource); | 2090 SourceEntry sourceEntry = getReadableSourceEntryOrNull(unitSource); |
| 1980 if (sourceEntry is DartEntry) { | 2091 if (sourceEntry is DartEntry) { |
| 1981 return sourceEntry.getValueInLibrary( | 2092 return sourceEntry.getValueInLibrary( |
| 1982 DartEntry.RESOLVED_UNIT, | 2093 DartEntry.RESOLVED_UNIT, |
| 1983 librarySource); | 2094 librarySource); |
| 1984 } | 2095 } |
| 1985 return null; | 2096 return null; |
| 1986 } | 2097 } |
| 1987 | 2098 |
| 1988 @override | 2099 @override |
| 2100 Future<CompilationUnit> getResolvedCompilationUnitFuture(Source unitSource, | |
| 2101 LibraryElement library) { | |
| 2102 Source librarySource = library.source; | |
| 2103 return _getFuture(unitSource, (SourceEntry sourceEntry) { | |
| 2104 if (sourceEntry is DartEntry) { | |
| 2105 if (sourceEntry.hasErrorState()) { | |
|
Brian Wilkerson
2014/12/12 15:13:12
Ditto
Paul Berry
2014/12/12 17:36:38
Done.
| |
| 2106 throw sourceEntry.exception; | |
| 2107 } | |
| 2108 return sourceEntry.getValueInLibrary( | |
| 2109 DartEntry.RESOLVED_UNIT, | |
| 2110 librarySource); | |
| 2111 } | |
| 2112 throw new AnalysisNotScheduledError(); | |
| 2113 }); | |
| 2114 } | |
| 2115 | |
| 2116 @override | |
| 1989 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { | 2117 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { |
| 1990 SourceEntry sourceEntry = getReadableSourceEntryOrNull(htmlSource); | 2118 SourceEntry sourceEntry = getReadableSourceEntryOrNull(htmlSource); |
| 1991 if (sourceEntry is HtmlEntry) { | 2119 if (sourceEntry is HtmlEntry) { |
| 1992 HtmlEntry htmlEntry = sourceEntry; | 2120 HtmlEntry htmlEntry = sourceEntry; |
| 1993 return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); | 2121 return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
| 1994 } | 2122 } |
| 1995 return null; | 2123 return null; |
| 1996 } | 2124 } |
| 1997 | 2125 |
| 1998 @override | 2126 @override |
| (...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3512 * resolved | 3640 * resolved |
| 3513 */ | 3641 */ |
| 3514 Object _getDartVerificationData(Source unitSource, Source librarySource, | 3642 Object _getDartVerificationData(Source unitSource, Source librarySource, |
| 3515 DartEntry dartEntry, DataDescriptor descriptor) { | 3643 DartEntry dartEntry, DataDescriptor descriptor) { |
| 3516 dartEntry = | 3644 dartEntry = |
| 3517 _cacheDartVerificationData(unitSource, librarySource, dartEntry, descrip tor); | 3645 _cacheDartVerificationData(unitSource, librarySource, dartEntry, descrip tor); |
| 3518 return dartEntry.getValueInLibrary(descriptor, librarySource); | 3646 return dartEntry.getValueInLibrary(descriptor, librarySource); |
| 3519 } | 3647 } |
| 3520 | 3648 |
| 3521 /** | 3649 /** |
| 3650 * Return a future that will be completed with the result of calling | |
| 3651 * [computeValue]. If [computeValue] returns non-null, the future will be | |
| 3652 * completed immediately with the resulting value. If it returns null, then | |
| 3653 * it will be re-executed in the future, after the next time the cached | |
| 3654 * information for [source] has changed. If [computeValue] throws an | |
| 3655 * exception, the future will fail with that exception. | |
| 3656 * | |
| 3657 * If the [computeValue] still returns null after there is no further | |
| 3658 * analysis to be done for [source], then the future will be completed with | |
| 3659 * the error AnalysisNotScheduledError. | |
| 3660 */ | |
| 3661 Future /*<T>*/ _getFuture(Source source, /*T*/ | |
| 3662 computeValue(SourceEntry sourceEntry)) { | |
| 3663 SourceEntry sourceEntry = getReadableSourceEntryOrNull(source); | |
| 3664 if (sourceEntry == null) { | |
| 3665 return new Future.error(new AnalysisNotScheduledError()); | |
| 3666 } | |
| 3667 PendingFuture pendingFuture = new PendingFuture(computeValue); | |
| 3668 if (!pendingFuture.evaluate(sourceEntry)) { | |
| 3669 _pendingFutureSources.putIfAbsent( | |
| 3670 source, | |
| 3671 () => <PendingFuture>[]).add(pendingFuture); | |
| 3672 } | |
| 3673 return pendingFuture.future; | |
| 3674 } | |
| 3675 | |
| 3676 /** | |
| 3522 * Given a source for an HTML file, return the data represented by the given d escriptor that is | 3677 * Given a source for an HTML file, return the data represented by the given d escriptor that is |
| 3523 * associated with that source, or the given default value if the source is no t an HTML file. This | 3678 * associated with that source, or the given default value if the source is no t an HTML file. This |
| 3524 * method assumes that the data can be produced by parsing the source if it is not already cached. | 3679 * method assumes that the data can be produced by parsing the source if it is not already cached. |
| 3525 * | 3680 * |
| 3526 * <b>Note:</b> This method cannot be used in an async environment. | 3681 * <b>Note:</b> This method cannot be used in an async environment. |
| 3527 * | 3682 * |
| 3528 * @param source the source representing the Dart file | 3683 * @param source the source representing the Dart file |
| 3529 * @param descriptor the descriptor representing the data to be returned | 3684 * @param descriptor the descriptor representing the data to be returned |
| 3530 * @param defaultValue the value to be returned if the source is not an HTML f ile | 3685 * @param defaultValue the value to be returned if the source is not an HTML f ile |
| 3531 * @return the requested data about the given source | 3686 * @return the requested data about the given source |
| (...skipping 2739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6271 * Reports that the given HTML source was resolved in the given context. | 6426 * Reports that the given HTML source was resolved in the given context. |
| 6272 * | 6427 * |
| 6273 * @param context the context in which the source was resolved | 6428 * @param context the context in which the source was resolved |
| 6274 * @param source the source that was resolved | 6429 * @param source the source that was resolved |
| 6275 * @param unit the result of resolving the source in the given context | 6430 * @param unit the result of resolving the source in the given context |
| 6276 */ | 6431 */ |
| 6277 void resolvedHtml(AnalysisContext context, Source source, ht.HtmlUnit unit); | 6432 void resolvedHtml(AnalysisContext context, Source source, ht.HtmlUnit unit); |
| 6278 } | 6433 } |
| 6279 | 6434 |
| 6280 /** | 6435 /** |
| 6436 * Futures returned by [AnalysisContext] for pending analysis results will | |
| 6437 * complete with this error if it is determined that analysis results will | |
| 6438 * never become available (e.g. because the requested source is not subject to | |
| 6439 * analysis, or because the requested source is a part file which is not a part | |
| 6440 * of any known library). | |
| 6441 */ | |
| 6442 class AnalysisNotScheduledError implements Exception { | |
| 6443 } | |
| 6444 | |
| 6445 /** | |
| 6281 * The interface `AnalysisOptions` defines the behavior of objects that provide access to a | 6446 * The interface `AnalysisOptions` defines the behavior of objects that provide access to a |
| 6282 * set of analysis options used to control the behavior of an analysis context. | 6447 * set of analysis options used to control the behavior of an analysis context. |
| 6283 */ | 6448 */ |
| 6284 abstract class AnalysisOptions { | 6449 abstract class AnalysisOptions { |
| 6285 /** | 6450 /** |
| 6286 * Return `true` if analysis is to analyze Angular. | 6451 * Return `true` if analysis is to analyze Angular. |
| 6287 * | 6452 * |
| 6288 * @return `true` if analysis is to analyze Angular | 6453 * @return `true` if analysis is to analyze Angular |
| 6289 */ | 6454 */ |
| 6290 bool get analyzeAngular; | 6455 bool get analyzeAngular; |
| (...skipping 3188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9479 /** | 9644 /** |
| 9480 * Initialize a newly created descriptor to have the given [name] and | 9645 * Initialize a newly created descriptor to have the given [name] and |
| 9481 * [defaultValue]. | 9646 * [defaultValue]. |
| 9482 */ | 9647 */ |
| 9483 DataDescriptor(this._name, [this.defaultValue = null]); | 9648 DataDescriptor(this._name, [this.defaultValue = null]); |
| 9484 | 9649 |
| 9485 @override | 9650 @override |
| 9486 String toString() => _name; | 9651 String toString() => _name; |
| 9487 } | 9652 } |
| 9488 | 9653 |
| 9654 | |
| 9489 /** | 9655 /** |
| 9490 * Instances of the class `DefaultRetentionPolicy` implement a retention policy that will keep | 9656 * Instances of the class `DefaultRetentionPolicy` implement a retention policy that will keep |
| 9491 * AST's in the cache if there is analysis information that needs to be computed for a source, where | 9657 * AST's in the cache if there is analysis information that needs to be computed for a source, where |
| 9492 * the computation is dependent on having the AST. | 9658 * the computation is dependent on having the AST. |
| 9493 */ | 9659 */ |
| 9494 class DefaultRetentionPolicy implements CacheRetentionPolicy { | 9660 class DefaultRetentionPolicy implements CacheRetentionPolicy { |
| 9495 /** | 9661 /** |
| 9496 * An instance of this class that can be shared. | 9662 * An instance of this class that can be shared. |
| 9497 */ | 9663 */ |
| 9498 static DefaultRetentionPolicy POLICY = new DefaultRetentionPolicy(); | 9664 static DefaultRetentionPolicy POLICY = new DefaultRetentionPolicy(); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 9514 if (sourceEntry is DartEntry) { | 9680 if (sourceEntry is DartEntry) { |
| 9515 DartEntry dartEntry = sourceEntry; | 9681 DartEntry dartEntry = sourceEntry; |
| 9516 if (astIsNeeded(dartEntry)) { | 9682 if (astIsNeeded(dartEntry)) { |
| 9517 return RetentionPriority.MEDIUM; | 9683 return RetentionPriority.MEDIUM; |
| 9518 } | 9684 } |
| 9519 } | 9685 } |
| 9520 return RetentionPriority.LOW; | 9686 return RetentionPriority.LOW; |
| 9521 } | 9687 } |
| 9522 } | 9688 } |
| 9523 | 9689 |
| 9524 | |
| 9525 /** | 9690 /** |
| 9526 * Recursively visits [HtmlUnit] and every embedded [Expression]. | 9691 * Recursively visits [HtmlUnit] and every embedded [Expression]. |
| 9527 */ | 9692 */ |
| 9528 abstract class ExpressionVisitor extends ht.RecursiveXmlVisitor<Object> { | 9693 abstract class ExpressionVisitor extends ht.RecursiveXmlVisitor<Object> { |
| 9529 /** | 9694 /** |
| 9530 * Visits the given [Expression]s embedded into tag or attribute. | 9695 * Visits the given [Expression]s embedded into tag or attribute. |
| 9531 * | 9696 * |
| 9532 * @param expression the [Expression] to visit, not `null` | 9697 * @param expression the [Expression] to visit, not `null` |
| 9533 */ | 9698 */ |
| 9534 void visitExpression(Expression expression); | 9699 void visitExpression(Expression expression); |
| (...skipping 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11485 SdkCachePartition partition = _sdkPartitions[sdk]; | 11650 SdkCachePartition partition = _sdkPartitions[sdk]; |
| 11486 if (partition == null) { | 11651 if (partition == null) { |
| 11487 partition = new SdkCachePartition(sdkContext, _DEFAULT_SDK_CACHE_SIZE); | 11652 partition = new SdkCachePartition(sdkContext, _DEFAULT_SDK_CACHE_SIZE); |
| 11488 _sdkPartitions[sdk] = partition; | 11653 _sdkPartitions[sdk] = partition; |
| 11489 } | 11654 } |
| 11490 return partition; | 11655 return partition; |
| 11491 } | 11656 } |
| 11492 } | 11657 } |
| 11493 | 11658 |
| 11494 /** | 11659 /** |
| 11660 * Representation of a pending computation which is based on the results of | |
| 11661 * analysis that may or may not have been completed. | |
| 11662 */ | |
| 11663 class PendingFuture<T> { | |
| 11664 /** | |
| 11665 * The function which implements the computation. | |
| 11666 */ | |
| 11667 final PendingFutureComputer<T> _computeValue; | |
| 11668 | |
| 11669 /** | |
| 11670 * The completer that should be completed once the computation has succeeded. | |
| 11671 */ | |
| 11672 final Completer<T> _completer = new Completer<T>(); | |
| 11673 | |
| 11674 PendingFuture(this._computeValue); | |
| 11675 | |
| 11676 /** | |
| 11677 * Retrieve the future which will be completed when this object is | |
| 11678 * successfully evaluated. | |
| 11679 */ | |
| 11680 Future<T> get future => _completer.future; | |
| 11681 | |
| 11682 /** | |
| 11683 * Execute [_computeValue], passing it the given [sourceEntry], and complete | |
| 11684 * the pending future if it's appropriate to do so. If the pending future is | |
| 11685 * completed by this call, true is returned; otherwise false is returned. | |
| 11686 * | |
| 11687 * Once this function has returned true, it should not be called again. | |
| 11688 */ | |
| 11689 bool evaluate(SourceEntry sourceEntry) { | |
| 11690 assert(!_completer.isCompleted); | |
| 11691 try { | |
| 11692 T result = _computeValue(sourceEntry); | |
| 11693 if (result == null) { | |
| 11694 return false; | |
| 11695 } else { | |
| 11696 _completer.complete(result); | |
| 11697 return true; | |
| 11698 } | |
| 11699 } catch (exception, stackTrace) { | |
| 11700 _completer.completeError(exception, stackTrace); | |
| 11701 return true; | |
| 11702 } | |
| 11703 } | |
| 11704 | |
| 11705 /** | |
| 11706 * No further analysis updates are expected which affect this future, so | |
| 11707 * complete it with an AnalysisNotScheduledError in order to avoid | |
| 11708 * deadlocking the client. | |
| 11709 */ | |
| 11710 void forciblyComplete() { | |
| 11711 _completer.completeError(new AnalysisNotScheduledError()); | |
|
Brian Wilkerson
2014/12/12 15:13:12
Should this be
try {
throw new AnalysisNotSched
Paul Berry
2014/12/12 17:36:38
Good point. Done.
| |
| 11712 } | |
| 11713 } | |
| 11714 | |
| 11715 /** | |
| 11495 * Container with global [AnalysisContext] performance statistics. | 11716 * Container with global [AnalysisContext] performance statistics. |
| 11496 */ | 11717 */ |
| 11497 class PerformanceStatistics { | 11718 class PerformanceStatistics { |
| 11498 /** | 11719 /** |
| 11499 * The [TimeCounter] for time spent in reading files. | 11720 * The [TimeCounter] for time spent in reading files. |
| 11500 */ | 11721 */ |
| 11501 static TimeCounter io = new TimeCounter(); | 11722 static TimeCounter io = new TimeCounter(); |
| 11502 | 11723 |
| 11503 /** | 11724 /** |
| 11504 * The [TimeCounter] for time spent in scanning. | 11725 * The [TimeCounter] for time spent in scanning. |
| (...skipping 2621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14126 | 14347 |
| 14127 @override | 14348 @override |
| 14128 Object visitPolymerTagDartElement(PolymerTagDartElement element) { | 14349 Object visitPolymerTagDartElement(PolymerTagDartElement element) { |
| 14129 if (element.name == PolymerHtmlUnitBuilder_this._elementName) { | 14350 if (element.name == PolymerHtmlUnitBuilder_this._elementName) { |
| 14130 throw new PolymerHtmlUnitBuilder_FoundTagDartElementError( | 14351 throw new PolymerHtmlUnitBuilder_FoundTagDartElementError( |
| 14131 element as PolymerTagDartElementImpl); | 14352 element as PolymerTagDartElementImpl); |
| 14132 } | 14353 } |
| 14133 return null; | 14354 return null; |
| 14134 } | 14355 } |
| 14135 } | 14356 } |
| OLD | NEW |