fixed after IDEA-CR-4069
authorliana.bakradze <liana.bakradze@jetbrains.com>
Wed, 5 Aug 2015 18:44:46 +0000 (21:44 +0300)
committerliana.bakradze <liana.bakradze@jetbrains.com>
Wed, 5 Aug 2015 18:44:46 +0000 (21:44 +0300)
19 files changed:
python/edu/src/META-INF/PyCharmEduPlugin.xml
python/edu/src/com/jetbrains/python/edu/PyCharmEduInitialConfigurator.java
python/edu/src/com/jetbrains/python/edu/PyEduUtils.java
python/edu/src/com/jetbrains/python/edu/PyRunConfigurationForFileAction.java
python/edu/src/com/jetbrains/python/edu/debugger/PyEduConsoleOutputFilter.java [deleted file]
python/edu/src/com/jetbrains/python/edu/debugger/PyEduDebugExecutor.java
python/edu/src/com/jetbrains/python/edu/debugger/PyEduDebugProcess.java [new file with mode: 0644]
python/edu/src/com/jetbrains/python/edu/debugger/PyEduDebugRunner.java
python/edu/src/com/jetbrains/python/edu/debugger/PyEduFramesTransformer.java [deleted file]
python/edu/src/com/jetbrains/python/edu/debugger/PyEduMagicDebugValue.java
python/edu/src/com/jetbrains/python/edu/debugger/PyEduStackFrame.java
python/pydevSrc/com/jetbrains/python/debugger/PyFramesTransformer.java [deleted file]
python/pydevSrc/com/jetbrains/python/debugger/PyThreadInfo.java
python/src/META-INF/python-core.xml
python/src/com/jetbrains/python/console/PyConsoleOutputFilter.java [deleted file]
python/src/com/jetbrains/python/console/PythonConsoleView.java
python/src/com/jetbrains/python/debugger/PyDebugProcess.java
python/src/com/jetbrains/python/debugger/PyDebugRunner.java
python/src/com/jetbrains/python/debugger/PyDebugValueTransformer.java

index da680fc346baf397218de8800bbe7a34cff82f10..743e43a7d7790d9bda8f4a850eb83b5c40eb5614 100644 (file)
       <codeInsight.lineMarkerProvider language="Python" implementationClass="com.jetbrains.python.edu.PyDebugFileLineMarkerProvider"/>
       <codeInsight.lineMarkerProvider language="Python" implementationClass="com.jetbrains.python.edu.PyExecuteFileLineMarkerProvider"/>
       <programRunner implementation="com.jetbrains.python.edu.debugger.PyEduDebugRunner"/>
-      <executor implementation="com.jetbrains.python.edu.debugger.PyEduDebugExecutor" order="first,after run"/>>
+      <executor implementation="com.jetbrains.python.edu.debugger.PyEduDebugExecutor" order="first,after run"/>
+      <consoleInputFilterProvider implementation="com.jetbrains.python.edu.debugger.PyEduConsoleInputFilterProvider"/>
   </extensions>
 
   <extensions defaultExtensionNs="Pythonid">
-    <pyDebugValueTransformer implementation="com.jetbrains.python.edu.debugger.PyEduDebugTransformer"/>
-    <pyFramesTransformer implementation="com.jetbrains.python.edu.debugger.PyEduFramesTransformer"/>
-    <pyConsoleOutputFilter implementation="com.jetbrains.python.edu.debugger.PyEduConsoleOutputFilter"/>
+    <debugValueTransformer implementation="com.jetbrains.python.edu.debugger.PyEduDebugTransformer"/>
   </extensions>
 
   <actions>
index e0dc6544aaa0b95448c2727f0ba83161b5e2893f..73d9e9b8142bf106fd1e72f120b0cf4f25ea44e4 100644 (file)
@@ -230,8 +230,11 @@ public class PyCharmEduInitialConfigurator {
     ActionManager actionManager = ActionManager.getInstance();
     AnAction action = actionManager.getAction(actionId);
     if (action != null) {
-      ((DefaultActionGroup)actionManager.getAction(groupId)).remove(action);
-      actionManager.unregisterAction(actionId);
+      AnAction actionGroup = actionManager.getAction(groupId);
+      if (actionGroup != null && actionGroup instanceof DefaultActionGroup) {
+        ((DefaultActionGroup)actionGroup).remove(action);
+        actionManager.unregisterAction(actionId);
+      }
     }
   }
 
index afae305552bfd376f8a92a686263b8cb3ce6b9d9..bdc0d402fa401eab50fffb9520a2afbff55f2676 100644 (file)
@@ -3,29 +3,22 @@ package com.jetbrains.python.edu;
 import com.intellij.psi.PsiComment;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiWhiteSpace;
-import com.intellij.util.containers.Predicate;
 import com.jetbrains.python.psi.PyFile;
 import com.jetbrains.python.psi.PyImportStatement;
 import com.jetbrains.python.psi.PyStatement;
-import org.jetbrains.annotations.Nullable;
 
 public class PyEduUtils {
-
   public static boolean isFirstCodeLine(PsiElement element) {
-    return isFirstCodeLine(element, DEFAULT_CONDITION);
-  }
-
-  public static boolean isFirstCodeLine(PsiElement element, Predicate<PsiElement> isNothing) {
     return element instanceof PyStatement &&
            element.getParent() instanceof PyFile &&
-           !isNothing.apply(element) &&
-           nothingBefore(element, isNothing);
+           !isNothing(element) &&
+           nothingBefore(element);
   }
 
-  private static boolean nothingBefore(PsiElement element, Predicate<PsiElement> isNothing) {
+  private static boolean nothingBefore(PsiElement element) {
     element = element.getPrevSibling();
     while (element != null) {
-      if (!isNothing.apply(element)) {
+      if (!isNothing(element)) {
         return false;
       }
       element = element.getPrevSibling();
@@ -34,10 +27,7 @@ public class PyEduUtils {
     return true;
   }
 
-  private static Predicate<PsiElement> DEFAULT_CONDITION = new Predicate<PsiElement>() {
-    @Override
-    public boolean apply(@Nullable PsiElement element) {
-      return (element instanceof PsiComment) || (element instanceof PyImportStatement) || (element instanceof PsiWhiteSpace);
-    }
-  };
+  private static boolean isNothing(PsiElement element) {
+    return (element instanceof PsiComment) || (element instanceof PyImportStatement) || (element instanceof PsiWhiteSpace);
+  }
 }
index 619ebe1c95ba56da2a91727d14ccee3da02d94af..8c42fe2b43b2c5ee82ab73ac972f6dbd67d6c708 100644 (file)
@@ -16,6 +16,9 @@ public abstract class PyRunConfigurationForFileAction extends AnAction {
   public void update(AnActionEvent e) {
     Presentation presentation = e.getPresentation();
     final ConfigurationContext context = ConfigurationContext.getFromContext(e.getDataContext());
+    if (context.findExisting() == null && context.getConfiguration() == null) {
+      return;
+    }
     Location location = context.getLocation();
     if (location != null && location.getPsiElement().getContainingFile() != null && location.getPsiElement().getContainingFile().getFileType() == PythonFileType.INSTANCE) {
       presentation.setEnabled(true);
diff --git a/python/edu/src/com/jetbrains/python/edu/debugger/PyEduConsoleOutputFilter.java b/python/edu/src/com/jetbrains/python/edu/debugger/PyEduConsoleOutputFilter.java
deleted file mode 100644 (file)
index d1bde91..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.jetbrains.python.edu.debugger;
-
-import com.intellij.execution.ui.ConsoleViewContentType;
-import com.jetbrains.python.console.PyConsoleOutputFilter;
-import org.jetbrains.annotations.NotNull;
-
-public class PyEduConsoleOutputFilter implements PyConsoleOutputFilter {
-  @Override
-  public boolean reject(@NotNull String text, @NotNull ConsoleViewContentType outputType) {
-    if (outputType.equals(ConsoleViewContentType.SYSTEM_OUTPUT) && !text.contains("exit code")) {
-      return true;
-    }
-    if (text.startsWith("pydev debugger")) {
-      return true;
-    }
-    return false;
-  }
-}
index 3bf50fa25b1816bbb8a0ab1dc00669599f7ec5c3..fe9e573dd86f9b34aae817b7a7c6ea4d00c14e2c 100644 (file)
@@ -20,7 +20,7 @@ public class PyEduDebugExecutor extends DefaultDebugExecutor {
 
   @Override
   public String getContextActionId() {
-    return "EduDebugClass";
+    return "EduDebug";
   }
 
   @NotNull
diff --git a/python/edu/src/com/jetbrains/python/edu/debugger/PyEduDebugProcess.java b/python/edu/src/com/jetbrains/python/edu/debugger/PyEduDebugProcess.java
new file mode 100644 (file)
index 0000000..0904ec7
--- /dev/null
@@ -0,0 +1,67 @@
+package com.jetbrains.python.edu.debugger;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.intellij.execution.process.ProcessHandler;
+import com.intellij.execution.ui.ExecutionConsole;
+import com.intellij.xdebugger.XDebugSession;
+import com.jetbrains.python.PythonHelpersLocator;
+import com.jetbrains.python.debugger.*;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.net.ServerSocket;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+class PyEduDebugProcess extends PyDebugProcess {
+
+  private final String myScriptName;
+  private final int myLine;
+
+  public PyEduDebugProcess(@NotNull XDebugSession session,
+                           @NotNull ServerSocket serverSocket,
+                           @NotNull ExecutionConsole executionConsole,
+                           @Nullable ProcessHandler processHandler, boolean multiProcess,
+                           String scriptName,
+                           int line) {
+    super(session, serverSocket, executionConsole, processHandler, multiProcess);
+    myScriptName = scriptName;
+    myLine = line;
+  }
+
+  @Override
+  public PyStackFrame createStackFrame(PyStackFrameInfo frameInfo) {
+    return new PyEduStackFrame(getSession().getProject(), this, frameInfo,
+                               getPositionConverter().convertFromPython(frameInfo.getPosition()));
+  }
+
+  @Override
+  public void init() {
+    super.init();
+    addTemporaryBreakpoint(PyLineBreakpointType.ID, myScriptName, myLine);
+  }
+
+  @NotNull
+  @Override
+  protected PySuspendContext createSuspendContext(PyThreadInfo threadInfo) {
+    threadInfo.updateState(threadInfo.getState(), new ArrayList<PyStackFrameInfo>(filterFrames(threadInfo.getFrames())));
+    return new PySuspendContext(this, threadInfo);
+  }
+
+  public Collection<PyStackFrameInfo> filterFrames(@Nullable List<PyStackFrameInfo> frames) {
+    if (frames == null) {
+      return Collections.emptyList();
+    }
+    final String debugger = PythonHelpersLocator.getHelperPath(PyDebugRunner.DEBUGGER_MAIN);
+    return Collections2.filter(frames, new Predicate<PyStackFrameInfo>() {
+      @Override
+      public boolean apply(PyStackFrameInfo frame) {
+        String file = frame.getPosition().getFile();
+        return !debugger.equals(file);
+      }
+    });
+  }
+}
index 98071490addb0ca71135534c8b8704621d093258..15d2fc98cdea8f936cc009718c9e8dd7dde3839f 100644 (file)
@@ -1,21 +1,17 @@
 package com.jetbrains.python.edu.debugger;
 
-import com.intellij.codeInsight.daemon.impl.CollectHighlightsUtil;
 import com.intellij.execution.ExecutionResult;
 import com.intellij.execution.Executor;
 import com.intellij.execution.configurations.RunProfile;
 import com.intellij.execution.configurations.RunProfileState;
 import com.intellij.execution.filters.UrlFilter;
 import com.intellij.execution.process.ProcessHandler;
+import com.intellij.execution.runners.ExecutionEnvironment;
 import com.intellij.execution.ui.ExecutionConsole;
 import com.intellij.execution.ui.RunnerLayoutUi;
 import com.intellij.execution.ui.layout.PlaceInGrid;
 import com.intellij.icons.AllIcons;
-import com.intellij.ide.DataManager;
-import com.intellij.openapi.actionSystem.ActionPlaces;
-import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.Presentation;
+import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.fileEditor.FileDocumentManager;
 import com.intellij.openapi.module.ModuleManager;
@@ -23,28 +19,18 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.vfs.VfsUtil;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.*;
 import com.intellij.ui.content.Content;
 import com.intellij.ui.content.ContentManager;
-import com.intellij.util.containers.Predicate;
 import com.intellij.xdebugger.XDebugSession;
-import com.intellij.xdebugger.XDebuggerManager;
-import com.intellij.xdebugger.breakpoints.XBreakpointManager;
-import com.intellij.xdebugger.breakpoints.XBreakpointProperties;
+import com.intellij.xdebugger.XDebuggerBundle;
 import com.intellij.xdebugger.impl.XDebugSessionImpl;
-import com.intellij.xdebugger.impl.breakpoints.LineBreakpointState;
-import com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl;
-import com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl;
 import com.intellij.xdebugger.impl.ui.XDebugSessionTab;
-import com.jetbrains.python.PyBundle;
 import com.jetbrains.python.console.PythonDebugLanguageConsoleView;
-import com.jetbrains.python.debugger.*;
-import com.jetbrains.python.documentation.DocStringUtil;
-import com.jetbrains.python.edu.PyEduUtils;
-import com.jetbrains.python.psi.PyExpression;
-import com.jetbrains.python.psi.PyExpressionStatement;
-import com.jetbrains.python.psi.PyImportStatement;
+import com.jetbrains.python.debugger.PyDebugProcess;
+import com.jetbrains.python.debugger.PyDebugRunner;
+import com.jetbrains.python.debugger.PyLineBreakpointType;
 import com.jetbrains.python.run.PythonCommandLineState;
+import com.jetbrains.python.run.PythonRunConfiguration;
 import com.jetbrains.python.run.PythonTracebackFilter;
 import com.jetbrains.python.sdk.PythonSdkType;
 import org.jetbrains.annotations.NotNull;
@@ -52,20 +38,11 @@ import org.jetbrains.annotations.Nullable;
 
 import java.io.File;
 import java.net.ServerSocket;
-import java.util.List;
 
 public class PyEduDebugRunner extends PyDebugRunner {
-
-  public static final Predicate<PsiElement> IS_NOTHING = new Predicate<PsiElement>() {
-    @Override
-    public boolean apply(@Nullable PsiElement input) {
-      return (input instanceof PsiComment) ||
-             (input instanceof PyImportStatement) ||
-             (input instanceof PsiWhiteSpace) ||
-             (isDocString(input));
-    }
-  };
   public static final String OUTPUT = "Output";
+  private static final Logger LOG = Logger.getInstance(PyEduDebugRunner.class);
+  public static final int NO_LINE = -1;
 
   @Override
   public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
@@ -78,40 +55,54 @@ public class PyEduDebugRunner extends PyDebugRunner {
                                               ServerSocket serverSocket,
                                               ExecutionResult result,
                                               PythonCommandLineState pyState) {
-
-    return new PyEduDebugProcess(session, serverSocket, result.getExecutionConsole(), result.getProcessHandler(),
-                                 pyState.isMultiprocessDebug());
+    ExecutionConsole executionConsole = result.getExecutionConsole();
+    ProcessHandler processHandler = result.getProcessHandler();
+    boolean isMultiProcess = pyState.isMultiprocessDebug();
+    String scriptName = getScriptName(pyState);
+    if (scriptName != null) {
+      VirtualFile file = VfsUtil.findFileByIoFile(new File(scriptName), true);
+      if (file != null) {
+        int line = getBreakpointLineNumber(file, session.getProject());
+        if (line != NO_LINE) {
+          return new PyEduDebugProcess(session, serverSocket,
+                                       executionConsole, processHandler,
+                                       isMultiProcess, scriptName, line + 1);
+        }
+      }
+    }
+    LOG.info("Failed to create PyEduDebugProcess. PyDebugProcess created instead.");
+    return new PyDebugProcess(session, serverSocket, executionConsole,
+                              processHandler, isMultiProcess);
   }
 
-  @Override
-  protected void initDebugProcess(String name, PyDebugProcess pyDebugProcess) {
-    VirtualFile file = VfsUtil.findFileByIoFile(new File(name), true);
-    assert file != null;
-
-    final Project project = pyDebugProcess.getProject();
-    PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
-
-    assert psiFile != null;
+  @Nullable
+  private static String getScriptName(PythonCommandLineState pyState) {
+    ExecutionEnvironment environment = pyState.getEnvironment();
+    if (environment == null) {
+      return null;
+    }
+    RunProfile runProfile = environment.getRunProfile();
+    if (runProfile instanceof PythonRunConfiguration) {
+      return ((PythonRunConfiguration)runProfile).getScriptName();
+    }
+    return null;
+  }
 
-    List<PsiElement> psiElements = CollectHighlightsUtil.getElementsInRange(psiFile, 0, psiFile.getTextLength());
-    for (PsiElement element : psiElements) {
-      if (PyEduUtils.isFirstCodeLine(element, IS_NOTHING)) {
-        int offset = element.getTextRange().getStartOffset();
-        Document document = FileDocumentManager.getInstance().getDocument(file);
-        assert document != null;
-        int line = document.getLineNumber(offset) + 1;
-        PySourcePosition sourcePosition = pyDebugProcess.getPositionConverter().create(file.getPath(), line);
-        XBreakpointManager breakpointManager = XDebuggerManager.getInstance(project).getBreakpointManager();
-        PyLineBreakpointType type = new PyLineBreakpointType();
-        XBreakpointProperties properties = type.createBreakpointProperties(file, line);
-        LineBreakpointState<XBreakpointProperties>
-          breakpointState =
-          new LineBreakpointState<XBreakpointProperties>(true, type.getId(), file.getUrl(), line, false, file.getTimeStamp());
-        pyDebugProcess.addBreakpoint(sourcePosition, new XLineBreakpointImpl<XBreakpointProperties>(type,
-                                                                                                    ((XBreakpointManagerImpl)breakpointManager),
-                                                                                                    properties, breakpointState));
+  /**
+   * @return the smallest line (from 0 to line number) suitable to set breakpoint on it, NO_LINE if there is no such line in the file
+   */
+  private static int getBreakpointLineNumber(@NotNull final VirtualFile file, @NotNull final Project project) {
+    Document document = FileDocumentManager.getInstance().getDocument(file);
+    if (document == null) {
+      return NO_LINE;
+    }
+    PyLineBreakpointType lineBreakpointType = new PyLineBreakpointType();
+    for (int line = 0; line < document.getLineCount(); line++) {
+      if (lineBreakpointType.canPutAt(file, line, project)) {
+        return line;
       }
     }
+    return NO_LINE;
   }
 
 
@@ -121,11 +112,11 @@ public class PyEduDebugRunner extends PyDebugRunner {
     if (tab != null) {
       RunnerLayoutUi ui = tab.getUi();
       ContentManager contentManager = ui.getContentManager();
-      Content content = findContent(contentManager, "Watches");
+      Content content = findContent(contentManager, XDebuggerBundle.message("debugger.session.tab.watches.title"));
       if (content != null) {
         contentManager.removeContent(content, true);
       }
-      content = findContent(contentManager, "Console");
+      content = findContent(contentManager, XDebuggerBundle.message("debugger.session.tab.console.content.name"));
       if (content != null) {
         contentManager.removeContent(content, true);
       }
@@ -144,10 +135,10 @@ public class PyEduDebugRunner extends PyDebugRunner {
     view.addMessageFilter(new PythonTracebackFilter(project));
     view.addMessageFilter(new UrlFilter());
 
-    switchToPythonConsole(view);
+    view.enableConsole(false);
 
     Content eduConsole =
-      ui.createContent(OUTPUT, view.getComponent() , OUTPUT, AllIcons.Debugger.ToolConsole, view.getPreferredFocusableComponent());
+      ui.createContent(OUTPUT, view.getComponent(), OUTPUT, AllIcons.Debugger.ToolConsole, view.getPreferredFocusableComponent());
     eduConsole.setCloseable(false);
     ui.addContent(eduConsole, 0, PlaceInGrid.right, false);
 
@@ -155,20 +146,6 @@ public class PyEduDebugRunner extends PyDebugRunner {
     PyDebugRunner.initDebugConsoleView(project, process, view, processHandler, session);
   }
 
-  private static void switchToPythonConsole(PythonDebugLanguageConsoleView view) {
-    AnAction[] actions = view.createConsoleActions();
-    for (AnAction action : actions) {
-      Presentation presentation = action.getTemplatePresentation();
-      String text = presentation.getText();
-      if (PyBundle.message("run.configuration.show.command.line.action.name").equals(text)) {
-        AnActionEvent event =
-          AnActionEvent.createFromAnAction(action, null,
-                                           ActionPlaces.DEBUGGER_TOOLBAR, DataManager.getInstance().getDataContext(view));
-        action.actionPerformed(event);
-      }
-    }
-  }
-
   @Nullable
   private static Content findContent(ContentManager manager, String name) {
     for (Content content : manager.getContents()) {
@@ -178,30 +155,4 @@ public class PyEduDebugRunner extends PyDebugRunner {
     }
     return null;
   }
-
-
-  private static boolean isDocString(PsiElement element) {
-    if (element instanceof PyExpressionStatement) {
-      element = ((PyExpressionStatement)element).getExpression();
-    }
-    if (element instanceof PyExpression) {
-      return DocStringUtil.isDocStringExpression((PyExpression)element);
-    }
-    return false;
-  }
-
-  private static class PyEduDebugProcess extends PyDebugProcess {
-    public PyEduDebugProcess(@NotNull XDebugSession session,
-                             @NotNull ServerSocket serverSocket,
-                             @NotNull ExecutionConsole executionConsole,
-                             @Nullable ProcessHandler processHandler, boolean multiProcess) {
-      super(session, serverSocket, executionConsole, processHandler, multiProcess);
-    }
-
-    @Override
-    public PyStackFrame createStackFrame(PyStackFrameInfo frameInfo) {
-      return new PyEduStackFrame(getSession().getProject(), this, frameInfo,
-                                 getPositionConverter().convertFromPython(frameInfo.getPosition()));
-    }
-  }
 }
\ No newline at end of file
diff --git a/python/edu/src/com/jetbrains/python/edu/debugger/PyEduFramesTransformer.java b/python/edu/src/com/jetbrains/python/edu/debugger/PyEduFramesTransformer.java
deleted file mode 100644 (file)
index e83a1e3..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.jetbrains.python.edu.debugger;
-
-import com.jetbrains.python.PythonHelpersLocator;
-import com.jetbrains.python.debugger.PyDebugRunner;
-import com.jetbrains.python.debugger.PyFramesTransformer;
-import com.jetbrains.python.debugger.PyStackFrameInfo;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class PyEduFramesTransformer implements PyFramesTransformer {
-  @Nullable
-  @Override
-  public List<PyStackFrameInfo> transformFrames(@Nullable List<PyStackFrameInfo> frames) {
-    if (frames == null) {
-      return null;
-    }
-    String debugger = PythonHelpersLocator.getHelperPath(PyDebugRunner.DEBUGGER_MAIN);
-    List<PyStackFrameInfo> newFrames = new ArrayList<PyStackFrameInfo>();
-    for (PyStackFrameInfo frame : frames) {
-      String file = frame.getPosition().getFile();
-      if (!debugger.equals(file)) {
-        newFrames.add(frame);
-      }
-    }
-    return newFrames;
-  }
-}
index eebf37036dbccd88f6c42aeab74640f8c772baf0..ddb2f4df714cb61383adcfc48e1c9244ad6d0f2f 100644 (file)
@@ -8,6 +8,10 @@ import org.jetbrains.annotations.NotNull;
 
 import java.util.Map;
 
+/**
+ * Represents debug value for content that should be hidden from the python beginners
+ * (e.g. values named with double underscore prefix and postfix)
+ */
 public class PyEduMagicDebugValue extends XNamedValue {
 
   private final Map<String, XValue> myValues;
index ca3b63b13f21f509bbeb6e4a9fe45abfc83b7c3b..be496d1a31fb0eccd70df818897422213535415c 100644 (file)
@@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
 
 public class PyEduStackFrame extends PyStackFrame {
   public static final String MODULE = "<module>";
-  public static final String GLOBAL_FRAME = "Global Frame";
+  public static final String GLOBAL_FRAME = "Globals";
   private final PyStackFrameInfo myFrameInfo;
   private final XSourcePosition myPosition;
 
diff --git a/python/pydevSrc/com/jetbrains/python/debugger/PyFramesTransformer.java b/python/pydevSrc/com/jetbrains/python/debugger/PyFramesTransformer.java
deleted file mode 100644 (file)
index 302edef..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.jetbrains.python.debugger;
-
-import com.intellij.openapi.extensions.ExtensionPointName;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.List;
-
-public interface PyFramesTransformer {
-  ExtensionPointName<PyFramesTransformer> EP_NAME = ExtensionPointName.create("Pythonid.pyFramesTransformer");
-
-  @Nullable
-  List<PyStackFrameInfo> transformFrames(@Nullable List<PyStackFrameInfo> frames);
-}
index f48c27bc226c4604f486d3bfdcde90e358395673..d7a2d5fe187cd5d61f4b6a07f076170b1c3e1acf 100644 (file)
@@ -1,10 +1,8 @@
 package com.jetbrains.python.debugger;
 
-import com.intellij.openapi.extensions.Extensions;
 import com.jetbrains.python.debugger.pydev.AbstractCommand;
 import org.jetbrains.annotations.Nullable;
 
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
@@ -28,22 +26,11 @@ public class PyThreadInfo {
                       String message) {
     myId = id;
     myName = name;
-    myFrames = prepareFrames(frames);
+    myFrames = (frames != null && frames.size() > 0 ? Collections.unmodifiableList(frames) : null);
     myStopReason = stopReason;
     myMessage = message;
   }
 
-  private static List<PyStackFrameInfo> prepareFrames(List<PyStackFrameInfo> frames) {
-    if (frames == null) {
-      return null;
-    }
-    List<PyStackFrameInfo> framesCopy = new ArrayList<PyStackFrameInfo>(frames);
-    for (PyFramesTransformer transformer: Extensions.getExtensions(PyFramesTransformer.EP_NAME)) {
-      framesCopy = transformer.transformFrames(framesCopy);
-    }
-    return framesCopy != null && framesCopy.size() > 0 ? Collections.unmodifiableList(framesCopy) : null;
-  }
-
   public String getId() {
     return myId;
   }
@@ -76,7 +63,7 @@ public class PyThreadInfo {
 
   public synchronized void updateState(final State state, final List<PyStackFrameInfo> frames) {
     myState = state;
-    myFrames = prepareFrames(frames);
+    myFrames = (frames != null && frames.size() > 0 ? Collections.unmodifiableList(frames) : null);
   }
 
 
index e77452a9d3e7835dc16019bbf325c3e3e001b565..abd422fe5b3a37ebef4d7d95eb613773c8f0438d 100644 (file)
     <extensionPoint qualifiedName="Pythonid.breakpointHandler" interface="com.jetbrains.python.debugger.PyBreakpointHandlerFactory"/>
     <extensionPoint qualifiedName="Pythonid.consoleOptionsProvider" interface="com.jetbrains.python.console.PyConsoleOptionsProvider"/>
     <extensionPoint qualifiedName="Pythonid.pyRootTypeProvider" interface="com.jetbrains.python.module.PyRootTypeProvider"/>
-    <extensionPoint qualifiedName="Pythonid.pyDebugValueTransformer" interface="com.jetbrains.python.debugger.PyDebugValueTransformer"/>
-    <extensionPoint qualifiedName="Pythonid.pyFramesTransformer" interface="com.jetbrains.python.debugger.PyFramesTransformer"/>
-    <extensionPoint qualifiedName="Pythonid.pyConsoleOutputFilter" interface="com.jetbrains.python.console.PyConsoleOutputFilter"/>
+    <extensionPoint qualifiedName="Pythonid.debugValueTransformer" interface="com.jetbrains.python.debugger.PyDebugValueTransformer"/>
   </extensionPoints>
 
   <extensions defaultExtensionNs="Pythonid">
diff --git a/python/src/com/jetbrains/python/console/PyConsoleOutputFilter.java b/python/src/com/jetbrains/python/console/PyConsoleOutputFilter.java
deleted file mode 100644 (file)
index 4575943..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2000-2015 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.jetbrains.python.console;
-
-import com.intellij.execution.ui.ConsoleViewContentType;
-import com.intellij.openapi.extensions.ExtensionPointName;
-import org.jetbrains.annotations.NotNull;
-
-public interface PyConsoleOutputFilter {
-  ExtensionPointName<PyConsoleOutputFilter> EP_NAME = ExtensionPointName.create("Pythonid.pyConsoleOutputFilter");
-
-  boolean reject(@NotNull String text, @NotNull final ConsoleViewContentType outputType);
-}
index a78fc2e61401738c3fd2298510556b975cc256bb..d5ddcb6f5175b044c264b7a32985e8622c91b685 100644 (file)
@@ -25,7 +25,6 @@ import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.colors.EditorColorsScheme;
-import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.progress.ProgressIndicator;
 import com.intellij.openapi.progress.ProgressManager;
 import com.intellij.openapi.progress.Task;
@@ -178,12 +177,6 @@ public class PythonConsoleView extends LanguageConsoleImpl implements Observable
 
   @Override
   public void print(@NotNull String text, @NotNull final ConsoleViewContentType outputType) {
-    for (PyConsoleOutputFilter filter : Extensions.getExtensions(PyConsoleOutputFilter.EP_NAME)) {
-      if (filter.reject(text, outputType)) {
-        return;
-      }
-    }
-
     detectIPython(text, outputType);
     if (PyConsoleUtil.detectIPythonEnd(text)) {
       myIsIPythonOutput = false;
index 0ab8651f56fd90ee81a57aab2644c802773d3ae7..83e44db7ff2c4149cab2e2d85bf1df0f48e71f49 100644 (file)
@@ -668,6 +668,12 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr
     }
   }
 
+  public void addTemporaryBreakpoint(String typeId, String file, int line) {
+    if (isConnected()) {
+      myDebugger.setTempBreakpoint(typeId, file, line);
+    }
+  }
+
   public void removeBreakpoint(final PySourcePosition position) {
     XLineBreakpoint breakpoint = myRegisteredBreakpoints.get(position);
     if (breakpoint != null) {
@@ -703,7 +709,7 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr
 
       final List<PyStackFrameInfo> frames = threadInfo.getFrames();
       if (frames != null) {
-        final PySuspendContext suspendContext = new PySuspendContext(this, threadInfo);
+        final PySuspendContext suspendContext = createSuspendContext(threadInfo);
 
         XBreakpoint<?> breakpoint = null;
         if (threadInfo.isStopOnBreakpoint()) {
@@ -733,6 +739,11 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr
     }
   }
 
+  @NotNull
+  protected PySuspendContext createSuspendContext(PyThreadInfo threadInfo) {
+    return new PySuspendContext(this, threadInfo);
+  }
+
   @Override
   public void threadResumed(final PyThreadInfo threadInfo) {
     mySuspendedThreads.remove(threadInfo);
index 2d0c5416350fd7852f53cfae428c74094c8851ae..728936052ced33e8aa088c698a9956ed15ffb130 100644 (file)
@@ -45,7 +45,6 @@ import com.jetbrains.python.console.pydev.ConsoleCommunicationListener;
 import com.jetbrains.python.run.AbstractPythonRunConfiguration;
 import com.jetbrains.python.run.CommandLinePatcher;
 import com.jetbrains.python.run.PythonCommandLineState;
-import com.jetbrains.python.run.PythonRunConfiguration;
 import com.jetbrains.python.sdk.flavors.PythonSdkFlavor;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -102,7 +101,6 @@ public class PyDebugRunner extends GenericProgramRunner {
             createDebugProcess(session, serverSocket, result, pyState);
 
           createConsoleCommunicationAndSetupActions(environment.getProject(), result, pyDebugProcess, session);
-          initDebugProcess(((PythonRunConfiguration)environment.getRunProfile()).getScriptName(), pyDebugProcess);
           return pyDebugProcess;
         }
       });
@@ -117,9 +115,6 @@ public class PyDebugRunner extends GenericProgramRunner {
                               pyState.isMultiprocessDebug());
   }
 
-  protected void initDebugProcess(String name, PyDebugProcess pyDebugProcess) {
-  }
-
   @Override
   protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull final ExecutionEnvironment environment) throws ExecutionException {
     XDebugSession session = createSession(state, environment);
index b92802984070b1226fc423b492043eed1c8cc819..3b697d5e891e5e9ccbf5c09b36c64360ef259d3b 100644 (file)
@@ -20,7 +20,7 @@ import com.intellij.xdebugger.frame.XValueChildrenList;
 import org.jetbrains.annotations.NotNull;
 
 public interface PyDebugValueTransformer {
-  ExtensionPointName<PyDebugValueTransformer> EP_NAME = ExtensionPointName.create("Pythonid.pyDebugValueTransformer");
+  ExtensionPointName<PyDebugValueTransformer> EP_NAME = ExtensionPointName.create("Pythonid.debugValueTransformer");
 
   /**
    * This method is used in python debugger to modify content and presentation of stack frame nodes