Search in sources :

Example 1 with XStackFrame

use of com.intellij.xdebugger.frame.XStackFrame in project intellij-community by JetBrains.

the class AlternativeSourceNotificationProvider method createNotificationPanel.

@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
    if (!DebuggerSettings.getInstance().SHOW_ALTERNATIVE_SOURCE) {
        return null;
    }
    XDebugSession session = XDebuggerManager.getInstance(myProject).getCurrentSession();
    if (session == null) {
        FILE_PROCESSED_KEY.set(file, null);
        return null;
    }
    XSourcePosition position = session.getCurrentPosition();
    if (position == null || !file.equals(position.getFile())) {
        FILE_PROCESSED_KEY.set(file, null);
        return null;
    }
    final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
    if (psiFile == null)
        return null;
    if (!(psiFile instanceof PsiJavaFile))
        return null;
    PsiClass[] classes = ((PsiJavaFile) psiFile).getClasses();
    if (classes.length == 0)
        return null;
    PsiClass baseClass = classes[0];
    String name = baseClass.getQualifiedName();
    if (name == null)
        return null;
    if (DumbService.getInstance(myProject).isDumb())
        return null;
    ArrayList<PsiClass> alts = ContainerUtil.newArrayList(JavaPsiFacade.getInstance(myProject).findClasses(name, GlobalSearchScope.allScope(myProject)));
    ContainerUtil.removeDuplicates(alts);
    FILE_PROCESSED_KEY.set(file, true);
    if (alts.size() > 1) {
        for (PsiClass cls : alts) {
            if (cls.equals(baseClass) || cls.getNavigationElement().equals(baseClass)) {
                alts.remove(cls);
                break;
            }
        }
        alts.add(0, baseClass);
        ComboBoxClassElement[] elems = ContainerUtil.map2Array(alts, ComboBoxClassElement.class, psiClass -> new ComboBoxClassElement((PsiClass) psiClass.getNavigationElement()));
        String locationDeclName = null;
        XStackFrame frame = session.getCurrentStackFrame();
        if (frame instanceof JavaStackFrame) {
            Location location = ((JavaStackFrame) frame).getDescriptor().getLocation();
            if (location != null) {
                locationDeclName = location.declaringType().name();
            }
        }
        return new AlternativeSourceNotificationPanel(elems, baseClass, myProject, file, locationDeclName);
    }
    return null;
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) XStackFrame(com.intellij.xdebugger.frame.XStackFrame) JavaStackFrame(com.intellij.debugger.engine.JavaStackFrame) XSourcePosition(com.intellij.xdebugger.XSourcePosition) Location(com.sun.jdi.Location) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with XStackFrame

use of com.intellij.xdebugger.frame.XStackFrame in project intellij-community by JetBrains.

the class JavaExecutionStack method createStackFrame.

private static XStackFrame createStackFrame(@NotNull StackFrameProxyImpl stackFrameProxy, @NotNull MethodsTracker tracker) {
    StackFrameDescriptorImpl descriptor = new StackFrameDescriptorImpl(stackFrameProxy, tracker);
    DebugProcessImpl debugProcess = (DebugProcessImpl) descriptor.getDebugProcess();
    Location location = descriptor.getLocation();
    if (location != null) {
        XStackFrame customFrame = debugProcess.getPositionManager().createStackFrame(stackFrameProxy, debugProcess, location);
        if (customFrame != null) {
            return customFrame;
        }
    }
    return new JavaStackFrame(descriptor, true);
}
Also used : StackFrameDescriptorImpl(com.intellij.debugger.ui.impl.watch.StackFrameDescriptorImpl) XStackFrame(com.intellij.xdebugger.frame.XStackFrame) Location(com.sun.jdi.Location)

Example 3 with XStackFrame

use of com.intellij.xdebugger.frame.XStackFrame in project intellij-community by JetBrains.

the class XFramesView method processSessionEvent.

@Override
public void processSessionEvent(@NotNull SessionEvent event, @NotNull XDebugSession session) {
    myRefresh = event == SessionEvent.SETTINGS_CHANGED;
    if (event == SessionEvent.BEFORE_RESUME) {
        return;
    }
    XStackFrame currentStackFrame = session.getCurrentStackFrame();
    XSuspendContext suspendContext = session.getSuspendContext();
    if (event == SessionEvent.FRAME_CHANGED) {
        ApplicationManager.getApplication().assertIsDispatchThread();
        if (currentStackFrame != null) {
            myFramesList.setSelectedValue(currentStackFrame, true);
            mySelectedFrameIndex = myFramesList.getSelectedIndex();
            myExecutionStacksWithSelection.put(mySelectedStack, mySelectedFrameIndex);
        }
        return;
    }
    myLaterInvocator.offer(() -> {
        if (event != SessionEvent.SETTINGS_CHANGED) {
            mySelectedFrameIndex = 0;
            mySelectedStack = null;
            myVisibleRect = null;
        } else {
            myVisibleRect = myFramesList.getVisibleRect();
        }
        myListenersEnabled = false;
        myBuilders.values().forEach(StackFramesListBuilder::dispose);
        myBuilders.clear();
        if (suspendContext == null) {
            requestClear();
            return;
        }
        if (event == SessionEvent.PAUSED) {
            // clear immediately
            cancelClear();
            clear();
        }
        XExecutionStack[] executionStacks = suspendContext.getExecutionStacks();
        addExecutionStacks(Arrays.asList(executionStacks));
        XExecutionStack activeExecutionStack = mySelectedStack != null ? mySelectedStack : suspendContext.getActiveExecutionStack();
        myThreadComboBox.setSelectedItem(activeExecutionStack);
        myThreadsPanel.removeAll();
        myThreadsPanel.add(myToolbar.getComponent(), BorderLayout.EAST);
        final boolean invisible = executionStacks.length == 1 && StringUtil.isEmpty(executionStacks[0].getDisplayName());
        if (!invisible) {
            myThreadsPanel.add(myThreadComboBox, BorderLayout.CENTER);
        }
        myToolbar.setAddSeparatorFirst(!invisible);
        updateFrames(activeExecutionStack, session);
    });
}
Also used : XSuspendContext(com.intellij.xdebugger.frame.XSuspendContext) XStackFrame(com.intellij.xdebugger.frame.XStackFrame) XExecutionStack(com.intellij.xdebugger.frame.XExecutionStack)

Example 4 with XStackFrame

use of com.intellij.xdebugger.frame.XStackFrame in project intellij-plugins by JetBrains.

the class DartPopFrameAction method getStackFrame.

@Nullable
private static DartVmServiceStackFrame getStackFrame(@NotNull final AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null)
        return null;
    XDebugSession session = e.getData(XDebugSession.DATA_KEY);
    if (session == null) {
        session = XDebuggerManager.getInstance(project).getCurrentSession();
    }
    if (session != null) {
        XStackFrame frame = session.getCurrentStackFrame();
        if (frame instanceof DartVmServiceStackFrame) {
            return ((DartVmServiceStackFrame) frame);
        }
    }
    return null;
}
Also used : Project(com.intellij.openapi.project.Project) XDebugSession(com.intellij.xdebugger.XDebugSession) DartVmServiceStackFrame(com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartVmServiceStackFrame) XStackFrame(com.intellij.xdebugger.frame.XStackFrame) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with XStackFrame

use of com.intellij.xdebugger.frame.XStackFrame in project intellij-plugins by JetBrains.

the class VmServiceWrapper method computeStackFrames.

public void computeStackFrames(@NotNull final String isolateId, final int firstFrameIndex, @NotNull final XExecutionStack.XStackFrameContainer container, @Nullable final InstanceRef exception) {
    addRequest(() -> myVmService.getStack(isolateId, new StackConsumer() {

        @Override
        public void received(final Stack vmStack) {
            ApplicationManager.getApplication().executeOnPooledThread(() -> {
                InstanceRef exceptionToAddToFrame = exception;
                // Check to see if the VM passing in awaiter frames; if so, use them. Else check
                // for async causal frames. Finally, fall back to using regular sync frames.
                ElementList<Frame> elementList = vmStack.getAwaiterFrames();
                if (elementList == null) {
                    elementList = vmStack.getAsyncCausalFrames();
                    if (elementList == null) {
                        elementList = vmStack.getFrames();
                    }
                }
                final List<Frame> vmFrames = Lists.newArrayList(elementList);
                final List<XStackFrame> xStackFrames = new ArrayList<>(vmFrames.size());
                for (final Frame vmFrame : vmFrames) {
                    if (vmFrame.getKind() == FrameKind.AsyncSuspensionMarker) {
                        // Render an asynchronous gap.
                        final XStackFrame markerFrame = new DartAsyncMarkerFrame();
                        xStackFrames.add(markerFrame);
                    } else {
                        final DartVmServiceStackFrame stackFrame = new DartVmServiceStackFrame(myDebugProcess, isolateId, vmFrame, vmFrames, exceptionToAddToFrame);
                        stackFrame.setIsDroppableFrame(vmFrame.getKind() == FrameKind.Regular);
                        xStackFrames.add(stackFrame);
                        if (!stackFrame.isInDartSdkPatchFile()) {
                            // The exception (if any) is added to the frame where debugger stops and to the upper frames.
                            exceptionToAddToFrame = null;
                        }
                    }
                }
                container.addStackFrames(firstFrameIndex == 0 ? xStackFrames : xStackFrames.subList(firstFrameIndex, xStackFrames.size()), true);
            });
        }

        @Override
        public void onError(final RPCError error) {
            container.errorOccurred(error.getMessage());
        }
    }));
}
Also used : XStackFrame(com.intellij.xdebugger.frame.XStackFrame) DartAsyncMarkerFrame(com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartAsyncMarkerFrame) DartVmServiceStackFrame(com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartVmServiceStackFrame) DartVmServiceStackFrame(com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartVmServiceStackFrame) ArrayList(java.util.ArrayList) XStackFrame(com.intellij.xdebugger.frame.XStackFrame) DartAsyncMarkerFrame(com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartAsyncMarkerFrame) XExecutionStack(com.intellij.xdebugger.frame.XExecutionStack)

Aggregations

XStackFrame (com.intellij.xdebugger.frame.XStackFrame)9 XExecutionStack (com.intellij.xdebugger.frame.XExecutionStack)3 XDebugSession (com.intellij.xdebugger.XDebugSession)2 XSourcePosition (com.intellij.xdebugger.XSourcePosition)2 XSuspendContext (com.intellij.xdebugger.frame.XSuspendContext)2 DartVmServiceStackFrame (com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartVmServiceStackFrame)2 Location (com.sun.jdi.Location)2 Nullable (org.jetbrains.annotations.Nullable)2 JavaStackFrame (com.intellij.debugger.engine.JavaStackFrame)1 StackFrameDescriptorImpl (com.intellij.debugger.ui.impl.watch.StackFrameDescriptorImpl)1 Editor (com.intellij.openapi.editor.Editor)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 XExpression (com.intellij.xdebugger.XExpression)1 XBreakpointProperties (com.intellij.xdebugger.breakpoints.XBreakpointProperties)1 EvaluationMode (com.intellij.xdebugger.evaluation.EvaluationMode)1 XDebuggerEditorsProvider (com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider)1 XDebuggerEvaluator (com.intellij.xdebugger.evaluation.XDebuggerEvaluator)1 XValue (com.intellij.xdebugger.frame.XValue)1 XDebuggerTree (com.intellij.xdebugger.impl.ui.tree.XDebuggerTree)1