mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-135439 Unable to use Boolean breakpoint condition
This commit is contained in:
+3
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -25,7 +25,6 @@ import com.intellij.debugger.engine.evaluation.EvaluateException;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
|
||||
import com.sun.jdi.BooleanValue;
|
||||
import com.sun.jdi.Value;
|
||||
|
||||
class ConditionalExpressionEvaluator implements Evaluator {
|
||||
private final Evaluator myConditionEvaluator;
|
||||
@@ -45,8 +44,8 @@ class ConditionalExpressionEvaluator implements Evaluator {
|
||||
|
||||
@Override
|
||||
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
|
||||
Value condition = (Value)myConditionEvaluator.evaluate(context);
|
||||
if (condition == null || !(condition instanceof BooleanValue)) {
|
||||
Object condition = UnBoxingEvaluator.unbox(myConditionEvaluator.evaluate(context), context);
|
||||
if (!(condition instanceof BooleanValue)) {
|
||||
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.boolean.condition.expected"));
|
||||
}
|
||||
return ((BooleanValue)condition).booleanValue()? myThenEvaluator.evaluate(context) : myElseEvaluator.evaluate(context);
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -41,7 +41,7 @@ public class DoWhileStatementEvaluator extends LoopEvaluator {
|
||||
while (true) {
|
||||
if (body(context)) break;
|
||||
|
||||
value = myConditionEvaluator.evaluate(context);
|
||||
value = UnBoxingEvaluator.unbox(myConditionEvaluator.evaluate(context), context);
|
||||
if (!(value instanceof BooleanValue)) {
|
||||
throw EvaluateExceptionUtil.BOOLEAN_EXPECTED;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -34,7 +34,7 @@ public abstract class ForStatementEvaluatorBase extends LoopEvaluator {
|
||||
|
||||
while (true) {
|
||||
// condition
|
||||
Object codition = evaluateCondition(context);
|
||||
Object codition = UnBoxingEvaluator.unbox(evaluateCondition(context), context);
|
||||
if (codition instanceof Boolean) {
|
||||
if (!(Boolean)codition) break;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -41,7 +41,7 @@ public class IfStatementEvaluator implements Evaluator {
|
||||
}
|
||||
|
||||
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
|
||||
Object value = myConditionEvaluator.evaluate(context);
|
||||
Object value = UnBoxingEvaluator.unbox(myConditionEvaluator.evaluate(context), context);
|
||||
if(!(value instanceof BooleanValue)) {
|
||||
throw EvaluateExceptionUtil.BOOLEAN_EXPECTED;
|
||||
} else {
|
||||
|
||||
+9
-6
@@ -57,18 +57,21 @@ public class UnBoxingEvaluator implements Evaluator{
|
||||
}
|
||||
|
||||
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
|
||||
final Value result = (Value)myOperand.evaluate(context);
|
||||
if (result == null) {
|
||||
return unbox(myOperand.evaluate(context), context);
|
||||
}
|
||||
|
||||
public static Object unbox(@Nullable Object value, EvaluationContextImpl context) throws EvaluateException {
|
||||
if (value == null) {
|
||||
throw new EvaluateException("java.lang.NullPointerException: cannot unbox null value");
|
||||
}
|
||||
if (result instanceof ObjectReference) {
|
||||
final String valueTypeName = result.type().name();
|
||||
if (value instanceof ObjectReference) {
|
||||
final String valueTypeName = ((ObjectReference)value).type().name();
|
||||
final Couple<String> pair = TYPES_TO_CONVERSION_METHOD_MAP.get(valueTypeName);
|
||||
if (pair != null) {
|
||||
return convertToPrimitive(context, (ObjectReference)result, pair.getFirst(), pair.getSecond());
|
||||
return convertToPrimitive(context, (ObjectReference)value, pair.getFirst(), pair.getSecond());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -39,7 +39,7 @@ public class WhileStatementEvaluator extends LoopEvaluator {
|
||||
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
|
||||
Object value;
|
||||
while (true) {
|
||||
value = myConditionEvaluator.evaluate(context);
|
||||
value = UnBoxingEvaluator.unbox(myConditionEvaluator.evaluate(context), context);
|
||||
if (!(value instanceof BooleanValue)) {
|
||||
throw EvaluateExceptionUtil.BOOLEAN_EXPECTED;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -25,6 +25,7 @@ import com.intellij.debugger.engine.*;
|
||||
import com.intellij.debugger.engine.evaluation.*;
|
||||
import com.intellij.debugger.engine.evaluation.expression.EvaluatorBuilderImpl;
|
||||
import com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator;
|
||||
import com.intellij.debugger.engine.evaluation.expression.UnBoxingEvaluator;
|
||||
import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
|
||||
import com.intellij.debugger.jdi.StackFrameProxyImpl;
|
||||
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
|
||||
@@ -366,7 +367,7 @@ public abstract class Breakpoint<P extends JavaBreakpointProperties> implements
|
||||
return EvaluatorBuilderImpl.build(getCondition(), contextPsiElement, contextSourcePosition);
|
||||
}
|
||||
});
|
||||
final Value value = evaluator.evaluate(context);
|
||||
Object value = UnBoxingEvaluator.unbox(evaluator.evaluate(context), context);
|
||||
if (!(value instanceof BooleanValue)) {
|
||||
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.boolean.expected"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user