Search in sources :

Example 11 with Method

use of com.sun.jdi.Method in project intellij-community by JetBrains.

the class ForceEarlyReturnAction method actionPerformed.

public void actionPerformed(@NotNull AnActionEvent e) {
    final Project project = e.getProject();
    final JavaStackFrame stackFrame = PopFrameAction.getStackFrame(e);
    if (stackFrame == null || project == null) {
        return;
    }
    final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
    final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
    if (debugProcess == null) {
        return;
    }
    final StackFrameProxyImpl proxy = stackFrame.getStackFrameProxy();
    final ThreadReferenceProxyImpl thread = proxy.threadProxy();
    debugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext, thread) {

        @Override
        public void threadAction() {
            Method method;
            try {
                method = proxy.location().method();
            } catch (EvaluateException e) {
                showError(project, DebuggerBundle.message("error.early.return", e.getLocalizedMessage()));
                return;
            }
            if ("void".equals(method.returnTypeName())) {
                forceEarlyReturnWithFinally(thread.getVirtualMachine().mirrorOfVoid(), stackFrame, debugProcess, null);
            } else {
                ApplicationManager.getApplication().invokeLater(() -> new ReturnExpressionDialog(project, debugProcess.getXdebugProcess().getEditorsProvider(), debugProcess, stackFrame).show());
            }
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) JavaStackFrame(com.intellij.debugger.engine.JavaStackFrame) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) Method(com.sun.jdi.Method) ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl)

Example 12 with Method

use of com.sun.jdi.Method in project intellij-community by JetBrains.

the class ExecutionWithDebuggerToolsTestCase method printFrameProxy.

protected void printFrameProxy(StackFrameProxyImpl frameProxy) throws EvaluateException {
    int frameIndex = frameProxy.getFrameIndex();
    Method method = frameProxy.location().method();
    println("frameProxy(" + frameIndex + ") = " + method, ProcessOutputTypes.SYSTEM);
}
Also used : Method(com.sun.jdi.Method) ExceptionBreakpoint(com.intellij.debugger.ui.breakpoints.ExceptionBreakpoint) Breakpoint(com.intellij.debugger.ui.breakpoints.Breakpoint)

Example 13 with Method

use of com.sun.jdi.Method in project che by eclipse.

the class Evaluator method findMethod.

private Method findMethod(List<Method> methods, List<Value> arguments) {
    Method m = null;
    for (Method mm : methods) {
        List<Type> argumentTypes;
        try {
            argumentTypes = mm.argumentTypes();
        } catch (ClassNotLoadedException e) {
            continue;
        }
        ARGUMENT_MATCHING argumentMatching = argumentsMatching(argumentTypes, arguments);
        if (argumentMatching == ARGUMENT_MATCHING.MATCH) {
            m = mm;
            break;
        } else if (argumentMatching == ARGUMENT_MATCHING.ASSIGNABLE) {
            if (m == null) {
                m = mm;
            } else {
                throw new ExpressionException("Multiple methods with name " + mm.name() + " matched to specified arguments. ");
            }
        }
    }
    return m;
}
Also used : ClassNotLoadedException(com.sun.jdi.ClassNotLoadedException) InterfaceType(com.sun.jdi.InterfaceType) Type(com.sun.jdi.Type) ClassType(com.sun.jdi.ClassType) ArrayType(com.sun.jdi.ArrayType) PrimitiveType(com.sun.jdi.PrimitiveType) BooleanType(com.sun.jdi.BooleanType) ReferenceType(com.sun.jdi.ReferenceType) Method(com.sun.jdi.Method)

Example 14 with Method

use of com.sun.jdi.Method in project gravel by gravel-st.

the class VMTargetStarter method installHaltPoint.

private void installHaltPoint(VirtualMachine vm) {
    List<ReferenceType> targetClasses = vm.classesByName(VMLocalTarget.class.getName());
    ReferenceType classRef = targetClasses.get(0);
    Method meth = classRef.methodsByName("haltPoint").get(0);
    BreakpointRequest req = vm.eventRequestManager().createBreakpointRequest(meth.location());
    req.setSuspendPolicy(BreakpointRequest.SUSPEND_EVENT_THREAD);
    req.enable();
}
Also used : BreakpointRequest(com.sun.jdi.request.BreakpointRequest) Method(com.sun.jdi.Method) ReferenceType(com.sun.jdi.ReferenceType)

Example 15 with Method

use of com.sun.jdi.Method in project intellij-community by JetBrains.

the class BasicStepMethodFilter method locationMatches.

public boolean locationMatches(final DebugProcessImpl process, final Location location) throws EvaluateException {
    Method method = location.method();
    String name = method.name();
    if (!myTargetMethodName.equals(name)) {
        if (DebuggerUtilsEx.isLambdaName(name)) {
            SourcePosition position = process.getPositionManager().getSourcePosition(location);
            return ReadAction.compute(() -> {
                PsiElement psiMethod = DebuggerUtilsEx.getContainingMethod(position);
                if (psiMethod instanceof PsiLambdaExpression) {
                    PsiType type = ((PsiLambdaExpression) psiMethod).getFunctionalInterfaceType();
                    PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(type);
                    if (type != null && interfaceMethod != null && myTargetMethodName.equals(interfaceMethod.getName())) {
                        try {
                            return InheritanceUtil.isInheritor(type, myDeclaringClassName.getName(process).replace('$', '.'));
                        } catch (EvaluateException e) {
                            LOG.info(e);
                        }
                    }
                }
                return false;
            });
        }
        return false;
    }
    if (myTargetMethodSignature != null && !signatureMatches(method, myTargetMethodSignature.getName(process))) {
        return false;
    }
    if (method.isBridge()) {
        // skip bridge methods
        return false;
    }
    return DebuggerUtilsEx.isAssignableFrom(myDeclaringClassName.getName(process), location.declaringType());
}
Also used : EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) SourcePosition(com.intellij.debugger.SourcePosition) Method(com.sun.jdi.Method)

Aggregations

Method (com.sun.jdi.Method)19 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)5 Location (com.sun.jdi.Location)5 ReferenceType (com.sun.jdi.ReferenceType)5 ClassType (com.sun.jdi.ClassType)4 SourcePosition (com.intellij.debugger.SourcePosition)3 Nullable (org.jetbrains.annotations.Nullable)3 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)2 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)2 VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)2 Project (com.intellij.openapi.project.Project)2 AbsentInformationException (com.sun.jdi.AbsentInformationException)2 ClassNotLoadedException (com.sun.jdi.ClassNotLoadedException)2 IncompatibleThreadStateException (com.sun.jdi.IncompatibleThreadStateException)2 InterfaceType (com.sun.jdi.InterfaceType)2 InvocationException (com.sun.jdi.InvocationException)2 ObjectReference (com.sun.jdi.ObjectReference)2 Value (com.sun.jdi.Value)2 BreakpointRequest (com.sun.jdi.request.BreakpointRequest)2 JVMName (com.intellij.debugger.engine.JVMName)1