Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Side by Side Diff: pkg/analyzer/lib/src/generated/engine.dart

Issue 1309543011: Add support for assert statements with messages to the analyzer. Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address review comments. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | pkg/analyzer/lib/src/generated/error.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 void set analysisOptions(AnalysisOptions options) { 1126 void set analysisOptions(AnalysisOptions options) {
1127 bool needsRecompute = this._options.analyzeFunctionBodiesPredicate != 1127 bool needsRecompute = this._options.analyzeFunctionBodiesPredicate !=
1128 options.analyzeFunctionBodiesPredicate || 1128 options.analyzeFunctionBodiesPredicate ||
1129 this._options.generateImplicitErrors != 1129 this._options.generateImplicitErrors !=
1130 options.generateImplicitErrors || 1130 options.generateImplicitErrors ||
1131 this._options.generateSdkErrors != options.generateSdkErrors || 1131 this._options.generateSdkErrors != options.generateSdkErrors ||
1132 this._options.dart2jsHint != options.dart2jsHint || 1132 this._options.dart2jsHint != options.dart2jsHint ||
1133 (this._options.hint && !options.hint) || 1133 (this._options.hint && !options.hint) ||
1134 this._options.preserveComments != options.preserveComments || 1134 this._options.preserveComments != options.preserveComments ||
1135 this._options.strongMode != options.strongMode || 1135 this._options.strongMode != options.strongMode ||
1136 this._options.enableAssertMessage != options.enableAssertMessage ||
1136 this._options.enableStrictCallChecks != 1137 this._options.enableStrictCallChecks !=
1137 options.enableStrictCallChecks || 1138 options.enableStrictCallChecks ||
1138 this._options.enableSuperMixins != options.enableSuperMixins; 1139 this._options.enableSuperMixins != options.enableSuperMixins;
1139 int cacheSize = options.cacheSize; 1140 int cacheSize = options.cacheSize;
1140 if (this._options.cacheSize != cacheSize) { 1141 if (this._options.cacheSize != cacheSize) {
1141 this._options.cacheSize = cacheSize; 1142 this._options.cacheSize = cacheSize;
1142 //cache.setMaxCacheSize(cacheSize); 1143 //cache.setMaxCacheSize(cacheSize);
1143 _privatePartition.maxCacheSize = cacheSize; 1144 _privatePartition.maxCacheSize = cacheSize;
1144 // 1145 //
1145 // Cap the size of the priority list to being less than the cache size. 1146 // Cap the size of the priority list to being less than the cache size.
1146 // Failure to do so can result in an infinite loop in 1147 // Failure to do so can result in an infinite loop in
1147 // performAnalysisTask() because re-caching one AST structure 1148 // performAnalysisTask() because re-caching one AST structure
1148 // can cause another priority source's AST structure to be flushed. 1149 // can cause another priority source's AST structure to be flushed.
1149 // 1150 //
1150 // TODO(brianwilkerson) Remove this constraint when the new task model is 1151 // TODO(brianwilkerson) Remove this constraint when the new task model is
1151 // implemented. 1152 // implemented.
1152 // 1153 //
1153 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; 1154 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA;
1154 if (_priorityOrder.length > maxPriorityOrderSize) { 1155 if (_priorityOrder.length > maxPriorityOrderSize) {
1155 _priorityOrder = _priorityOrder.sublist(0, maxPriorityOrderSize); 1156 _priorityOrder = _priorityOrder.sublist(0, maxPriorityOrderSize);
1156 } 1157 }
1157 } 1158 }
1158 this._options.analyzeFunctionBodiesPredicate = 1159 this._options.analyzeFunctionBodiesPredicate =
1159 options.analyzeFunctionBodiesPredicate; 1160 options.analyzeFunctionBodiesPredicate;
1160 this._options.generateImplicitErrors = options.generateImplicitErrors; 1161 this._options.generateImplicitErrors = options.generateImplicitErrors;
1161 this._options.generateSdkErrors = options.generateSdkErrors; 1162 this._options.generateSdkErrors = options.generateSdkErrors;
1162 this._options.dart2jsHint = options.dart2jsHint; 1163 this._options.dart2jsHint = options.dart2jsHint;
1164 this._options.enableAssertMessage = options.enableAssertMessage;
1163 this._options.enableStrictCallChecks = options.enableStrictCallChecks; 1165 this._options.enableStrictCallChecks = options.enableStrictCallChecks;
1164 this._options.enableSuperMixins = options.enableSuperMixins; 1166 this._options.enableSuperMixins = options.enableSuperMixins;
1165 this._options.hint = options.hint; 1167 this._options.hint = options.hint;
1166 this._options.incremental = options.incremental; 1168 this._options.incremental = options.incremental;
1167 this._options.incrementalApi = options.incrementalApi; 1169 this._options.incrementalApi = options.incrementalApi;
1168 this._options.incrementalValidation = options.incrementalValidation; 1170 this._options.incrementalValidation = options.incrementalValidation;
1169 this._options.lint = options.lint; 1171 this._options.lint = options.lint;
1170 this._options.preserveComments = options.preserveComments; 1172 this._options.preserveComments = options.preserveComments;
1171 this._options.strongMode = options.strongMode; 1173 this._options.strongMode = options.strongMode;
1172 _generateImplicitErrors = options.generateImplicitErrors; 1174 _generateImplicitErrors = options.generateImplicitErrors;
(...skipping 5022 matching lines...) Expand 10 before | Expand all | Expand 10 after
6195 * kept in the cache. 6197 * kept in the cache.
6196 */ 6198 */
6197 int get cacheSize; 6199 int get cacheSize;
6198 6200
6199 /** 6201 /**
6200 * Return `true` if analysis is to generate dart2js related hint results. 6202 * Return `true` if analysis is to generate dart2js related hint results.
6201 */ 6203 */
6202 bool get dart2jsHint; 6204 bool get dart2jsHint;
6203 6205
6204 /** 6206 /**
6207 * Return `true` to enable custom assert messages (DEP 37).
6208 */
6209 bool get enableAssertMessage;
6210
6211 /**
6205 * Return `true` if analysis is to include the new async support. 6212 * Return `true` if analysis is to include the new async support.
6206 */ 6213 */
6207 @deprecated // Always true 6214 @deprecated // Always true
6208 bool get enableAsync; 6215 bool get enableAsync;
6209 6216
6210 /** 6217 /**
6211 * Return `true` if analysis is to include the new deferred loading support. 6218 * Return `true` if analysis is to include the new deferred loading support.
6212 */ 6219 */
6213 @deprecated // Always true 6220 @deprecated // Always true
6214 bool get enableDeferredLoading; 6221 bool get enableDeferredLoading;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
6328 */ 6335 */
6329 int cacheSize = DEFAULT_CACHE_SIZE; 6336 int cacheSize = DEFAULT_CACHE_SIZE;
6330 6337
6331 /** 6338 /**
6332 * A flag indicating whether analysis is to generate dart2js related hint 6339 * A flag indicating whether analysis is to generate dart2js related hint
6333 * results. 6340 * results.
6334 */ 6341 */
6335 bool dart2jsHint = false; 6342 bool dart2jsHint = false;
6336 6343
6337 /** 6344 /**
6345 * A flag indicating whether custom assert messages are to be supported (DEP
6346 * 37).
6347 */
6348 bool enableAssertMessage = false;
6349
6350 /**
6338 * A flag indicating whether generic methods are to be supported (DEP 22). 6351 * A flag indicating whether generic methods are to be supported (DEP 22).
6339 */ 6352 */
6340 bool enableGenericMethods = false; 6353 bool enableGenericMethods = false;
6341 6354
6342 /** 6355 /**
6343 * A flag indicating whether analysis is to strictly follow the specification 6356 * A flag indicating whether analysis is to strictly follow the specification
6344 * when generating warnings on "call" methods (fixes dartbug.com/21938). 6357 * when generating warnings on "call" methods (fixes dartbug.com/21938).
6345 */ 6358 */
6346 bool enableStrictCallChecks = false; 6359 bool enableStrictCallChecks = false;
6347 6360
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
6409 6422
6410 /** 6423 /**
6411 * Initialize a newly created set of analysis options to have the same values 6424 * Initialize a newly created set of analysis options to have the same values
6412 * as those in the given set of analysis [options]. 6425 * as those in the given set of analysis [options].
6413 */ 6426 */
6414 @deprecated // Use new AnalysisOptionsImpl.from(options) 6427 @deprecated // Use new AnalysisOptionsImpl.from(options)
6415 AnalysisOptionsImpl.con1(AnalysisOptions options) { 6428 AnalysisOptionsImpl.con1(AnalysisOptions options) {
6416 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; 6429 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate;
6417 cacheSize = options.cacheSize; 6430 cacheSize = options.cacheSize;
6418 dart2jsHint = options.dart2jsHint; 6431 dart2jsHint = options.dart2jsHint;
6432 enableAssertMessage = options.enableAssertMessage;
6419 enableStrictCallChecks = options.enableStrictCallChecks; 6433 enableStrictCallChecks = options.enableStrictCallChecks;
6420 enableSuperMixins = options.enableSuperMixins; 6434 enableSuperMixins = options.enableSuperMixins;
6421 generateImplicitErrors = options.generateImplicitErrors; 6435 generateImplicitErrors = options.generateImplicitErrors;
6422 generateSdkErrors = options.generateSdkErrors; 6436 generateSdkErrors = options.generateSdkErrors;
6423 hint = options.hint; 6437 hint = options.hint;
6424 incremental = options.incremental; 6438 incremental = options.incremental;
6425 incrementalApi = options.incrementalApi; 6439 incrementalApi = options.incrementalApi;
6426 incrementalValidation = options.incrementalValidation; 6440 incrementalValidation = options.incrementalValidation;
6427 lint = options.lint; 6441 lint = options.lint;
6428 preserveComments = options.preserveComments; 6442 preserveComments = options.preserveComments;
6429 strongMode = options.strongMode; 6443 strongMode = options.strongMode;
6430 } 6444 }
6431 6445
6432 /** 6446 /**
6433 * Initialize a newly created set of analysis options to have the same values 6447 * Initialize a newly created set of analysis options to have the same values
6434 * as those in the given set of analysis [options]. 6448 * as those in the given set of analysis [options].
6435 */ 6449 */
6436 AnalysisOptionsImpl.from(AnalysisOptions options) { 6450 AnalysisOptionsImpl.from(AnalysisOptions options) {
6437 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; 6451 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate;
6438 cacheSize = options.cacheSize; 6452 cacheSize = options.cacheSize;
6439 dart2jsHint = options.dart2jsHint; 6453 dart2jsHint = options.dart2jsHint;
6454 enableAssertMessage = options.enableAssertMessage;
6440 enableStrictCallChecks = options.enableStrictCallChecks; 6455 enableStrictCallChecks = options.enableStrictCallChecks;
6441 enableSuperMixins = options.enableSuperMixins; 6456 enableSuperMixins = options.enableSuperMixins;
6442 generateImplicitErrors = options.generateImplicitErrors; 6457 generateImplicitErrors = options.generateImplicitErrors;
6443 generateSdkErrors = options.generateSdkErrors; 6458 generateSdkErrors = options.generateSdkErrors;
6444 hint = options.hint; 6459 hint = options.hint;
6445 incremental = options.incremental; 6460 incremental = options.incremental;
6446 incrementalApi = options.incrementalApi; 6461 incrementalApi = options.incrementalApi;
6447 incrementalValidation = options.incrementalValidation; 6462 incrementalValidation = options.incrementalValidation;
6448 lint = options.lint; 6463 lint = options.lint;
6449 preserveComments = options.preserveComments; 6464 preserveComments = options.preserveComments;
(...skipping 2038 matching lines...) Expand 10 before | Expand all | Expand 10 after
8488 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, libraryElement, typeProvider); 8503 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, libraryElement, typeProvider);
8489 // _unit.accept(constantVerifier); 8504 // _unit.accept(constantVerifier);
8490 // 8505 //
8491 // Use the ErrorVerifier to compute the rest of the errors. 8506 // Use the ErrorVerifier to compute the rest of the errors.
8492 // 8507 //
8493 ErrorVerifier errorVerifier = new ErrorVerifier( 8508 ErrorVerifier errorVerifier = new ErrorVerifier(
8494 errorReporter, 8509 errorReporter,
8495 libraryElement, 8510 libraryElement,
8496 typeProvider, 8511 typeProvider,
8497 new InheritanceManager(libraryElement), 8512 new InheritanceManager(libraryElement),
8498 context.analysisOptions.enableSuperMixins); 8513 context.analysisOptions.enableSuperMixins,
8514 context.analysisOptions.enableAssertMessage);
8499 _unit.accept(errorVerifier); 8515 _unit.accept(errorVerifier);
8500 _errors = errorListener.getErrorsForSource(source); 8516 _errors = errorListener.getErrorsForSource(source);
8501 }); 8517 });
8502 } 8518 }
8503 8519
8504 /** 8520 /**
8505 * Check each directive in the given compilation unit to see if the referenced source exists and 8521 * Check each directive in the given compilation unit to see if the referenced source exists and
8506 * report an error if it does not. 8522 * report an error if it does not.
8507 * 8523 *
8508 * @param context the context in which the library exists 8524 * @param context the context in which the library exists
(...skipping 2431 matching lines...) Expand 10 before | Expand all | Expand 10 after
10940 // 10956 //
10941 // Perform additional error checking. 10957 // Perform additional error checking.
10942 // 10958 //
10943 PerformanceStatistics.errors.makeCurrentWhile(() { 10959 PerformanceStatistics.errors.makeCurrentWhile(() {
10944 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); 10960 ErrorReporter errorReporter = new ErrorReporter(errorListener, source);
10945 ErrorVerifier errorVerifier = new ErrorVerifier( 10961 ErrorVerifier errorVerifier = new ErrorVerifier(
10946 errorReporter, 10962 errorReporter,
10947 _libraryElement, 10963 _libraryElement,
10948 typeProvider, 10964 typeProvider,
10949 inheritanceManager, 10965 inheritanceManager,
10950 context.analysisOptions.enableSuperMixins); 10966 context.analysisOptions.enableSuperMixins,
10967 context.analysisOptions.enableAssertMessage);
10951 unit.accept(errorVerifier); 10968 unit.accept(errorVerifier);
10952 // TODO(paulberry): as a temporary workaround for issue 21572, 10969 // TODO(paulberry): as a temporary workaround for issue 21572,
10953 // ConstantVerifier is being run right after ConstantValueComputer, so we 10970 // ConstantVerifier is being run right after ConstantValueComputer, so we
10954 // don't need to run it here. Once issue 21572 is fixed, re-enable the 10971 // don't need to run it here. Once issue 21572 is fixed, re-enable the
10955 // call to ConstantVerifier. 10972 // call to ConstantVerifier.
10956 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, _libraryElement, typeProvider); 10973 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, _libraryElement, typeProvider);
10957 // unit.accept(constantVerifier); 10974 // unit.accept(constantVerifier);
10958 }); 10975 });
10959 // 10976 //
10960 // Capture the results. 10977 // Capture the results.
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after
12034 PendingFuture pendingFuture = 12051 PendingFuture pendingFuture =
12035 new PendingFuture<T>(_context, source, computeValue); 12052 new PendingFuture<T>(_context, source, computeValue);
12036 if (!pendingFuture.evaluate(sourceEntry)) { 12053 if (!pendingFuture.evaluate(sourceEntry)) {
12037 _context._pendingFutureSources 12054 _context._pendingFutureSources
12038 .putIfAbsent(source, () => <PendingFuture>[]) 12055 .putIfAbsent(source, () => <PendingFuture>[])
12039 .add(pendingFuture); 12056 .add(pendingFuture);
12040 } 12057 }
12041 return pendingFuture.future; 12058 return pendingFuture.future;
12042 } 12059 }
12043 } 12060 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | pkg/analyzer/lib/src/generated/error.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698