replace ReferenceEvaluator with simple fallback

This commit is contained in:
Egor.Ushakov
2016-06-27 18:39:36 +03:00
parent 30e2099f47
commit c7058d944f
2 changed files with 7 additions and 57 deletions
@@ -805,13 +805,15 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
}
}
else {
myResult = new ReferenceEvaluator(name);
myResult = createFallbackEvaluator(new LocalVariableEvaluator(name, false),
new FieldEvaluator(new ThisEvaluator(), FieldEvaluator.TargetClassFilter.ALL, name));
}
}
}
private static Evaluator createFallbackEvaluator(final Evaluator primary, final Evaluator fallback) {
return new Evaluator() {
private boolean myIsFallback;
@Override
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
try {
@@ -819,7 +821,9 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
}
catch (EvaluateException e) {
try {
return fallback.evaluate(context);
Object res = fallback.evaluate(context);
myIsFallback = true;
return res;
}
catch (EvaluateException e1) {
throw e;
@@ -829,7 +833,7 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
@Override
public Modifier getModifier() {
return primary.getModifier();
return myIsFallback ? fallback.getModifier() : primary.getModifier();
}
};
}
@@ -1,54 +0,0 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.debugger.engine.evaluation.expression;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
/**
* @author egor
*/
public class ReferenceEvaluator extends LocalVariableEvaluator {
private final FieldEvaluator myFieldEvaluator;
private boolean myIsField;
public ReferenceEvaluator(String localVariableName) {
super(localVariableName, false);
myFieldEvaluator = new FieldEvaluator(new ThisEvaluator(), FieldEvaluator.TargetClassFilter.ALL, localVariableName);
}
@Override
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
try {
return super.evaluate(context);
}
catch (EvaluateException e) {
try {
Object fieldValue = myFieldEvaluator.evaluate(context);
myIsField = true;
return fieldValue;
}
catch (EvaluateException e1) {
throw e;
}
}
}
@Override
public Modifier getModifier() {
return myIsField ? myFieldEvaluator.getModifier() : super.getModifier();
}
}