| 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 19 matching lines...) Expand all Loading... |
| 30 import 'java_engine.dart'; | 30 import 'java_engine.dart'; |
| 31 import 'parser.dart' show Parser, IncrementalParser; | 31 import 'parser.dart' show Parser, IncrementalParser; |
| 32 import 'resolver.dart'; | 32 import 'resolver.dart'; |
| 33 import 'scanner.dart'; | 33 import 'scanner.dart'; |
| 34 import 'sdk.dart' show DartSdk; | 34 import 'sdk.dart' show DartSdk; |
| 35 import 'source.dart'; | 35 import 'source.dart'; |
| 36 import 'utilities_collection.dart'; | 36 import 'utilities_collection.dart'; |
| 37 import 'utilities_general.dart'; | 37 import 'utilities_general.dart'; |
| 38 | 38 |
| 39 /** | 39 /** |
| 40 * Used by [AnalysisOptions] to allow function bodies to be analyzed in some |
| 41 * sources but not others. |
| 42 */ |
| 43 typedef bool AnalyzeFunctionBodiesPredicate(Source source); |
| 44 |
| 45 /** |
| 40 * Type of callback functions used by PendingFuture. Functions of this type | 46 * Type of callback functions used by PendingFuture. Functions of this type |
| 41 * should perform a computation based on the data in [sourceEntry] and return | 47 * should perform a computation based on the data in [sourceEntry] and return |
| 42 * it. If the computation can't be performed yet because more analysis is | 48 * it. If the computation can't be performed yet because more analysis is |
| 43 * needed, null should be returned. | 49 * needed, null should be returned. |
| 44 * | 50 * |
| 45 * The function may also throw an exception, in which case the corresponding | 51 * The function may also throw an exception, in which case the corresponding |
| 46 * future will be completed with failure. | 52 * future will be completed with failure. |
| 47 * | 53 * |
| 48 * Since this function is called while the state of analysis is being updated, | 54 * Since this function is called while the state of analysis is being updated, |
| 49 * it should be free of side effects so that it doesn't cause reentrant | 55 * it should be free of side effects so that it doesn't cause reentrant |
| (...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 _onSourcesChangedController = | 1109 _onSourcesChangedController = |
| 1104 new StreamController<SourcesChangedEvent>.broadcast(); | 1110 new StreamController<SourcesChangedEvent>.broadcast(); |
| 1105 } | 1111 } |
| 1106 | 1112 |
| 1107 @override | 1113 @override |
| 1108 AnalysisOptions get analysisOptions => _options; | 1114 AnalysisOptions get analysisOptions => _options; |
| 1109 | 1115 |
| 1110 @override | 1116 @override |
| 1111 void set analysisOptions(AnalysisOptions options) { | 1117 void set analysisOptions(AnalysisOptions options) { |
| 1112 bool needsRecompute = | 1118 bool needsRecompute = |
| 1113 this._options.analyzeFunctionBodies != options.analyzeFunctionBodies || | 1119 this._options.analyzeFunctionBodiesPredicate != |
| 1120 options.analyzeFunctionBodiesPredicate || |
| 1114 this._options.generateSdkErrors != options.generateSdkErrors || | 1121 this._options.generateSdkErrors != options.generateSdkErrors || |
| 1115 this._options.dart2jsHint != options.dart2jsHint || | 1122 this._options.dart2jsHint != options.dart2jsHint || |
| 1116 (this._options.hint && !options.hint) || | 1123 (this._options.hint && !options.hint) || |
| 1117 this._options.preserveComments != options.preserveComments; | 1124 this._options.preserveComments != options.preserveComments; |
| 1118 int cacheSize = options.cacheSize; | 1125 int cacheSize = options.cacheSize; |
| 1119 if (this._options.cacheSize != cacheSize) { | 1126 if (this._options.cacheSize != cacheSize) { |
| 1120 this._options.cacheSize = cacheSize; | 1127 this._options.cacheSize = cacheSize; |
| 1121 //cache.setMaxCacheSize(cacheSize); | 1128 //cache.setMaxCacheSize(cacheSize); |
| 1122 _privatePartition.maxCacheSize = cacheSize; | 1129 _privatePartition.maxCacheSize = cacheSize; |
| 1123 // | 1130 // |
| 1124 // Cap the size of the priority list to being less than the cache size. | 1131 // Cap the size of the priority list to being less than the cache size. |
| 1125 // Failure to do so can result in an infinite loop in | 1132 // Failure to do so can result in an infinite loop in |
| 1126 // performAnalysisTask() because re-caching one AST structure | 1133 // performAnalysisTask() because re-caching one AST structure |
| 1127 // can cause another priority source's AST structure to be flushed. | 1134 // can cause another priority source's AST structure to be flushed. |
| 1128 // | 1135 // |
| 1129 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; | 1136 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; |
| 1130 if (_priorityOrder.length > maxPriorityOrderSize) { | 1137 if (_priorityOrder.length > maxPriorityOrderSize) { |
| 1131 List<Source> newPriorityOrder = new List<Source>(maxPriorityOrderSize); | 1138 List<Source> newPriorityOrder = new List<Source>(maxPriorityOrderSize); |
| 1132 JavaSystem.arraycopy( | 1139 JavaSystem.arraycopy( |
| 1133 _priorityOrder, | 1140 _priorityOrder, |
| 1134 0, | 1141 0, |
| 1135 newPriorityOrder, | 1142 newPriorityOrder, |
| 1136 0, | 1143 0, |
| 1137 maxPriorityOrderSize); | 1144 maxPriorityOrderSize); |
| 1138 _priorityOrder = newPriorityOrder; | 1145 _priorityOrder = newPriorityOrder; |
| 1139 } | 1146 } |
| 1140 } | 1147 } |
| 1141 this._options.analyzeFunctionBodies = options.analyzeFunctionBodies; | 1148 this._options.analyzeFunctionBodiesPredicate = |
| 1149 options.analyzeFunctionBodiesPredicate; |
| 1142 this._options.generateSdkErrors = options.generateSdkErrors; | 1150 this._options.generateSdkErrors = options.generateSdkErrors; |
| 1143 this._options.dart2jsHint = options.dart2jsHint; | 1151 this._options.dart2jsHint = options.dart2jsHint; |
| 1144 this._options.hint = options.hint; | 1152 this._options.hint = options.hint; |
| 1145 this._options.incremental = options.incremental; | 1153 this._options.incremental = options.incremental; |
| 1146 this._options.incrementalApi = options.incrementalApi; | 1154 this._options.incrementalApi = options.incrementalApi; |
| 1147 this._options.incrementalValidation = options.incrementalValidation; | 1155 this._options.incrementalValidation = options.incrementalValidation; |
| 1148 this._options.lint = options.lint; | 1156 this._options.lint = options.lint; |
| 1149 this._options.preserveComments = options.preserveComments; | 1157 this._options.preserveComments = options.preserveComments; |
| 1150 _generateSdkErrors = options.generateSdkErrors; | 1158 _generateSdkErrors = options.generateSdkErrors; |
| 1151 if (needsRecompute) { | 1159 if (needsRecompute) { |
| (...skipping 5348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6500 */ | 6508 */ |
| 6501 class AnalysisNotScheduledError implements Exception { | 6509 class AnalysisNotScheduledError implements Exception { |
| 6502 } | 6510 } |
| 6503 | 6511 |
| 6504 /** | 6512 /** |
| 6505 * The interface `AnalysisOptions` defines the behavior of objects that provide
access to a | 6513 * The interface `AnalysisOptions` defines the behavior of objects that provide
access to a |
| 6506 * set of analysis options used to control the behavior of an analysis context. | 6514 * set of analysis options used to control the behavior of an analysis context. |
| 6507 */ | 6515 */ |
| 6508 abstract class AnalysisOptions { | 6516 abstract class AnalysisOptions { |
| 6509 /** | 6517 /** |
| 6510 * Return `true` if analysis is to parse and analyze function bodies. | 6518 * If analysis is to parse and analyze all function bodies, return `true`. |
| 6519 * If analysis is to skip all function bodies, return `false`. If analysis |
| 6520 * is to parse and analyze function bodies in some sources and not in others, |
| 6521 * throw an exception. |
| 6511 * | 6522 * |
| 6512 * @return `true` if analysis is to parse and analyzer function bodies | 6523 * This getter is deprecated; consider using [analyzeFunctionBodiesPredicate] |
| 6524 * instead. |
| 6513 */ | 6525 */ |
| 6526 @deprecated |
| 6514 bool get analyzeFunctionBodies; | 6527 bool get analyzeFunctionBodies; |
| 6515 | 6528 |
| 6516 /** | 6529 /** |
| 6530 * Function that returns `true` if analysis is to parse and analyze function |
| 6531 * bodies for a given source. |
| 6532 */ |
| 6533 AnalyzeFunctionBodiesPredicate get analyzeFunctionBodiesPredicate; |
| 6534 |
| 6535 /** |
| 6517 * Return the maximum number of sources for which AST structures should be kep
t in the cache. | 6536 * Return the maximum number of sources for which AST structures should be kep
t in the cache. |
| 6518 * | 6537 * |
| 6519 * @return the maximum number of sources for which AST structures should be ke
pt in the cache | 6538 * @return the maximum number of sources for which AST structures should be ke
pt in the cache |
| 6520 */ | 6539 */ |
| 6521 int get cacheSize; | 6540 int get cacheSize; |
| 6522 | 6541 |
| 6523 /** | 6542 /** |
| 6524 * Return `true` if analysis is to generate dart2js related hint results. | 6543 * Return `true` if analysis is to generate dart2js related hint results. |
| 6525 * | 6544 * |
| 6526 * @return `true` if analysis is to generate dart2js related hint results | 6545 * @return `true` if analysis is to generate dart2js related hint results |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6615 @deprecated | 6634 @deprecated |
| 6616 static bool DEFAULT_ENABLE_DEFERRED_LOADING = true; | 6635 static bool DEFAULT_ENABLE_DEFERRED_LOADING = true; |
| 6617 | 6636 |
| 6618 /** | 6637 /** |
| 6619 * The default value for enabling enum support. | 6638 * The default value for enabling enum support. |
| 6620 */ | 6639 */ |
| 6621 @deprecated | 6640 @deprecated |
| 6622 static bool DEFAULT_ENABLE_ENUM = false; | 6641 static bool DEFAULT_ENABLE_ENUM = false; |
| 6623 | 6642 |
| 6624 /** | 6643 /** |
| 6625 * A flag indicating whether analysis is to parse and analyze function bodies. | 6644 * A predicate indicating whether analysis is to parse and analyze function |
| 6645 * bodies. |
| 6626 */ | 6646 */ |
| 6627 bool analyzeFunctionBodies = true; | 6647 AnalyzeFunctionBodiesPredicate _analyzeFunctionBodiesPredicate = |
| 6648 _analyzeAllFunctionBodies; |
| 6628 | 6649 |
| 6629 /** | 6650 /** |
| 6630 * The maximum number of sources for which AST structures should be kept in th
e cache. | 6651 * The maximum number of sources for which AST structures should be kept in th
e cache. |
| 6631 */ | 6652 */ |
| 6632 int cacheSize = DEFAULT_CACHE_SIZE; | 6653 int cacheSize = DEFAULT_CACHE_SIZE; |
| 6633 | 6654 |
| 6634 /** | 6655 /** |
| 6635 * A flag indicating whether analysis is to generate dart2js related hint resu
lts. | 6656 * A flag indicating whether analysis is to generate dart2js related hint resu
lts. |
| 6636 */ | 6657 */ |
| 6637 bool dart2jsHint = true; | 6658 bool dart2jsHint = true; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6680 */ | 6701 */ |
| 6681 AnalysisOptionsImpl(); | 6702 AnalysisOptionsImpl(); |
| 6682 | 6703 |
| 6683 /** | 6704 /** |
| 6684 * Initialize a newly created set of analysis options to have the same values
as those in the | 6705 * Initialize a newly created set of analysis options to have the same values
as those in the |
| 6685 * given set of analysis options. | 6706 * given set of analysis options. |
| 6686 * | 6707 * |
| 6687 * @param options the analysis options whose values are being copied | 6708 * @param options the analysis options whose values are being copied |
| 6688 */ | 6709 */ |
| 6689 AnalysisOptionsImpl.con1(AnalysisOptions options) { | 6710 AnalysisOptionsImpl.con1(AnalysisOptions options) { |
| 6690 analyzeFunctionBodies = options.analyzeFunctionBodies; | 6711 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; |
| 6691 cacheSize = options.cacheSize; | 6712 cacheSize = options.cacheSize; |
| 6692 dart2jsHint = options.dart2jsHint; | 6713 dart2jsHint = options.dart2jsHint; |
| 6693 _generateSdkErrors = options.generateSdkErrors; | 6714 _generateSdkErrors = options.generateSdkErrors; |
| 6694 hint = options.hint; | 6715 hint = options.hint; |
| 6695 incremental = options.incremental; | 6716 incremental = options.incremental; |
| 6696 incrementalApi = options.incrementalApi; | 6717 incrementalApi = options.incrementalApi; |
| 6697 incrementalValidation = options.incrementalValidation; | 6718 incrementalValidation = options.incrementalValidation; |
| 6698 lint = options.lint; | 6719 lint = options.lint; |
| 6699 preserveComments = options.preserveComments; | 6720 preserveComments = options.preserveComments; |
| 6700 } | 6721 } |
| 6701 | 6722 |
| 6723 bool get analyzeFunctionBodies { |
| 6724 if (identical(analyzeFunctionBodiesPredicate, _analyzeAllFunctionBodies)) { |
| 6725 return true; |
| 6726 } else if (identical( |
| 6727 analyzeFunctionBodiesPredicate, |
| 6728 _analyzeNoFunctionBodies)) { |
| 6729 return false; |
| 6730 } else { |
| 6731 throw new StateError('analyzeFunctionBodiesPredicate in use'); |
| 6732 } |
| 6733 } |
| 6734 |
| 6735 set analyzeFunctionBodies(bool value) { |
| 6736 if (value) { |
| 6737 analyzeFunctionBodiesPredicate = _analyzeAllFunctionBodies; |
| 6738 } else { |
| 6739 analyzeFunctionBodiesPredicate = _analyzeNoFunctionBodies; |
| 6740 } |
| 6741 } |
| 6742 |
| 6743 @override |
| 6744 AnalyzeFunctionBodiesPredicate get analyzeFunctionBodiesPredicate => |
| 6745 _analyzeFunctionBodiesPredicate; |
| 6746 |
| 6747 set analyzeFunctionBodiesPredicate(AnalyzeFunctionBodiesPredicate value) { |
| 6748 if (value == null) { |
| 6749 throw new ArgumentError.notNull('analyzeFunctionBodiesPredicate'); |
| 6750 } |
| 6751 _analyzeFunctionBodiesPredicate = value; |
| 6752 } |
| 6753 |
| 6702 @deprecated | 6754 @deprecated |
| 6703 @override | 6755 @override |
| 6704 bool get enableAsync => true; | 6756 bool get enableAsync => true; |
| 6705 | 6757 |
| 6706 @deprecated | 6758 @deprecated |
| 6707 void set enableAsync(bool enable) { | 6759 void set enableAsync(bool enable) { |
| 6708 // Async support cannot be disabled | 6760 // Async support cannot be disabled |
| 6709 } | 6761 } |
| 6710 | 6762 |
| 6711 @deprecated | 6763 @deprecated |
| (...skipping 20 matching lines...) Expand all Loading... |
| 6732 /** | 6784 /** |
| 6733 * Set whether errors, warnings and hints should be generated for sources in t
he SDK to match the | 6785 * Set whether errors, warnings and hints should be generated for sources in t
he SDK to match the |
| 6734 * given value. | 6786 * given value. |
| 6735 * | 6787 * |
| 6736 * @param generate `true` if errors, warnings and hints should be generated fo
r sources in | 6788 * @param generate `true` if errors, warnings and hints should be generated fo
r sources in |
| 6737 * the SDK | 6789 * the SDK |
| 6738 */ | 6790 */ |
| 6739 void set generateSdkErrors(bool generate) { | 6791 void set generateSdkErrors(bool generate) { |
| 6740 _generateSdkErrors = generate; | 6792 _generateSdkErrors = generate; |
| 6741 } | 6793 } |
| 6794 |
| 6795 /** |
| 6796 * Predicate used for [analyzeFunctionBodiesPredicate] when |
| 6797 * [analyzeFunctionBodies] is set to `true`. |
| 6798 */ |
| 6799 static bool _analyzeAllFunctionBodies(Source _) => true; |
| 6800 |
| 6801 /** |
| 6802 * Predicate used for [analyzeFunctionBodiesPredicate] when |
| 6803 * [analyzeFunctionBodies] is set to `false`. |
| 6804 */ |
| 6805 static bool _analyzeNoFunctionBodies(Source _) => false; |
| 6742 } | 6806 } |
| 6743 | 6807 |
| 6744 /** | 6808 /** |
| 6745 * Instances of the class `AnalysisResult` | 6809 * Instances of the class `AnalysisResult` |
| 6746 */ | 6810 */ |
| 6747 class AnalysisResult { | 6811 class AnalysisResult { |
| 6748 /** | 6812 /** |
| 6749 * The change notices associated with this result, or `null` if there were no
changes and | 6813 * The change notices associated with this result, or `null` if there were no
changes and |
| 6750 * there is no more work to be done. | 6814 * there is no more work to be done. |
| 6751 */ | 6815 */ |
| (...skipping 3352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10104 | 10168 |
| 10105 @override | 10169 @override |
| 10106 void internalPerform() { | 10170 void internalPerform() { |
| 10107 // | 10171 // |
| 10108 // Then parse the token stream. | 10172 // Then parse the token stream. |
| 10109 // | 10173 // |
| 10110 PerformanceStatistics.parse.makeCurrentWhile(() { | 10174 PerformanceStatistics.parse.makeCurrentWhile(() { |
| 10111 RecordingErrorListener errorListener = new RecordingErrorListener(); | 10175 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 10112 Parser parser = new Parser(source, errorListener); | 10176 Parser parser = new Parser(source, errorListener); |
| 10113 AnalysisOptions options = context.analysisOptions; | 10177 AnalysisOptions options = context.analysisOptions; |
| 10114 parser.parseFunctionBodies = options.analyzeFunctionBodies; | 10178 parser.parseFunctionBodies = |
| 10179 options.analyzeFunctionBodiesPredicate(source); |
| 10115 _unit = parser.parseCompilationUnit(_tokenStream); | 10180 _unit = parser.parseCompilationUnit(_tokenStream); |
| 10116 _unit.lineInfo = lineInfo; | 10181 _unit.lineInfo = lineInfo; |
| 10117 AnalysisContext analysisContext = context; | 10182 AnalysisContext analysisContext = context; |
| 10118 for (Directive directive in _unit.directives) { | 10183 for (Directive directive in _unit.directives) { |
| 10119 if (directive is PartOfDirective) { | 10184 if (directive is PartOfDirective) { |
| 10120 _containsPartOfDirective = true; | 10185 _containsPartOfDirective = true; |
| 10121 } else { | 10186 } else { |
| 10122 _containsNonPartOfDirective = true; | 10187 _containsNonPartOfDirective = true; |
| 10123 if (directive is UriBasedDirective) { | 10188 if (directive is UriBasedDirective) { |
| 10124 Source referencedSource = | 10189 Source referencedSource = |
| (...skipping 2368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12493 if (element.id == _id) { | 12558 if (element.id == _id) { |
| 12494 result = element; | 12559 result = element; |
| 12495 throw new _ElementByIdFinderException(); | 12560 throw new _ElementByIdFinderException(); |
| 12496 } | 12561 } |
| 12497 super.visitElement(element); | 12562 super.visitElement(element); |
| 12498 } | 12563 } |
| 12499 } | 12564 } |
| 12500 | 12565 |
| 12501 class _ElementByIdFinderException { | 12566 class _ElementByIdFinderException { |
| 12502 } | 12567 } |
| OLD | NEW |