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

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

Issue 1933763002: Use null-aware operators to clean up the code (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Additional clean-up Created 4 years, 7 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
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 analyzer.src.generated.constant; 5 library analyzer.src.generated.constant;
6 6
7 import 'package:analyzer/context/declared_variables.dart'; 7 import 'package:analyzer/context/declared_variables.dart';
8 import 'package:analyzer/dart/ast/ast.dart'; 8 import 'package:analyzer/dart/ast/ast.dart';
9 import 'package:analyzer/src/dart/constant/evaluation.dart'; 9 import 'package:analyzer/src/dart/constant/evaluation.dart';
10 import 'package:analyzer/src/dart/constant/value.dart'; 10 import 'package:analyzer/src/dart/constant/value.dart';
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 * The type system primitives. 113 * The type system primitives.
114 */ 114 */
115 final TypeSystem _typeSystem; 115 final TypeSystem _typeSystem;
116 116
117 /** 117 /**
118 * Initialize a newly created evaluator to evaluate expressions in the given 118 * Initialize a newly created evaluator to evaluate expressions in the given
119 * [source]. The [typeProvider] is the type provider used to access known 119 * [source]. The [typeProvider] is the type provider used to access known
120 * types. 120 * types.
121 */ 121 */
122 ConstantEvaluator(this._source, this._typeProvider, {TypeSystem typeSystem}) 122 ConstantEvaluator(this._source, this._typeProvider, {TypeSystem typeSystem})
123 : _typeSystem = typeSystem != null ? typeSystem : new TypeSystemImpl(); 123 : _typeSystem = typeSystem ?? new TypeSystemImpl();
124 124
125 EvaluationResult evaluate(Expression expression) { 125 EvaluationResult evaluate(Expression expression) {
126 RecordingErrorListener errorListener = new RecordingErrorListener(); 126 RecordingErrorListener errorListener = new RecordingErrorListener();
127 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); 127 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source);
128 DartObjectImpl result = expression.accept(new ConstantVisitor( 128 DartObjectImpl result = expression.accept(new ConstantVisitor(
129 new ConstantEvaluationEngine(_typeProvider, new DeclaredVariables(), 129 new ConstantEvaluationEngine(_typeProvider, new DeclaredVariables(),
130 typeSystem: _typeSystem), 130 typeSystem: _typeSystem),
131 errorReporter)); 131 errorReporter));
132 if (result != null) { 132 if (result != null) {
133 return EvaluationResult.forValue(result); 133 return EvaluationResult.forValue(result);
134 } 134 }
135 return EvaluationResult.forErrors(errorListener.errors); 135 return EvaluationResult.forErrors(errorListener.errors);
136 } 136 }
137 } 137 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/resolver/scope.dart ('k') | pkg/analyzer/lib/src/generated/element_resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698