Search in sources :

Example 1 with ProgressWindowWithNotification

use of com.intellij.openapi.progress.util.ProgressWindowWithNotification in project intellij-community by JetBrains.

the class MethodBreakpoint method createRequestForSubClasses.

private static void createRequestForSubClasses(@NotNull MethodBreakpointBase breakpoint, @NotNull DebugProcessImpl debugProcess, @NotNull ReferenceType baseType) {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    RequestManagerImpl requestsManager = debugProcess.getRequestsManager();
    ClassPrepareRequest request = requestsManager.createClassPrepareRequest((debuggerProcess, referenceType) -> {
        if (instanceOf(referenceType, baseType)) {
            createRequestForPreparedClassEmulated(breakpoint, debugProcess, referenceType, false);
        }
    }, null);
    if (request != null) {
        requestsManager.registerRequest(breakpoint, request);
        request.enable();
        // to force reload classes available so far
        debugProcess.getVirtualMachineProxy().clearCaches();
    }
    AtomicReference<ProgressIndicator> indicatorRef = new AtomicReference<>();
    ApplicationManager.getApplication().invokeAndWait(() -> indicatorRef.set(new ProgressWindowWithNotification(true, false, debugProcess.getProject(), "Cancel emulation")));
    ProgressIndicator indicator = indicatorRef.get();
    ProgressManager.getInstance().executeProcessUnderProgress(() -> processPreparedSubTypes(baseType, subType -> createRequestForPreparedClassEmulated(breakpoint, debugProcess, subType, false), indicator), indicator);
    if (indicator.isCanceled()) {
        breakpoint.disableEmulation();
    }
}
Also used : com.intellij.openapi.util(com.intellij.openapi.util) MethodEntryEvent(com.sun.jdi.event.MethodEntryEvent) JVMNameUtil(com.intellij.debugger.engine.JVMNameUtil) AllIcons(com.intellij.icons.AllIcons) Document(com.intellij.openapi.editor.Document) Opcodes(org.jetbrains.org.objectweb.asm.Opcodes) DebuggerUtilsEx(com.intellij.debugger.impl.DebuggerUtilsEx) EventRequest(com.sun.jdi.request.EventRequest) EvaluationContextImpl(com.intellij.debugger.engine.evaluation.EvaluationContextImpl) StringBuilderSpinAllocator(com.intellij.util.StringBuilderSpinAllocator) ProgressWindowWithNotification(com.intellij.openapi.progress.util.ProgressWindowWithNotification) Logger(com.intellij.openapi.diagnostic.Logger) MultiMap(com.intellij.util.containers.MultiMap) MethodEntryRequest(com.sun.jdi.request.MethodEntryRequest) DebuggerManagerThreadImpl(com.intellij.debugger.engine.DebuggerManagerThreadImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) ProgressManager(com.intellij.openapi.progress.ProgressManager) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) MethodExitRequest(com.sun.jdi.request.MethodExitRequest) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) PositionUtil(com.intellij.debugger.impl.PositionUtil) MethodExitEvent(com.sun.jdi.event.MethodExitEvent) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) Nullable(org.jetbrains.annotations.Nullable) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) List(java.util.List) Stream(java.util.stream.Stream) StreamEx(one.util.streamex.StreamEx) ApplicationManager(com.intellij.openapi.application.ApplicationManager) Requestor(com.intellij.debugger.requests.Requestor) com.intellij.psi(com.intellij.psi) NotNull(org.jetbrains.annotations.NotNull) SourcePosition(com.intellij.debugger.SourcePosition) LocatableEvent(com.sun.jdi.event.LocatableEvent) Label(org.jetbrains.org.objectweb.asm.Label) NonNls(org.jetbrains.annotations.NonNls) MethodBytecodeUtil(com.intellij.debugger.jdi.MethodBytecodeUtil) ContainerUtil(com.intellij.util.containers.ContainerUtil) AtomicReference(java.util.concurrent.atomic.AtomicReference) RequestManagerImpl(com.intellij.debugger.engine.requests.RequestManagerImpl) Project(com.intellij.openapi.project.Project) DebuggerBundle(com.intellij.debugger.DebuggerBundle) JavaMethodBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties) MethodVisitor(org.jetbrains.org.objectweb.asm.MethodVisitor) JVMName(com.intellij.debugger.engine.JVMName) Consumer(java.util.function.Consumer) ClassPrepareRequest(com.sun.jdi.request.ClassPrepareRequest) DebuggerManagerEx(com.intellij.debugger.DebuggerManagerEx) com.sun.jdi(com.sun.jdi) Element(org.jdom.Element) javax.swing(javax.swing) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) ProgressWindowWithNotification(com.intellij.openapi.progress.util.ProgressWindowWithNotification) AtomicReference(java.util.concurrent.atomic.AtomicReference) RequestManagerImpl(com.intellij.debugger.engine.requests.RequestManagerImpl) ClassPrepareRequest(com.sun.jdi.request.ClassPrepareRequest)

Example 2 with ProgressWindowWithNotification

use of com.intellij.openapi.progress.util.ProgressWindowWithNotification in project intellij-community by JetBrains.

the class JavaWithRuntimeCastSurrounder method surroundExpression.

public TextRange surroundExpression(Project project, Editor editor, PsiExpression expr) throws IncorrectOperationException {
    DebuggerContextImpl debuggerContext = (DebuggerManagerEx.getInstanceEx(project)).getContext();
    DebuggerSession debuggerSession = debuggerContext.getDebuggerSession();
    if (debuggerSession != null) {
        final ProgressWindowWithNotification progressWindow = new ProgressWindowWithNotification(true, expr.getProject());
        SurroundWithCastWorker worker = new SurroundWithCastWorker(editor, expr, debuggerContext, progressWindow);
        progressWindow.setTitle(DebuggerBundle.message("title.evaluating"));
        debuggerContext.getDebugProcess().getManagerThread().startProgress(worker, progressWindow);
    }
    return null;
}
Also used : DebuggerSession(com.intellij.debugger.impl.DebuggerSession) ProgressWindowWithNotification(com.intellij.openapi.progress.util.ProgressWindowWithNotification) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl)

Example 3 with ProgressWindowWithNotification

use of com.intellij.openapi.progress.util.ProgressWindowWithNotification in project intellij-community by JetBrains.

the class JavaValueModifier method set.

protected void set(@NotNull final String expression, final XModificationCallback callback, final DebuggerContextImpl debuggerContext, final SetValueRunnable setValueRunnable) {
    final ProgressWindowWithNotification progressWindow = new ProgressWindowWithNotification(true, debuggerContext.getProject());
    final EvaluationContextImpl evaluationContext = myJavaValue.getEvaluationContext();
    SuspendContextCommandImpl askSetAction = new DebuggerContextCommandImpl(debuggerContext) {

        public Priority getPriority() {
            return Priority.HIGH;
        }

        public void threadAction(@NotNull SuspendContextImpl suspendContext) {
            ExpressionEvaluator evaluator;
            try {
                Project project = evaluationContext.getProject();
                SourcePosition position = ContextUtil.getSourcePosition(evaluationContext);
                PsiElement context = ContextUtil.getContextElement(evaluationContext, position);
                evaluator = DebuggerInvocationUtil.commitAndRunReadAction(project, new EvaluatingComputable<ExpressionEvaluator>() {

                    public ExpressionEvaluator compute() throws EvaluateException {
                        return EvaluatorBuilderImpl.build(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, expression), context, position, project);
                    }
                });
                setValue(expression, evaluator, evaluationContext, new SetValueRunnable() {

                    public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException, IncompatibleThreadStateException {
                        if (!progressWindow.isCanceled()) {
                            setValueRunnable.setValue(evaluationContext, newValue);
                        //node.calcValue();
                        }
                    }

                    public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, EvaluateException, IncompatibleThreadStateException, InvalidTypeException {
                        return setValueRunnable.loadClass(evaluationContext, className);
                    }
                });
                callback.valueModified();
            } catch (EvaluateException e) {
                callback.errorOccurred(e.getMessage());
            }
        //String initialString = "";
        //if (descriptor instanceof ValueDescriptorImpl) {
        //  Value currentValue = ((ValueDescriptorImpl) descriptor).getValue();
        //  if (currentValue instanceof StringReference) {
        //    initialString = DebuggerUtilsEx.getValueOrErrorAsString(debuggerContext.createEvaluationContext(), currentValue);
        //    initialString = initialString == null ? "" : "\"" + DebuggerUtilsEx.translateStringValue(initialString) + "\"";
        //  }
        //  else if (currentValue instanceof PrimitiveValue) {
        //    ValueLabelRenderer renderer = ((ValueDescriptorImpl) descriptor).getRenderer(debuggerContext.getDebugProcess());
        //    initialString = getDisplayableString((PrimitiveValue) currentValue, renderer instanceof NodeRenderer && HexRenderer.UNIQUE_ID.equals(renderer.getUniqueId()));
        //  }
        //
        //  final String initialString1 = initialString;
        //  final Project project = debuggerContext.getProject();
        //  DebuggerInvocationUtil.swingInvokeLater(project, new Runnable() {
        //    public void run() {
        //      showEditor(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, initialString1), node, debuggerContext, setValueRunnable);
        //    }
        //  });
        //}
        }
    };
    progressWindow.setTitle(DebuggerBundle.message("title.evaluating"));
    evaluationContext.getDebugProcess().getManagerThread().startProgress(askSetAction, progressWindow);
}
Also used : ProgressWindowWithNotification(com.intellij.openapi.progress.util.ProgressWindowWithNotification) SuspendContextCommandImpl(com.intellij.debugger.engine.events.SuspendContextCommandImpl) NotNull(org.jetbrains.annotations.NotNull) EvaluatingComputable(com.intellij.debugger.EvaluatingComputable) Project(com.intellij.openapi.project.Project) SourcePosition(com.intellij.debugger.SourcePosition) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl) PsiElement(com.intellij.psi.PsiElement)

Aggregations

ProgressWindowWithNotification (com.intellij.openapi.progress.util.ProgressWindowWithNotification)3 SourcePosition (com.intellij.debugger.SourcePosition)2 Project (com.intellij.openapi.project.Project)2 NotNull (org.jetbrains.annotations.NotNull)2 DebuggerBundle (com.intellij.debugger.DebuggerBundle)1 DebuggerManagerEx (com.intellij.debugger.DebuggerManagerEx)1 EvaluatingComputable (com.intellij.debugger.EvaluatingComputable)1 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)1 DebuggerManagerThreadImpl (com.intellij.debugger.engine.DebuggerManagerThreadImpl)1 JVMName (com.intellij.debugger.engine.JVMName)1 JVMNameUtil (com.intellij.debugger.engine.JVMNameUtil)1 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)1 EvaluationContextImpl (com.intellij.debugger.engine.evaluation.EvaluationContextImpl)1 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)1 SuspendContextCommandImpl (com.intellij.debugger.engine.events.SuspendContextCommandImpl)1 RequestManagerImpl (com.intellij.debugger.engine.requests.RequestManagerImpl)1 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)1 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)1 DebuggerUtilsEx (com.intellij.debugger.impl.DebuggerUtilsEx)1 PositionUtil (com.intellij.debugger.impl.PositionUtil)1