1 package com.jetbrains.python.edu.debugger;
3 import com.google.common.base.Predicate;
4 import com.google.common.collect.Collections2;
5 import com.intellij.execution.process.ProcessHandler;
6 import com.intellij.execution.ui.ExecutionConsole;
7 import com.intellij.xdebugger.XDebugSession;
8 import com.jetbrains.python.PythonHelpersLocator;
9 import com.jetbrains.python.debugger.*;
10 import org.jetbrains.annotations.NotNull;
11 import org.jetbrains.annotations.Nullable;
13 import java.net.ServerSocket;
14 import java.util.ArrayList;
15 import java.util.Collection;
16 import java.util.Collections;
17 import java.util.List;
19 class PyEduDebugProcess extends PyDebugProcess {
21 private final String myScriptName;
22 private final int myLine;
24 public PyEduDebugProcess(@NotNull XDebugSession session,
25 @NotNull ServerSocket serverSocket,
26 @NotNull ExecutionConsole executionConsole,
27 @Nullable ProcessHandler processHandler, boolean multiProcess,
30 super(session, serverSocket, executionConsole, processHandler, multiProcess);
31 myScriptName = scriptName;
36 public PyStackFrame createStackFrame(PyStackFrameInfo frameInfo) {
37 return new PyEduStackFrame(getSession().getProject(), this, frameInfo,
38 getPositionConverter().convertFromPython(frameInfo.getPosition()));
44 addTemporaryBreakpoint(PyLineBreakpointType.ID, myScriptName, myLine);
49 protected PySuspendContext createSuspendContext(PyThreadInfo threadInfo) {
50 threadInfo.updateState(threadInfo.getState(), new ArrayList<PyStackFrameInfo>(filterFrames(threadInfo.getFrames())));
51 return new PySuspendContext(this, threadInfo);
54 public Collection<PyStackFrameInfo> filterFrames(@Nullable List<PyStackFrameInfo> frames) {
56 return Collections.emptyList();
58 final String debugger = PythonHelpersLocator.getHelperPath(PyDebugRunner.DEBUGGER_MAIN);
59 return Collections2.filter(frames, new Predicate<PyStackFrameInfo>() {
61 public boolean apply(PyStackFrameInfo frame) {
62 String file = frame.getPosition().getFile();
63 return !debugger.equals(file);