Chromium Code Reviews| Index: pkg/analyzer/lib/src/generated/engine.dart |
| diff --git a/pkg/analyzer/lib/src/generated/engine.dart b/pkg/analyzer/lib/src/generated/engine.dart |
| index fedfe2289b42c45fe54eefad7a2f2d4fba6f4e03..7b29f48479e878826047a10ebe3defa23bae6911 100644 |
| --- a/pkg/analyzer/lib/src/generated/engine.dart |
| +++ b/pkg/analyzer/lib/src/generated/engine.dart |
| @@ -38,6 +38,12 @@ import 'utilities_collection.dart'; |
| import 'utilities_general.dart'; |
| /** |
| + * Used by [AnalysisOptions] to allow function bodies to be analyzed in some |
| + * sources but not others. |
| + */ |
| +typedef bool AnalyzeFunctionBodiesPredicate(Source source); |
| + |
| +/** |
| * Type of callback functions used by PendingFuture. Functions of this type |
| * should perform a computation based on the data in [sourceEntry] and return |
| * it. If the computation can't be performed yet because more analysis is |
| @@ -1117,7 +1123,8 @@ class AnalysisContextImpl implements InternalAnalysisContext { |
| @override |
| void set analysisOptions(AnalysisOptions options) { |
| bool needsRecompute = |
| - this._options.analyzeFunctionBodies != options.analyzeFunctionBodies || |
| + this._options.analyzeFunctionBodiesPredicate != |
| + options.analyzeFunctionBodiesPredicate || |
| this._options.generateSdkErrors != options.generateSdkErrors || |
| this._options.dart2jsHint != options.dart2jsHint || |
| (this._options.hint && !options.hint) || |
| @@ -1145,7 +1152,8 @@ class AnalysisContextImpl implements InternalAnalysisContext { |
| _priorityOrder = newPriorityOrder; |
| } |
| } |
| - this._options.analyzeFunctionBodies = options.analyzeFunctionBodies; |
| + this._options.analyzeFunctionBodiesPredicate = |
| + options.analyzeFunctionBodiesPredicate; |
| this._options.generateSdkErrors = options.generateSdkErrors; |
| this._options.dart2jsHint = options.dart2jsHint; |
| this._options.hint = options.hint; |
| @@ -6501,13 +6509,24 @@ class AnalysisNotScheduledError implements Exception { |
| */ |
| abstract class AnalysisOptions { |
| /** |
| - * Return `true` if analysis is to parse and analyze function bodies. |
| + * If analysis is to parse and analyze all function bodies, return `true`. |
| + * If analysis is to skip all function bodies, return `false`. If analysis |
| + * is to parse and analyze function bodies in some sources and not in others, |
| + * throw an exception. |
| * |
| - * @return `true` if analysis is to parse and analyzer function bodies |
| + * This getter is deprecated; consider using [analyzeFunctionBodiesPredicate] |
| + * instead. |
| */ |
| + @deprecated |
| bool get analyzeFunctionBodies; |
| /** |
| + * Function that returns `true` if analysis is to parse and analyze function |
| + * bodies for a given source. |
| + */ |
| + AnalyzeFunctionBodiesPredicate get analyzeFunctionBodiesPredicate; |
| + |
| + /** |
| * Return the maximum number of sources for which AST structures should be kept in the cache. |
| * |
| * @return the maximum number of sources for which AST structures should be kept in the cache |
| @@ -6616,9 +6635,11 @@ class AnalysisOptionsImpl implements AnalysisOptions { |
| static bool DEFAULT_ENABLE_ENUM = false; |
| /** |
| - * A flag indicating whether analysis is to parse and analyze function bodies. |
| + * A predicate indicating whether analysis is to parse and analyze function |
| + * bodies. |
| */ |
| - bool analyzeFunctionBodies = true; |
| + 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
|
| + _analyzeAllFunctionBodies; |
| /** |
| * The maximum number of sources for which AST structures should be kept in the cache. |
| @@ -6681,7 +6702,7 @@ class AnalysisOptionsImpl implements AnalysisOptions { |
| * @param options the analysis options whose values are being copied |
| */ |
| AnalysisOptionsImpl.con1(AnalysisOptions options) { |
| - analyzeFunctionBodies = options.analyzeFunctionBodies; |
| + analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; |
| cacheSize = options.cacheSize; |
| dart2jsHint = options.dart2jsHint; |
| _generateSdkErrors = options.generateSdkErrors; |
| @@ -6693,6 +6714,26 @@ class AnalysisOptionsImpl implements AnalysisOptions { |
| preserveComments = options.preserveComments; |
| } |
| + bool get analyzeFunctionBodies { |
| + if (identical(analyzeFunctionBodiesPredicate, _analyzeAllFunctionBodies)) { |
| + return true; |
| + } else if (identical( |
| + analyzeFunctionBodiesPredicate, |
| + _analyzeNoFunctionBodies)) { |
| + return false; |
| + } else { |
| + throw new StateError('analyzeFunctionBodiesPredicate in use'); |
| + } |
| + } |
| + |
| + set analyzeFunctionBodies(bool value) { |
| + if (value) { |
| + analyzeFunctionBodiesPredicate = _analyzeAllFunctionBodies; |
| + } else { |
| + analyzeFunctionBodiesPredicate = _analyzeNoFunctionBodies; |
| + } |
| + } |
| + |
| @deprecated |
| @override |
| bool get enableAsync => true; |
| @@ -6733,6 +6774,18 @@ class AnalysisOptionsImpl implements AnalysisOptions { |
| void set generateSdkErrors(bool generate) { |
| _generateSdkErrors = generate; |
| } |
| + |
| + /** |
| + * Predicate used for [analyzeFunctionBodiesPredicate] when |
| + * [analyzeFunctionBodies] is set to `true`. |
| + */ |
| + static bool _analyzeAllFunctionBodies(Source _) => true; |
| + |
| + /** |
| + * Predicate used for [analyzeFunctionBodiesPredicate] when |
| + * [analyzeFunctionBodies] is set to `false`. |
| + */ |
| + static bool _analyzeNoFunctionBodies(Source _) => false; |
| } |
| /** |
| @@ -10105,7 +10158,8 @@ class ParseDartTask extends AnalysisTask { |
| RecordingErrorListener errorListener = new RecordingErrorListener(); |
| Parser parser = new Parser(source, errorListener); |
| AnalysisOptions options = context.analysisOptions; |
| - parser.parseFunctionBodies = options.analyzeFunctionBodies; |
| + parser.parseFunctionBodies = |
| + options.analyzeFunctionBodiesPredicate(source); |
| _unit = parser.parseCompilationUnit(_tokenStream); |
| _unit.lineInfo = lineInfo; |
| AnalysisContext analysisContext = context; |