From c7058d944fc35c60c68fb8278f766ec18dfd6e80 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Mon, 27 Jun 2016 16:24:57 +0300 Subject: [PATCH] replace ReferenceEvaluator with simple fallback --- .../expression/EvaluatorBuilderImpl.java | 10 ++-- .../expression/ReferenceEvaluator.java | 54 ------------------- 2 files changed, 7 insertions(+), 57 deletions(-) delete mode 100644 java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ReferenceEvaluator.java diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java index ff8f550b6d71..8f85b9a2f887 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java @@ -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(); } }; } diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ReferenceEvaluator.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ReferenceEvaluator.java deleted file mode 100644 index f5ae73d4ae21..000000000000 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/ReferenceEvaluator.java +++ /dev/null @@ -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(); - } -}