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

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

Issue 628053002: Create a NullErrorReporter to use when errors don't need to be recorded. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
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.constant; 8 library engine.constant;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 /** 202 /**
203 * Initialize a newly created evaluator to evaluate expressions in the given s ource. 203 * Initialize a newly created evaluator to evaluate expressions in the given s ource.
204 * 204 *
205 * @param source the source containing the expression(s) that will be evaluate d 205 * @param source the source containing the expression(s) that will be evaluate d
206 * @param typeProvider the type provider used to access known types 206 * @param typeProvider the type provider used to access known types
207 */ 207 */
208 ConstantEvaluator(this._source, this._typeProvider); 208 ConstantEvaluator(this._source, this._typeProvider);
209 209
210 EvaluationResult evaluate(Expression expression) { 210 EvaluationResult evaluate(Expression expression) {
211 RecordingErrorListener errorListener = new RecordingErrorListener(); 211 RecordingErrorListener errorListener = new RecordingErrorListener();
212 ErrorReporter errorReporter = new ErrorReporter(errorListener, _source); 212 ErrorReporter errorReporter = new ErrorReporterImpl(errorListener, _source);
213 DartObjectImpl result = expression.accept(new ConstantVisitor.con1(_typeProv ider, errorReporter)); 213 DartObjectImpl result = expression.accept(new ConstantVisitor.con1(_typeProv ider, errorReporter));
214 if (result != null) { 214 if (result != null) {
215 return EvaluationResult.forValue(result); 215 return EvaluationResult.forValue(result);
216 } 216 }
217 return EvaluationResult.forErrors(errorListener.errors); 217 return EvaluationResult.forErrors(errorListener.errors);
218 } 218 }
219 } 219 }
220 220
221 /** 221 /**
222 * Instances of the class `ConstantFinder` are used to traverse the AST structur es of all of 222 * Instances of the class `ConstantFinder` are used to traverse the AST structur es of all of
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 * Compute a value for the given constant. 540 * Compute a value for the given constant.
541 * 541 *
542 * @param constNode the constant for which a value is to be computed 542 * @param constNode the constant for which a value is to be computed
543 */ 543 */
544 void _computeValueFor(AstNode constNode) { 544 void _computeValueFor(AstNode constNode) {
545 beforeComputeValue(constNode); 545 beforeComputeValue(constNode);
546 if (constNode is VariableDeclaration) { 546 if (constNode is VariableDeclaration) {
547 VariableDeclaration declaration = constNode; 547 VariableDeclaration declaration = constNode;
548 Element element = declaration.element; 548 Element element = declaration.element;
549 RecordingErrorListener errorListener = new RecordingErrorListener(); 549 RecordingErrorListener errorListener = new RecordingErrorListener();
550 ErrorReporter errorReporter = new ErrorReporter(errorListener, element.sou rce); 550 ErrorReporter errorReporter = new ErrorReporterImpl(errorListener, element .source);
551 DartObjectImpl dartObject = declaration.initializer.accept(createConstantV isitor(errorReporter)); 551 DartObjectImpl dartObject = declaration.initializer.accept(createConstantV isitor(errorReporter));
552 (element as VariableElementImpl).evaluationResult = new EvaluationResultIm pl.con2(dartObject, errorListener.errors); 552 (element as VariableElementImpl).evaluationResult = new EvaluationResultIm pl.con2(dartObject, errorListener.errors);
553 } else if (constNode is InstanceCreationExpression) { 553 } else if (constNode is InstanceCreationExpression) {
554 InstanceCreationExpression expression = constNode; 554 InstanceCreationExpression expression = constNode;
555 ConstructorElement constructor = expression.staticElement; 555 ConstructorElement constructor = expression.staticElement;
556 if (constructor == null) { 556 if (constructor == null) {
557 // Couldn't resolve the constructor so we can't compute a value. No pro blem--the error 557 // Couldn't resolve the constructor so we can't compute a value. No pro blem--the error
558 // has already been reported. But we still need to store an evaluation result. 558 // has already been reported. But we still need to store an evaluation result.
559 expression.evaluationResult = new EvaluationResultImpl.con1(null); 559 expression.evaluationResult = new EvaluationResultImpl.con1(null);
560 return; 560 return;
561 } 561 }
562 RecordingErrorListener errorListener = new RecordingErrorListener(); 562 RecordingErrorListener errorListener = new RecordingErrorListener();
563 CompilationUnit sourceCompilationUnit = expression.getAncestor((node) => n ode is CompilationUnit); 563 CompilationUnit sourceCompilationUnit = expression.getAncestor((node) => n ode is CompilationUnit);
564 ErrorReporter errorReporter = new ErrorReporter(errorListener, sourceCompi lationUnit.element.source); 564 ErrorReporter errorReporter = new ErrorReporterImpl(errorListener, sourceC ompilationUnit.element.source);
565 ConstantVisitor constantVisitor = createConstantVisitor(errorReporter); 565 ConstantVisitor constantVisitor = createConstantVisitor(errorReporter);
566 DartObjectImpl result = _evaluateConstructorCall(constNode, expression.arg umentList.arguments, constructor, constantVisitor, errorReporter); 566 DartObjectImpl result = _evaluateConstructorCall(constNode, expression.arg umentList.arguments, constructor, constantVisitor, errorReporter);
567 expression.evaluationResult = new EvaluationResultImpl.con2(result, errorL istener.errors); 567 expression.evaluationResult = new EvaluationResultImpl.con2(result, errorL istener.errors);
568 } else if (constNode is ConstructorDeclaration) { 568 } else if (constNode is ConstructorDeclaration) {
569 ConstructorDeclaration declaration = constNode; 569 ConstructorDeclaration declaration = constNode;
570 NodeList<ConstructorInitializer> initializers = declaration.initializers; 570 NodeList<ConstructorInitializer> initializers = declaration.initializers;
571 ConstructorElementImpl constructor = declaration.element as ConstructorEle mentImpl; 571 ConstructorElementImpl constructor = declaration.element as ConstructorEle mentImpl;
572 constructor.constantInitializers = new ConstantValueComputer_InitializerCl oner().cloneNodeList(initializers); 572 constructor.constantInitializers = new ConstantValueComputer_InitializerCl oner().cloneNodeList(initializers);
573 } else if (constNode is FormalParameter) { 573 } else if (constNode is FormalParameter) {
574 if (constNode is DefaultFormalParameter) { 574 if (constNode is DefaultFormalParameter) {
575 DefaultFormalParameter parameter = constNode; 575 DefaultFormalParameter parameter = constNode;
576 ParameterElement element = parameter.element; 576 ParameterElement element = parameter.element;
577 Expression defaultValue = parameter.defaultValue; 577 Expression defaultValue = parameter.defaultValue;
578 if (defaultValue != null) { 578 if (defaultValue != null) {
579 RecordingErrorListener errorListener = new RecordingErrorListener(); 579 RecordingErrorListener errorListener = new RecordingErrorListener();
580 ErrorReporter errorReporter = new ErrorReporter(errorListener, element .source); 580 ErrorReporter errorReporter = new ErrorReporterImpl(errorListener, ele ment.source);
581 DartObjectImpl dartObject = defaultValue.accept(createConstantVisitor( errorReporter)); 581 DartObjectImpl dartObject = defaultValue.accept(createConstantVisitor( errorReporter));
582 (element as ParameterElementImpl).evaluationResult = new EvaluationRes ultImpl.con2(dartObject, errorListener.errors); 582 (element as ParameterElementImpl).evaluationResult = new EvaluationRes ultImpl.con2(dartObject, errorListener.errors);
583 } 583 }
584 } 584 }
585 } else { 585 } else {
586 // Should not happen. 586 // Should not happen.
587 AnalysisEngine.instance.logger.logError("Constant value computer trying to compute the value of a node which is not a VariableDeclaration, InstanceCreatio nExpression, FormalParameter, or ConstructorDeclaration"); 587 AnalysisEngine.instance.logger.logError("Constant value computer trying to compute the value of a node which is not a VariableDeclaration, InstanceCreatio nExpression, FormalParameter, or ConstructorDeclaration");
588 return; 588 return;
589 } 589 }
590 } 590 }
(...skipping 3977 matching lines...) Expand 10 before | Expand all | Expand 10 after
4568 4568
4569 @override 4569 @override
4570 String get typeName => "Type"; 4570 String get typeName => "Type";
4571 4571
4572 @override 4572 @override
4573 int get hashCode => _element == null ? 0 : _element.hashCode; 4573 int get hashCode => _element == null ? 0 : _element.hashCode;
4574 4574
4575 @override 4575 @override
4576 String toString() => _element == null ? "-unknown-" : _element.name; 4576 String toString() => _element == null ? "-unknown-" : _element.name;
4577 } 4577 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/engine.dart » ('j') | pkg/analyzer/lib/src/generated/error.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698