Search in sources :

Example 51 with EvaluateException

use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.

the class ExpressionChildrenRenderer method isExpandable.

public boolean isExpandable(Value value, final EvaluationContext context, NodeDescriptor parentDescriptor) {
    final EvaluationContext evaluationContext = context.createEvaluationContext(value);
    if (!StringUtil.isEmpty(myChildrenExpandable.getReferenceExpression().getText())) {
        try {
            Value expanded = myChildrenExpandable.getEvaluator(evaluationContext.getProject()).evaluate(evaluationContext);
            if (expanded instanceof BooleanValue) {
                return ((BooleanValue) expanded).booleanValue();
            }
        } catch (EvaluateException e) {
        // ignored
        }
    }
    try {
        Value children = evaluateChildren(evaluationContext, parentDescriptor);
        ChildrenRenderer defaultChildrenRenderer = DebugProcessImpl.getDefaultRenderer(value.type());
        return defaultChildrenRenderer.isExpandable(children, evaluationContext, parentDescriptor);
    } catch (EvaluateException e) {
        return true;
    }
}
Also used : EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) BooleanValue(com.sun.jdi.BooleanValue) BooleanValue(com.sun.jdi.BooleanValue) Value(com.sun.jdi.Value) EvaluationContext(com.intellij.debugger.engine.evaluation.EvaluationContext)

Example 52 with EvaluateException

use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.

the class IconObjectRenderer method calcValueIcon.

@Override
public Icon calcValueIcon(final ValueDescriptor descriptor, final EvaluationContext evaluationContext, final DescriptorLabelListener listener) throws EvaluateException {
    EvaluationContextImpl evalContext = ((EvaluationContextImpl) evaluationContext);
    DebugProcessImpl debugProcess = evalContext.getDebugProcess();
    if (!Registry.is("debugger.auto.fetch.icons") || DebuggerUtilsImpl.isRemote(debugProcess))
        return null;
    debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(evalContext.getSuspendContext()) {

        @Override
        public void contextAction() throws Exception {
            String getterName = AllIcons.Debugger.Value.getIconHeight() <= 16 ? "iconToBytesPreviewNormal" : "iconToBytesPreviewRetina";
            descriptor.setValueIcon(ImageObjectRenderer.getIcon(evaluationContext, descriptor.getValue(), getterName));
            listener.labelChanged();
        }
    });
    return null;
}
Also used : EvaluationContextImpl(com.intellij.debugger.engine.evaluation.EvaluationContextImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) SuspendContextCommandImpl(com.intellij.debugger.engine.events.SuspendContextCommandImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException)

Example 53 with EvaluateException

use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.

the class LabelRenderer method calcLabel.

public String calcLabel(ValueDescriptor descriptor, EvaluationContext evaluationContext, DescriptorLabelListener labelListener) throws EvaluateException {
    final Value value = descriptor.getValue();
    String result;
    final DebugProcess debugProcess = evaluationContext.getDebugProcess();
    if (value != null) {
        try {
            final ExpressionEvaluator evaluator = myLabelExpression.getEvaluator(debugProcess.getProject());
            if (!debugProcess.isAttached()) {
                throw EvaluateExceptionUtil.PROCESS_EXITED;
            }
            EvaluationContext thisEvaluationContext = evaluationContext.createEvaluationContext(value);
            Value labelValue = evaluator.evaluate(thisEvaluationContext);
            result = DebuggerUtils.getValueAsString(thisEvaluationContext, labelValue);
        } catch (final EvaluateException ex) {
            throw new EvaluateException(DebuggerBundle.message("error.unable.to.evaluate.expression") + " " + ex.getMessage(), ex);
        }
    } else {
        //noinspection HardCodedStringLiteral
        result = "null";
    }
    return result;
}
Also used : DebugProcess(com.intellij.debugger.engine.DebugProcess) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) Value(com.sun.jdi.Value) EvaluationContext(com.intellij.debugger.engine.evaluation.EvaluationContext) ExpressionEvaluator(com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator)

Example 54 with EvaluateException

use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.

the class ClassRenderer method getChildValueExpression.

@Override
public PsiElement getChildValueExpression(DebuggerTreeNode node, DebuggerContext context) throws EvaluateException {
    FieldDescriptor fieldDescriptor = (FieldDescriptor) node.getDescriptor();
    PsiElementFactory elementFactory = JavaPsiFacade.getInstance(node.getProject()).getElementFactory();
    try {
        return elementFactory.createExpressionFromText("this." + fieldDescriptor.getField().name(), DebuggerUtils.findClass(fieldDescriptor.getObject().referenceType().name(), context.getProject(), context.getDebugProcess().getSearchScope()));
    } catch (IncorrectOperationException e) {
        throw new EvaluateException(DebuggerBundle.message("error.invalid.field.name", fieldDescriptor.getField().name()), null);
    }
}
Also used : EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) PsiElementFactory(com.intellij.psi.PsiElementFactory) IncorrectOperationException(com.intellij.util.IncorrectOperationException)

Example 55 with EvaluateException

use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.

the class RequestManagerImpl method addLocatableRequest.

private void addLocatableRequest(FilteredRequestor requestor, EventRequest request) {
    if (DebuggerSettings.SUSPEND_ALL.equals(requestor.getSuspendPolicy())) {
        request.setSuspendPolicy(EventRequest.SUSPEND_ALL);
    } else {
        //when requestor.SUSPEND_POLICY == SUSPEND_NONE
        //we should pause thread in order to evaluate conditions
        request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
    }
    // count filter has to be applied manually if condition is specified
    if (requestor.isCountFilterEnabled() && !requestor.isConditionEnabled()) {
        request.addCountFilter(requestor.getCountFilter());
    }
    if (requestor.isClassFiltersEnabled() && !(request instanceof BreakpointRequest)) /*no built-in class filters support for breakpoint requests*/
    {
        ClassFilter[] classFilters = requestor.getClassFilters();
        if (DebuggerUtilsEx.getEnabledNumber(classFilters) == 1) {
            for (final ClassFilter filter : classFilters) {
                if (!filter.isEnabled()) {
                    continue;
                }
                final JVMName jvmClassName = ApplicationManager.getApplication().runReadAction(new Computable<JVMName>() {

                    public JVMName compute() {
                        PsiClass psiClass = DebuggerUtils.findClass(filter.getPattern(), myDebugProcess.getProject(), myDebugProcess.getSearchScope());
                        if (psiClass == null) {
                            return null;
                        }
                        return JVMNameUtil.getJVMQualifiedName(psiClass);
                    }
                });
                String pattern = filter.getPattern();
                try {
                    if (jvmClassName != null) {
                        pattern = jvmClassName.getName(myDebugProcess);
                    }
                } catch (EvaluateException ignored) {
                }
                addClassFilter(request, pattern);
                // adding more than one inclusion filter does not work, only events that satisfy ALL filters are placed in the event queue.
                break;
            }
        }
        for (ClassFilter filter : requestor.getClassExclusionFilters()) {
            if (filter.isEnabled()) {
                addClassExclusionFilter(request, filter.getPattern());
            }
        }
    }
    registerRequestInternal(requestor, request);
}
Also used : EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) ClassFilter(com.intellij.ui.classFilter.ClassFilter) PsiClass(com.intellij.psi.PsiClass)

Aggregations

EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)62 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)13 NotNull (org.jetbrains.annotations.NotNull)12 Nullable (org.jetbrains.annotations.Nullable)12 EvaluationContextImpl (com.intellij.debugger.engine.evaluation.EvaluationContextImpl)11 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)10 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)10 SourcePosition (com.intellij.debugger.SourcePosition)8 JavaValue (com.intellij.debugger.engine.JavaValue)8 JavaValueModifier (com.intellij.debugger.engine.JavaValueModifier)6 Value (com.sun.jdi.Value)6 Project (com.intellij.openapi.project.Project)5 IncorrectOperationException (com.intellij.util.IncorrectOperationException)5 Method (com.sun.jdi.Method)5 ObjectReference (com.sun.jdi.ObjectReference)5 TextWithImports (com.intellij.debugger.engine.evaluation.TextWithImports)4 ExpressionEvaluator (com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator)4 SuspendContextCommandImpl (com.intellij.debugger.engine.events.SuspendContextCommandImpl)4 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)3 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)3