@Override
    public void paused(final SuspendContextImpl suspendContext) {
      LOG.debug("paused");

      ThreadReferenceProxyImpl currentThread = suspendContext.getEventThread();

      if (!shouldSetAsActiveContext(suspendContext)) {
        notifyThreadsRefresh();
        ThreadReferenceProxyImpl thread = suspendContext.getEventThread();
        if (thread != null) {
          List<Pair<Breakpoint, com.sun.jdi.event.Event>> descriptors = DebuggerUtilsEx.getEventDescriptors(suspendContext);
          if (!descriptors.isEmpty()) {
            XDebuggerManagerImpl.getNotificationGroup().createNotification(
                JavaDebuggerBundle.message("status.breakpoint.reached.in.thread", thread.name()),
                JavaDebuggerBundle.message("status.breakpoint.reached.in.thread.switch"),
                NotificationType.INFORMATION)
              .setListener(new BreakpointReachedNotificationListener(suspendContext))
              .notify(getProject());
          }
        }
        if (myDebugProcess.getSuspendManager().getPausedContexts().size() > 1) {
          return;
        }
        else {
          currentThread = mySteppingThroughThread.get();
        }
      }
      else {
        setSteppingThrough(currentThread);
      }

      final StackFrameContext positionContext;
      SourcePosition position;

      if (currentThread == null) {
        //Pause pressed
        LOG.assertTrue(suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_ALL);
        SuspendContextImpl oldContext = getProcess().getSuspendManager().getPausedContext();

        if (oldContext != null) {
          currentThread = oldContext.getThread();
        }

        if (currentThread == null) {
          Collection<ThreadReferenceProxyImpl> allThreads = suspendContext.getVirtualMachine().allThreads();
          ThreadReferenceProxyImpl lastThread = myLastThread.get();
          if (lastThread != null && allThreads.contains(lastThread)) {
            currentThread = lastThread;
          }
          else {
            // heuristics: try to pre-select EventDispatchThread
            currentThread = ContainerUtil.find(allThreads, thread -> ThreadDumper.isEDT(thread.name()));
            if (currentThread == null) {
              // heuristics: try to pre-select the main thread
              currentThread = ContainerUtil.find(allThreads, thread -> "main".equals(thread.name()));
            }
            if (currentThread == null) {
              // heuristics: display the first thread with RUNNABLE status
              for (final ThreadReferenceProxyImpl thread : allThreads) {
                currentThread = thread;
                try {
                  if (currentThread.status() == ThreadReference.THREAD_STATUS_RUNNING && currentThread.frameCount() > 0) {
                    break;
                  }
                }
                catch (EvaluateException ignored) {
                }
              }
            }
          }
        }

        StackFrameProxyImpl proxy = null;
        if (currentThread != null) {
          try {
            while (!currentThread.isSuspended()) {
              // Wait until the thread is considered suspended.
              // Querying data from a thread immediately after VM.suspend() may result in IncompatibleThreadStateException,
              // most likely because some time after suspend() VM erroneously thinks that the thread is still running.
              TimeoutUtil.sleep(10);
            }
            proxy = (currentThread.frameCount() > 0) ? currentThread.frame(0) : null;
          }
          catch (ObjectCollectedException ignored) {
            proxy = null;
          }
          catch (EvaluateException e) {
            proxy = null;
            LOG.error(e);
          }
        }
        positionContext = new SimpleStackFrameContext(proxy, myDebugProcess);
        position = ContextUtil.getSourcePosition(positionContext);
      }
      else {
        positionContext = suspendContext;
        position = myDebugProcess.getPositionManager().getSourcePosition(suspendContext.getLocation());
      }

      if (currentThread != null) {
        try {
          final int frameCount = currentThread.frameCount();
          if (frameCount == 0 || (frameCount <= myIgnoreFiltersFrameCountThreshold)) {
            resetIgnoreStepFiltersFlag();
          }
        }
        catch (EvaluateException e) {
          LOG.info(e);
          resetIgnoreStepFiltersFlag();
        }
      }

      if (position != null) {
        final List<Pair<Breakpoint, com.sun.jdi.event.Event>> eventDescriptors = DebuggerUtilsEx.getEventDescriptors(suspendContext);
        final RequestManagerImpl requestsManager = suspendContext.getDebugProcess().getRequestsManager();
        final PsiFile foundFile = position.getFile();
        final boolean sourceMissing = foundFile instanceof PsiCompiledElement;
        for (Pair<Breakpoint, com.sun.jdi.event.Event> eventDescriptor : eventDescriptors) {
          Breakpoint breakpoint = eventDescriptor.getFirst();
          if (breakpoint instanceof LineBreakpoint) {
            final SourcePosition breakpointPosition = ((BreakpointWithHighlighter<?>)breakpoint).getSourcePosition();
            if (breakpointPosition == null || (!sourceMissing && breakpointPosition.getLine() != position.getLine())) {
              requestsManager.deleteRequest(breakpoint);
              requestsManager.setInvalid(breakpoint, JavaDebuggerBundle.message("error.invalid.breakpoint.source.changed"));
              breakpoint.updateUI();
            }
            else if (sourceMissing) {
              // Adjust the position to be the position of the breakpoint in order to show the real originator of the event.
              position = breakpointPosition;
              final StackFrameProxy frameProxy = positionContext.getFrameProxy();
              String className;
              try {
                className = frameProxy != null ? frameProxy.location().declaringType().name() : "";
              }
              catch (EvaluateException ignored) {
                className = "";
              }
              requestsManager.setInvalid(breakpoint, JavaDebuggerBundle.message("error.invalid.breakpoint.source.not.found", className));
              breakpoint.updateUI();
            }
          }
        }
      }

      final DebuggerContextImpl debuggerContext =
        DebuggerContextImpl.createDebuggerContext(DebuggerSession.this, suspendContext, currentThread, null);
      if (suspendContext.getThread() == currentThread) {
        debuggerContext.setPositionCache(position);
      }

      DebuggerInvocationUtil.invokeLater(getProject(), () -> getContextManager().setState(debuggerContext, State.PAUSED, Event.PAUSE,
                                                                                          getDescription(debuggerContext)));
    }
@Override
    public void paused(final SuspendContextImpl suspendContext)