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 20 matching lines...) Expand all Loading... | |
| 31 import 'java_engine.dart'; | 31 import 'java_engine.dart'; |
| 32 import 'parser.dart' show Parser, IncrementalParser; | 32 import 'parser.dart' show Parser, IncrementalParser; |
| 33 import 'resolver.dart'; | 33 import 'resolver.dart'; |
| 34 import 'scanner.dart'; | 34 import 'scanner.dart'; |
| 35 import 'sdk.dart' show DartSdk; | 35 import 'sdk.dart' show DartSdk; |
| 36 import 'source.dart'; | 36 import 'source.dart'; |
| 37 import 'utilities_collection.dart'; | 37 import 'utilities_collection.dart'; |
| 38 import 'utilities_general.dart'; | 38 import 'utilities_general.dart'; |
| 39 | 39 |
| 40 /** | 40 /** |
| 41 * Used by [AnalysisOptions] to allow function bodies to be analyzed in some | |
| 42 * sources but not others. | |
| 43 */ | |
| 44 typedef bool AnalyzeFunctionBodiesPredicate(Source source); | |
| 45 | |
| 46 /** | |
| 41 * Type of callback functions used by PendingFuture. Functions of this type | 47 * Type of callback functions used by PendingFuture. Functions of this type |
| 42 * should perform a computation based on the data in [sourceEntry] and return | 48 * should perform a computation based on the data in [sourceEntry] and return |
| 43 * it. If the computation can't be performed yet because more analysis is | 49 * it. If the computation can't be performed yet because more analysis is |
| 44 * needed, null should be returned. | 50 * needed, null should be returned. |
| 45 * | 51 * |
| 46 * The function may also throw an exception, in which case the corresponding | 52 * The function may also throw an exception, in which case the corresponding |
| 47 * future will be completed with failure. | 53 * future will be completed with failure. |
| 48 * | 54 * |
| 49 * Since this function is called while the state of analysis is being updated, | 55 * Since this function is called while the state of analysis is being updated, |
| 50 * it should be free of side effects so that it doesn't cause reentrant | 56 * it should be free of side effects so that it doesn't cause reentrant |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1110 _onSourcesChangedController = | 1116 _onSourcesChangedController = |
| 1111 new StreamController<SourcesChangedEvent>.broadcast(); | 1117 new StreamController<SourcesChangedEvent>.broadcast(); |
| 1112 } | 1118 } |
| 1113 | 1119 |
| 1114 @override | 1120 @override |
| 1115 AnalysisOptions get analysisOptions => _options; | 1121 AnalysisOptions get analysisOptions => _options; |
| 1116 | 1122 |
| 1117 @override | 1123 @override |
| 1118 void set analysisOptions(AnalysisOptions options) { | 1124 void set analysisOptions(AnalysisOptions options) { |
| 1119 bool needsRecompute = | 1125 bool needsRecompute = |
| 1120 this._options.analyzeFunctionBodies != options.analyzeFunctionBodies || | 1126 this._options.analyzeFunctionBodiesPredicate != |
| 1127 options.analyzeFunctionBodiesPredicate || | |
| 1121 this._options.generateSdkErrors != options.generateSdkErrors || | 1128 this._options.generateSdkErrors != options.generateSdkErrors || |
| 1122 this._options.dart2jsHint != options.dart2jsHint || | 1129 this._options.dart2jsHint != options.dart2jsHint || |
| 1123 (this._options.hint && !options.hint) || | 1130 (this._options.hint && !options.hint) || |
| 1124 this._options.preserveComments != options.preserveComments; | 1131 this._options.preserveComments != options.preserveComments; |
| 1125 int cacheSize = options.cacheSize; | 1132 int cacheSize = options.cacheSize; |
| 1126 if (this._options.cacheSize != cacheSize) { | 1133 if (this._options.cacheSize != cacheSize) { |
| 1127 this._options.cacheSize = cacheSize; | 1134 this._options.cacheSize = cacheSize; |
| 1128 //cache.setMaxCacheSize(cacheSize); | 1135 //cache.setMaxCacheSize(cacheSize); |
| 1129 _privatePartition.maxCacheSize = cacheSize; | 1136 _privatePartition.maxCacheSize = cacheSize; |
| 1130 // | 1137 // |
| 1131 // Cap the size of the priority list to being less than the cache size. | 1138 // Cap the size of the priority list to being less than the cache size. |
| 1132 // Failure to do so can result in an infinite loop in | 1139 // Failure to do so can result in an infinite loop in |
| 1133 // performAnalysisTask() because re-caching one AST structure | 1140 // performAnalysisTask() because re-caching one AST structure |
| 1134 // can cause another priority source's AST structure to be flushed. | 1141 // can cause another priority source's AST structure to be flushed. |
| 1135 // | 1142 // |
| 1136 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; | 1143 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; |
| 1137 if (_priorityOrder.length > maxPriorityOrderSize) { | 1144 if (_priorityOrder.length > maxPriorityOrderSize) { |
| 1138 List<Source> newPriorityOrder = new List<Source>(maxPriorityOrderSize); | 1145 List<Source> newPriorityOrder = new List<Source>(maxPriorityOrderSize); |
| 1139 JavaSystem.arraycopy( | 1146 JavaSystem.arraycopy( |
| 1140 _priorityOrder, | 1147 _priorityOrder, |
| 1141 0, | 1148 0, |
| 1142 newPriorityOrder, | 1149 newPriorityOrder, |
| 1143 0, | 1150 0, |
| 1144 maxPriorityOrderSize); | 1151 maxPriorityOrderSize); |
| 1145 _priorityOrder = newPriorityOrder; | 1152 _priorityOrder = newPriorityOrder; |
| 1146 } | 1153 } |
| 1147 } | 1154 } |
| 1148 this._options.analyzeFunctionBodies = options.analyzeFunctionBodies; | 1155 this._options.analyzeFunctionBodiesPredicate = |
| 1156 options.analyzeFunctionBodiesPredicate; | |
| 1149 this._options.generateSdkErrors = options.generateSdkErrors; | 1157 this._options.generateSdkErrors = options.generateSdkErrors; |
| 1150 this._options.dart2jsHint = options.dart2jsHint; | 1158 this._options.dart2jsHint = options.dart2jsHint; |
| 1151 this._options.hint = options.hint; | 1159 this._options.hint = options.hint; |
| 1152 this._options.incremental = options.incremental; | 1160 this._options.incremental = options.incremental; |
| 1153 this._options.incrementalApi = options.incrementalApi; | 1161 this._options.incrementalApi = options.incrementalApi; |
| 1154 this._options.incrementalValidation = options.incrementalValidation; | 1162 this._options.incrementalValidation = options.incrementalValidation; |
| 1155 this._options.lint = options.lint; | 1163 this._options.lint = options.lint; |
| 1156 this._options.preserveComments = options.preserveComments; | 1164 this._options.preserveComments = options.preserveComments; |
| 1157 _generateSdkErrors = options.generateSdkErrors; | 1165 _generateSdkErrors = options.generateSdkErrors; |
| 1158 if (needsRecompute) { | 1166 if (needsRecompute) { |
| (...skipping 5335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6494 */ | 6502 */ |
| 6495 class AnalysisNotScheduledError implements Exception { | 6503 class AnalysisNotScheduledError implements Exception { |
| 6496 } | 6504 } |
| 6497 | 6505 |
| 6498 /** | 6506 /** |
| 6499 * The interface `AnalysisOptions` defines the behavior of objects that provide access to a | 6507 * The interface `AnalysisOptions` defines the behavior of objects that provide access to a |
| 6500 * set of analysis options used to control the behavior of an analysis context. | 6508 * set of analysis options used to control the behavior of an analysis context. |
| 6501 */ | 6509 */ |
| 6502 abstract class AnalysisOptions { | 6510 abstract class AnalysisOptions { |
| 6503 /** | 6511 /** |
| 6504 * Return `true` if analysis is to parse and analyze function bodies. | 6512 * If analysis is to parse and analyze all function bodies, return `true`. |
| 6513 * If analysis is to skip all function bodies, return `false`. If analysis | |
| 6514 * is to parse and analyze function bodies in some sources and not in others, | |
| 6515 * throw an exception. | |
| 6505 * | 6516 * |
| 6506 * @return `true` if analysis is to parse and analyzer function bodies | 6517 * This getter is deprecated; consider using [analyzeFunctionBodiesPredicate] |
| 6518 * instead. | |
| 6507 */ | 6519 */ |
| 6520 @deprecated | |
| 6508 bool get analyzeFunctionBodies; | 6521 bool get analyzeFunctionBodies; |
| 6509 | 6522 |
| 6510 /** | 6523 /** |
| 6524 * Function that returns `true` if analysis is to parse and analyze function | |
| 6525 * bodies for a given source. | |
| 6526 */ | |
| 6527 AnalyzeFunctionBodiesPredicate get analyzeFunctionBodiesPredicate; | |
| 6528 | |
| 6529 /** | |
| 6511 * Return the maximum number of sources for which AST structures should be kep t in the cache. | 6530 * Return the maximum number of sources for which AST structures should be kep t in the cache. |
| 6512 * | 6531 * |
| 6513 * @return the maximum number of sources for which AST structures should be ke pt in the cache | 6532 * @return the maximum number of sources for which AST structures should be ke pt in the cache |
| 6514 */ | 6533 */ |
| 6515 int get cacheSize; | 6534 int get cacheSize; |
| 6516 | 6535 |
| 6517 /** | 6536 /** |
| 6518 * Return `true` if analysis is to generate dart2js related hint results. | 6537 * Return `true` if analysis is to generate dart2js related hint results. |
| 6519 * | 6538 * |
| 6520 * @return `true` if analysis is to generate dart2js related hint results | 6539 * @return `true` if analysis is to generate dart2js related hint results |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6609 @deprecated | 6628 @deprecated |
| 6610 static bool DEFAULT_ENABLE_DEFERRED_LOADING = true; | 6629 static bool DEFAULT_ENABLE_DEFERRED_LOADING = true; |
| 6611 | 6630 |
| 6612 /** | 6631 /** |
| 6613 * The default value for enabling enum support. | 6632 * The default value for enabling enum support. |
| 6614 */ | 6633 */ |
| 6615 @deprecated | 6634 @deprecated |
| 6616 static bool DEFAULT_ENABLE_ENUM = false; | 6635 static bool DEFAULT_ENABLE_ENUM = false; |
| 6617 | 6636 |
| 6618 /** | 6637 /** |
| 6619 * A flag indicating whether analysis is to parse and analyze function bodies. | 6638 * A predicate indicating whether analysis is to parse and analyze function |
| 6639 * bodies. | |
| 6620 */ | 6640 */ |
| 6621 bool analyzeFunctionBodies = true; | 6641 AnalyzeFunctionBodiesPredicate analyzeFunctionBodiesPredicate = |
|
Brian Wilkerson
2015/02/27 23:52:05
For safety, we should have a setter that replaces
Paul Berry
2015/03/02 19:09:45
I don't think there's any benefit in auto-converti
| |
| 6642 _analyzeAllFunctionBodies; | |
| 6622 | 6643 |
| 6623 /** | 6644 /** |
| 6624 * The maximum number of sources for which AST structures should be kept in th e cache. | 6645 * The maximum number of sources for which AST structures should be kept in th e cache. |
| 6625 */ | 6646 */ |
| 6626 int cacheSize = DEFAULT_CACHE_SIZE; | 6647 int cacheSize = DEFAULT_CACHE_SIZE; |
| 6627 | 6648 |
| 6628 /** | 6649 /** |
| 6629 * A flag indicating whether analysis is to generate dart2js related hint resu lts. | 6650 * A flag indicating whether analysis is to generate dart2js related hint resu lts. |
| 6630 */ | 6651 */ |
| 6631 bool dart2jsHint = true; | 6652 bool dart2jsHint = true; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6674 */ | 6695 */ |
| 6675 AnalysisOptionsImpl(); | 6696 AnalysisOptionsImpl(); |
| 6676 | 6697 |
| 6677 /** | 6698 /** |
| 6678 * Initialize a newly created set of analysis options to have the same values as those in the | 6699 * Initialize a newly created set of analysis options to have the same values as those in the |
| 6679 * given set of analysis options. | 6700 * given set of analysis options. |
| 6680 * | 6701 * |
| 6681 * @param options the analysis options whose values are being copied | 6702 * @param options the analysis options whose values are being copied |
| 6682 */ | 6703 */ |
| 6683 AnalysisOptionsImpl.con1(AnalysisOptions options) { | 6704 AnalysisOptionsImpl.con1(AnalysisOptions options) { |
| 6684 analyzeFunctionBodies = options.analyzeFunctionBodies; | 6705 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; |
| 6685 cacheSize = options.cacheSize; | 6706 cacheSize = options.cacheSize; |
| 6686 dart2jsHint = options.dart2jsHint; | 6707 dart2jsHint = options.dart2jsHint; |
| 6687 _generateSdkErrors = options.generateSdkErrors; | 6708 _generateSdkErrors = options.generateSdkErrors; |
| 6688 hint = options.hint; | 6709 hint = options.hint; |
| 6689 incremental = options.incremental; | 6710 incremental = options.incremental; |
| 6690 incrementalApi = options.incrementalApi; | 6711 incrementalApi = options.incrementalApi; |
| 6691 incrementalValidation = options.incrementalValidation; | 6712 incrementalValidation = options.incrementalValidation; |
| 6692 lint = options.lint; | 6713 lint = options.lint; |
| 6693 preserveComments = options.preserveComments; | 6714 preserveComments = options.preserveComments; |
| 6694 } | 6715 } |
| 6695 | 6716 |
| 6717 bool get analyzeFunctionBodies { | |
| 6718 if (identical(analyzeFunctionBodiesPredicate, _analyzeAllFunctionBodies)) { | |
| 6719 return true; | |
| 6720 } else if (identical( | |
| 6721 analyzeFunctionBodiesPredicate, | |
| 6722 _analyzeNoFunctionBodies)) { | |
| 6723 return false; | |
| 6724 } else { | |
| 6725 throw new StateError('analyzeFunctionBodiesPredicate in use'); | |
| 6726 } | |
| 6727 } | |
| 6728 | |
| 6729 set analyzeFunctionBodies(bool value) { | |
| 6730 if (value) { | |
| 6731 analyzeFunctionBodiesPredicate = _analyzeAllFunctionBodies; | |
| 6732 } else { | |
| 6733 analyzeFunctionBodiesPredicate = _analyzeNoFunctionBodies; | |
| 6734 } | |
| 6735 } | |
| 6736 | |
| 6696 @deprecated | 6737 @deprecated |
| 6697 @override | 6738 @override |
| 6698 bool get enableAsync => true; | 6739 bool get enableAsync => true; |
| 6699 | 6740 |
| 6700 @deprecated | 6741 @deprecated |
| 6701 void set enableAsync(bool enable) { | 6742 void set enableAsync(bool enable) { |
| 6702 // Async support cannot be disabled | 6743 // Async support cannot be disabled |
| 6703 } | 6744 } |
| 6704 | 6745 |
| 6705 @deprecated | 6746 @deprecated |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 6726 /** | 6767 /** |
| 6727 * Set whether errors, warnings and hints should be generated for sources in t he SDK to match the | 6768 * Set whether errors, warnings and hints should be generated for sources in t he SDK to match the |
| 6728 * given value. | 6769 * given value. |
| 6729 * | 6770 * |
| 6730 * @param generate `true` if errors, warnings and hints should be generated fo r sources in | 6771 * @param generate `true` if errors, warnings and hints should be generated fo r sources in |
| 6731 * the SDK | 6772 * the SDK |
| 6732 */ | 6773 */ |
| 6733 void set generateSdkErrors(bool generate) { | 6774 void set generateSdkErrors(bool generate) { |
| 6734 _generateSdkErrors = generate; | 6775 _generateSdkErrors = generate; |
| 6735 } | 6776 } |
| 6777 | |
| 6778 /** | |
| 6779 * Predicate used for [analyzeFunctionBodiesPredicate] when | |
| 6780 * [analyzeFunctionBodies] is set to `true`. | |
| 6781 */ | |
| 6782 static bool _analyzeAllFunctionBodies(Source _) => true; | |
| 6783 | |
| 6784 /** | |
| 6785 * Predicate used for [analyzeFunctionBodiesPredicate] when | |
| 6786 * [analyzeFunctionBodies] is set to `false`. | |
| 6787 */ | |
| 6788 static bool _analyzeNoFunctionBodies(Source _) => false; | |
| 6736 } | 6789 } |
| 6737 | 6790 |
| 6738 /** | 6791 /** |
| 6739 * Instances of the class `AnalysisResult` | 6792 * Instances of the class `AnalysisResult` |
| 6740 */ | 6793 */ |
| 6741 class AnalysisResult { | 6794 class AnalysisResult { |
| 6742 /** | 6795 /** |
| 6743 * The change notices associated with this result, or `null` if there were no changes and | 6796 * The change notices associated with this result, or `null` if there were no changes and |
| 6744 * there is no more work to be done. | 6797 * there is no more work to be done. |
| 6745 */ | 6798 */ |
| (...skipping 3352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10098 | 10151 |
| 10099 @override | 10152 @override |
| 10100 void internalPerform() { | 10153 void internalPerform() { |
| 10101 // | 10154 // |
| 10102 // Then parse the token stream. | 10155 // Then parse the token stream. |
| 10103 // | 10156 // |
| 10104 PerformanceStatistics.parse.makeCurrentWhile(() { | 10157 PerformanceStatistics.parse.makeCurrentWhile(() { |
| 10105 RecordingErrorListener errorListener = new RecordingErrorListener(); | 10158 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 10106 Parser parser = new Parser(source, errorListener); | 10159 Parser parser = new Parser(source, errorListener); |
| 10107 AnalysisOptions options = context.analysisOptions; | 10160 AnalysisOptions options = context.analysisOptions; |
| 10108 parser.parseFunctionBodies = options.analyzeFunctionBodies; | 10161 parser.parseFunctionBodies = |
| 10162 options.analyzeFunctionBodiesPredicate(source); | |
| 10109 _unit = parser.parseCompilationUnit(_tokenStream); | 10163 _unit = parser.parseCompilationUnit(_tokenStream); |
| 10110 _unit.lineInfo = lineInfo; | 10164 _unit.lineInfo = lineInfo; |
| 10111 AnalysisContext analysisContext = context; | 10165 AnalysisContext analysisContext = context; |
| 10112 for (Directive directive in _unit.directives) { | 10166 for (Directive directive in _unit.directives) { |
| 10113 if (directive is PartOfDirective) { | 10167 if (directive is PartOfDirective) { |
| 10114 _containsPartOfDirective = true; | 10168 _containsPartOfDirective = true; |
| 10115 } else { | 10169 } else { |
| 10116 _containsNonPartOfDirective = true; | 10170 _containsNonPartOfDirective = true; |
| 10117 if (directive is UriBasedDirective) { | 10171 if (directive is UriBasedDirective) { |
| 10118 Source referencedSource = | 10172 Source referencedSource = |
| (...skipping 2368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12487 if (element.id == _id) { | 12541 if (element.id == _id) { |
| 12488 result = element; | 12542 result = element; |
| 12489 throw new _ElementByIdFinderException(); | 12543 throw new _ElementByIdFinderException(); |
| 12490 } | 12544 } |
| 12491 super.visitElement(element); | 12545 super.visitElement(element); |
| 12492 } | 12546 } |
| 12493 } | 12547 } |
| 12494 | 12548 |
| 12495 class _ElementByIdFinderException { | 12549 class _ElementByIdFinderException { |
| 12496 } | 12550 } |
| OLD | NEW |