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

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

Issue 1239513005: Switch on null-aware operators by default in analyzer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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/context/context.dart ('k') | pkg/analyzer/lib/src/generated/html.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 // 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:async'; 10 import 'dart:async';
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 @override 1095 @override
1096 void set analysisOptions(AnalysisOptions options) { 1096 void set analysisOptions(AnalysisOptions options) {
1097 bool needsRecompute = this._options.analyzeFunctionBodiesPredicate != 1097 bool needsRecompute = this._options.analyzeFunctionBodiesPredicate !=
1098 options.analyzeFunctionBodiesPredicate || 1098 options.analyzeFunctionBodiesPredicate ||
1099 this._options.generateImplicitErrors != 1099 this._options.generateImplicitErrors !=
1100 options.generateImplicitErrors || 1100 options.generateImplicitErrors ||
1101 this._options.generateSdkErrors != options.generateSdkErrors || 1101 this._options.generateSdkErrors != options.generateSdkErrors ||
1102 this._options.dart2jsHint != options.dart2jsHint || 1102 this._options.dart2jsHint != options.dart2jsHint ||
1103 (this._options.hint && !options.hint) || 1103 (this._options.hint && !options.hint) ||
1104 this._options.preserveComments != options.preserveComments || 1104 this._options.preserveComments != options.preserveComments ||
1105 this._options.enableNullAwareOperators !=
1106 options.enableNullAwareOperators ||
1107 this._options.enableStrictCallChecks != options.enableStrictCallChecks; 1105 this._options.enableStrictCallChecks != options.enableStrictCallChecks;
1108 int cacheSize = options.cacheSize; 1106 int cacheSize = options.cacheSize;
1109 if (this._options.cacheSize != cacheSize) { 1107 if (this._options.cacheSize != cacheSize) {
1110 this._options.cacheSize = cacheSize; 1108 this._options.cacheSize = cacheSize;
1111 //cache.setMaxCacheSize(cacheSize); 1109 //cache.setMaxCacheSize(cacheSize);
1112 _privatePartition.maxCacheSize = cacheSize; 1110 _privatePartition.maxCacheSize = cacheSize;
1113 // 1111 //
1114 // Cap the size of the priority list to being less than the cache size. 1112 // Cap the size of the priority list to being less than the cache size.
1115 // Failure to do so can result in an infinite loop in 1113 // Failure to do so can result in an infinite loop in
1116 // performAnalysisTask() because re-caching one AST structure 1114 // performAnalysisTask() because re-caching one AST structure
1117 // can cause another priority source's AST structure to be flushed. 1115 // can cause another priority source's AST structure to be flushed.
1118 // 1116 //
1119 // TODO(brianwilkerson) Remove this constraint when the new task model is 1117 // TODO(brianwilkerson) Remove this constraint when the new task model is
1120 // implemented. 1118 // implemented.
1121 // 1119 //
1122 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA; 1120 int maxPriorityOrderSize = cacheSize - _PRIORITY_ORDER_SIZE_DELTA;
1123 if (_priorityOrder.length > maxPriorityOrderSize) { 1121 if (_priorityOrder.length > maxPriorityOrderSize) {
1124 _priorityOrder = _priorityOrder.sublist(0, maxPriorityOrderSize); 1122 _priorityOrder = _priorityOrder.sublist(0, maxPriorityOrderSize);
1125 } 1123 }
1126 } 1124 }
1127 this._options.analyzeFunctionBodiesPredicate = 1125 this._options.analyzeFunctionBodiesPredicate =
1128 options.analyzeFunctionBodiesPredicate; 1126 options.analyzeFunctionBodiesPredicate;
1129 this._options.generateImplicitErrors = options.generateImplicitErrors; 1127 this._options.generateImplicitErrors = options.generateImplicitErrors;
1130 this._options.generateSdkErrors = options.generateSdkErrors; 1128 this._options.generateSdkErrors = options.generateSdkErrors;
1131 this._options.dart2jsHint = options.dart2jsHint; 1129 this._options.dart2jsHint = options.dart2jsHint;
1132 this._options.enableNullAwareOperators = options.enableNullAwareOperators;
1133 this._options.enableStrictCallChecks = options.enableStrictCallChecks; 1130 this._options.enableStrictCallChecks = options.enableStrictCallChecks;
1134 this._options.hint = options.hint; 1131 this._options.hint = options.hint;
1135 this._options.incremental = options.incremental; 1132 this._options.incremental = options.incremental;
1136 this._options.incrementalApi = options.incrementalApi; 1133 this._options.incrementalApi = options.incrementalApi;
1137 this._options.incrementalValidation = options.incrementalValidation; 1134 this._options.incrementalValidation = options.incrementalValidation;
1138 this._options.lint = options.lint; 1135 this._options.lint = options.lint;
1139 this._options.preserveComments = options.preserveComments; 1136 this._options.preserveComments = options.preserveComments;
1140 _generateImplicitErrors = options.generateImplicitErrors; 1137 _generateImplicitErrors = options.generateImplicitErrors;
1141 _generateSdkErrors = options.generateSdkErrors; 1138 _generateSdkErrors = options.generateSdkErrors;
1142 if (needsRecompute) { 1139 if (needsRecompute) {
(...skipping 4952 matching lines...) Expand 10 before | Expand all | Expand 10 after
6095 bool get enableEnum; 6092 bool get enableEnum;
6096 6093
6097 /** 6094 /**
6098 * Return `true` to enable generic methods (DEP 22). 6095 * Return `true` to enable generic methods (DEP 22).
6099 */ 6096 */
6100 bool get enableGenericMethods => null; 6097 bool get enableGenericMethods => null;
6101 6098
6102 /** 6099 /**
6103 * Return `true` to enable null-aware operators (DEP 9). 6100 * Return `true` to enable null-aware operators (DEP 9).
6104 */ 6101 */
6102 @deprecated // Always true
6105 bool get enableNullAwareOperators; 6103 bool get enableNullAwareOperators;
6106 6104
6107 /** 6105 /**
6108 * Return `true` to strictly follow the specification when generating 6106 * Return `true` to strictly follow the specification when generating
6109 * warnings on "call" methods (fixes dartbug.com/21938). 6107 * warnings on "call" methods (fixes dartbug.com/21938).
6110 */ 6108 */
6111 bool get enableStrictCallChecks; 6109 bool get enableStrictCallChecks;
6112 6110
6113 /** 6111 /**
6114 * Return `true` if errors, warnings and hints should be generated for sources 6112 * Return `true` if errors, warnings and hints should be generated for sources
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
6196 * results. 6194 * results.
6197 */ 6195 */
6198 bool dart2jsHint = true; 6196 bool dart2jsHint = true;
6199 6197
6200 /** 6198 /**
6201 * A flag indicating whether generic methods are to be supported (DEP 22). 6199 * A flag indicating whether generic methods are to be supported (DEP 22).
6202 */ 6200 */
6203 bool enableGenericMethods = false; 6201 bool enableGenericMethods = false;
6204 6202
6205 /** 6203 /**
6206 * A flag indicating whether null-aware operators should be parsed (DEP 9).
6207 */
6208 bool enableNullAwareOperators = false;
6209
6210 /**
6211 * A flag indicating whether analysis is to strictly follow the specification 6204 * A flag indicating whether analysis is to strictly follow the specification
6212 * when generating warnings on "call" methods (fixes dartbug.com/21938). 6205 * when generating warnings on "call" methods (fixes dartbug.com/21938).
6213 */ 6206 */
6214 bool enableStrictCallChecks = false; 6207 bool enableStrictCallChecks = false;
6215 6208
6216 /** 6209 /**
6217 * A flag indicating whether errors, warnings and hints should be generated 6210 * A flag indicating whether errors, warnings and hints should be generated
6218 * for sources that are implicitly being analyzed. 6211 * for sources that are implicitly being analyzed.
6219 */ 6212 */
6220 bool generateImplicitErrors = true; 6213 bool generateImplicitErrors = true;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
6266 6259
6267 /** 6260 /**
6268 * Initialize a newly created set of analysis options to have the same values 6261 * Initialize a newly created set of analysis options to have the same values
6269 * as those in the given set of analysis [options]. 6262 * as those in the given set of analysis [options].
6270 */ 6263 */
6271 @deprecated // Use new AnalysisOptionsImpl.from(options) 6264 @deprecated // Use new AnalysisOptionsImpl.from(options)
6272 AnalysisOptionsImpl.con1(AnalysisOptions options) { 6265 AnalysisOptionsImpl.con1(AnalysisOptions options) {
6273 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; 6266 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate;
6274 cacheSize = options.cacheSize; 6267 cacheSize = options.cacheSize;
6275 dart2jsHint = options.dart2jsHint; 6268 dart2jsHint = options.dart2jsHint;
6276 enableNullAwareOperators = options.enableNullAwareOperators;
6277 enableStrictCallChecks = options.enableStrictCallChecks; 6269 enableStrictCallChecks = options.enableStrictCallChecks;
6278 generateImplicitErrors = options.generateImplicitErrors; 6270 generateImplicitErrors = options.generateImplicitErrors;
6279 generateSdkErrors = options.generateSdkErrors; 6271 generateSdkErrors = options.generateSdkErrors;
6280 hint = options.hint; 6272 hint = options.hint;
6281 incremental = options.incremental; 6273 incremental = options.incremental;
6282 incrementalApi = options.incrementalApi; 6274 incrementalApi = options.incrementalApi;
6283 incrementalValidation = options.incrementalValidation; 6275 incrementalValidation = options.incrementalValidation;
6284 lint = options.lint; 6276 lint = options.lint;
6285 preserveComments = options.preserveComments; 6277 preserveComments = options.preserveComments;
6286 } 6278 }
6287 6279
6288 /** 6280 /**
6289 * Initialize a newly created set of analysis options to have the same values 6281 * Initialize a newly created set of analysis options to have the same values
6290 * as those in the given set of analysis [options]. 6282 * as those in the given set of analysis [options].
6291 */ 6283 */
6292 AnalysisOptionsImpl.from(AnalysisOptions options) { 6284 AnalysisOptionsImpl.from(AnalysisOptions options) {
6293 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate; 6285 analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate;
6294 cacheSize = options.cacheSize; 6286 cacheSize = options.cacheSize;
6295 dart2jsHint = options.dart2jsHint; 6287 dart2jsHint = options.dart2jsHint;
6296 enableNullAwareOperators = options.enableNullAwareOperators;
6297 enableStrictCallChecks = options.enableStrictCallChecks; 6288 enableStrictCallChecks = options.enableStrictCallChecks;
6298 generateImplicitErrors = options.generateImplicitErrors; 6289 generateImplicitErrors = options.generateImplicitErrors;
6299 generateSdkErrors = options.generateSdkErrors; 6290 generateSdkErrors = options.generateSdkErrors;
6300 hint = options.hint; 6291 hint = options.hint;
6301 incremental = options.incremental; 6292 incremental = options.incremental;
6302 incrementalApi = options.incrementalApi; 6293 incrementalApi = options.incrementalApi;
6303 incrementalValidation = options.incrementalValidation; 6294 incrementalValidation = options.incrementalValidation;
6304 lint = options.lint; 6295 lint = options.lint;
6305 preserveComments = options.preserveComments; 6296 preserveComments = options.preserveComments;
6306 } 6297 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
6355 6346
6356 @deprecated 6347 @deprecated
6357 @override 6348 @override
6358 bool get enableEnum => true; 6349 bool get enableEnum => true;
6359 6350
6360 @deprecated 6351 @deprecated
6361 void set enableEnum(bool enable) { 6352 void set enableEnum(bool enable) {
6362 // Enum support cannot be disabled 6353 // Enum support cannot be disabled
6363 } 6354 }
6364 6355
6356 @deprecated
6357 @override
6358 bool get enableNullAwareOperators => true;
6359
6360 @deprecated
6361 void set enableNullAwareOperators(bool enable) {
6362 // Null-aware operator support cannot be disabled
6363 }
6364
6365 /** 6365 /**
6366 * Predicate used for [analyzeFunctionBodiesPredicate] when 6366 * Predicate used for [analyzeFunctionBodiesPredicate] when
6367 * [analyzeFunctionBodies] is set to `true`. 6367 * [analyzeFunctionBodies] is set to `true`.
6368 */ 6368 */
6369 static bool _analyzeAllFunctionBodies(Source _) => true; 6369 static bool _analyzeAllFunctionBodies(Source _) => true;
6370 6370
6371 /** 6371 /**
6372 * Predicate used for [analyzeFunctionBodiesPredicate] when 6372 * Predicate used for [analyzeFunctionBodiesPredicate] when
6373 * [analyzeFunctionBodies] is set to `false`. 6373 * [analyzeFunctionBodies] is set to `false`.
6374 */ 6374 */
(...skipping 4614 matching lines...) Expand 10 before | Expand all | Expand 10 after
10989 accept(AnalysisTaskVisitor visitor) => visitor.visitScanDartTask(this); 10989 accept(AnalysisTaskVisitor visitor) => visitor.visitScanDartTask(this);
10990 10990
10991 @override 10991 @override
10992 void internalPerform() { 10992 void internalPerform() {
10993 PerformanceStatistics.scan.makeCurrentWhile(() { 10993 PerformanceStatistics.scan.makeCurrentWhile(() {
10994 RecordingErrorListener errorListener = new RecordingErrorListener(); 10994 RecordingErrorListener errorListener = new RecordingErrorListener();
10995 try { 10995 try {
10996 Scanner scanner = new Scanner( 10996 Scanner scanner = new Scanner(
10997 source, new CharSequenceReader(_content), errorListener); 10997 source, new CharSequenceReader(_content), errorListener);
10998 scanner.preserveComments = context.analysisOptions.preserveComments; 10998 scanner.preserveComments = context.analysisOptions.preserveComments;
10999 scanner.enableNullAwareOperators =
11000 context.analysisOptions.enableNullAwareOperators;
11001 _tokenStream = scanner.tokenize(); 10999 _tokenStream = scanner.tokenize();
11002 _lineInfo = new LineInfo(scanner.lineStarts); 11000 _lineInfo = new LineInfo(scanner.lineStarts);
11003 _errors = errorListener.getErrorsForSource(source); 11001 _errors = errorListener.getErrorsForSource(source);
11004 } catch (exception, stackTrace) { 11002 } catch (exception, stackTrace) {
11005 throw new AnalysisException( 11003 throw new AnalysisException(
11006 "Exception", new CaughtException(exception, stackTrace)); 11004 "Exception", new CaughtException(exception, stackTrace));
11007 } 11005 }
11008 }); 11006 });
11009 } 11007 }
11010 } 11008 }
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
11842 PendingFuture pendingFuture = 11840 PendingFuture pendingFuture =
11843 new PendingFuture<T>(_context, source, computeValue); 11841 new PendingFuture<T>(_context, source, computeValue);
11844 if (!pendingFuture.evaluate(sourceEntry)) { 11842 if (!pendingFuture.evaluate(sourceEntry)) {
11845 _context._pendingFutureSources 11843 _context._pendingFutureSources
11846 .putIfAbsent(source, () => <PendingFuture>[]) 11844 .putIfAbsent(source, () => <PendingFuture>[])
11847 .add(pendingFuture); 11845 .add(pendingFuture);
11848 } 11846 }
11849 return pendingFuture.future; 11847 return pendingFuture.future;
11850 } 11848 }
11851 } 11849 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/context/context.dart ('k') | pkg/analyzer/lib/src/generated/html.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698