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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/DeadCodeVerifier.java

Issue 613303003: Rework EvaluationResultImpl class hierarchy. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rework to use ErrorReporter Created 6 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 side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/DeadCodeVerifier.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/DeadCodeVerifier.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/DeadCodeVerifier.java
index 6208d8bcf6eee657b6be106d0603e56c37b1c666..2abedb0835f900c4559289b3330707a38d88233c 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/DeadCodeVerifier.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/DeadCodeVerifier.java
@@ -39,7 +39,7 @@ import com.google.dart.engine.element.Element;
import com.google.dart.engine.element.PropertyAccessorElement;
import com.google.dart.engine.element.PropertyInducingElement;
import com.google.dart.engine.error.HintCode;
-import com.google.dart.engine.internal.constant.ValidResult;
+import com.google.dart.engine.internal.constant.EvaluationResultImpl;
import com.google.dart.engine.internal.error.ErrorReporter;
import com.google.dart.engine.internal.object.BoolState;
import com.google.dart.engine.internal.object.DartObjectImpl;
@@ -79,15 +79,15 @@ public class DeadCodeVerifier extends RecursiveAstVisitor<Void> {
if (isAmpAmp || isBarBar) {
Expression lhsCondition = node.getLeftOperand();
if (!isDebugConstant(lhsCondition)) {
- ValidResult lhsResult = getConstantBooleanValue(lhsCondition);
+ EvaluationResultImpl lhsResult = getConstantBooleanValue(lhsCondition);
if (lhsResult != null) {
- if (lhsResult.isTrue() && isBarBar) {
+ if (lhsResult.getValue().isTrue() && isBarBar) {
// report error on else block: true || !e!
errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.getRightOperand());
// only visit the LHS:
safelyVisit(lhsCondition);
return null;
- } else if (lhsResult.isFalse() && isAmpAmp) {
+ } else if (lhsResult.getValue().isFalse() && isAmpAmp) {
// report error on if block: false && !e!
errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.getRightOperand());
// only visit the LHS:
@@ -136,9 +136,9 @@ public class DeadCodeVerifier extends RecursiveAstVisitor<Void> {
Expression conditionExpression = node.getCondition();
safelyVisit(conditionExpression);
if (!isDebugConstant(conditionExpression)) {
- ValidResult result = getConstantBooleanValue(conditionExpression);
+ EvaluationResultImpl result = getConstantBooleanValue(conditionExpression);
if (result != null) {
- if (result.isTrue()) {
+ if (result.getValue().isTrue()) {
// report error on else block: true ? 1 : !2!
errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.getElseExpression());
safelyVisit(node.getThenExpression());
@@ -159,9 +159,9 @@ public class DeadCodeVerifier extends RecursiveAstVisitor<Void> {
Expression conditionExpression = node.getCondition();
safelyVisit(conditionExpression);
if (!isDebugConstant(conditionExpression)) {
- ValidResult result = getConstantBooleanValue(conditionExpression);
+ EvaluationResultImpl result = getConstantBooleanValue(conditionExpression);
if (result != null) {
- if (result.isTrue()) {
+ if (result.getValue().isTrue()) {
// report error on else block: if(true) {} else {!}
Statement elseStatement = node.getElseStatement();
if (elseStatement != null) {
@@ -285,9 +285,9 @@ public class DeadCodeVerifier extends RecursiveAstVisitor<Void> {
Expression conditionExpression = node.getCondition();
safelyVisit(conditionExpression);
if (!isDebugConstant(conditionExpression)) {
- ValidResult result = getConstantBooleanValue(conditionExpression);
+ EvaluationResultImpl result = getConstantBooleanValue(conditionExpression);
if (result != null) {
- if (result.isFalse()) {
+ if (result.getValue().isFalse()) {
// report error on if block: while (false) {!}
errorReporter.reportErrorForNode(HintCode.DEAD_CODE, node.getBody());
return null;
@@ -334,12 +334,12 @@ public class DeadCodeVerifier extends RecursiveAstVisitor<Void> {
* if it is {@code false}, or {@code null} if the expression is not a constant boolean
* value
*/
- private ValidResult getConstantBooleanValue(Expression expression) {
+ private EvaluationResultImpl getConstantBooleanValue(Expression expression) {
if (expression instanceof BooleanLiteral) {
if (((BooleanLiteral) expression).getValue()) {
- return new ValidResult(new DartObjectImpl(null, BoolState.from(true)));
+ return new EvaluationResultImpl(new DartObjectImpl(null, BoolState.from(true)));
} else {
- return new ValidResult(new DartObjectImpl(null, BoolState.from(false)));
+ return new EvaluationResultImpl(new DartObjectImpl(null, BoolState.from(false)));
}
}
// Don't consider situations where we could evaluate to a constant boolean expression with the

Powered by Google App Engine
This is Rietveld 408576698