<consoleInputFilterProvider implementation="com.jetbrains.python.edu.debugger.PyEduConsoleInputFilterProvider"/>
</extensions>
- <extensions defaultExtensionNs="Pythonid">
- <debugValueTransformer implementation="com.jetbrains.python.edu.debugger.PyEduDebugTransformer"/>
- </extensions>
-
<actions>
<group overrides="true" class="com.intellij.openapi.actionSystem.EmptyActionGroup" id="ToolsMenu"/>
+++ /dev/null
-package com.jetbrains.python.edu.debugger;
-
-import com.intellij.util.containers.hash.HashMap;
-import com.intellij.xdebugger.frame.XValue;
-import com.intellij.xdebugger.frame.XValueChildrenList;
-import com.jetbrains.python.debugger.PyDebugValueTransformer;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Map;
-
-public class PyEduDebugTransformer implements PyDebugValueTransformer {
- @Override
- public XValueChildrenList getTransformedChildren(@NotNull XValueChildrenList children) {
- XValueChildrenList list = new XValueChildrenList();
- Map<String, XValue> magicValues = new HashMap<String, XValue>();
- for (int i = 0; i < children.size(); i++) {
- String name = children.getName(i);
- XValue value = children.getValue(i);
- if (name.startsWith("__") && name.endsWith("__")) {
- magicValues.put(name, value);
- }
- else {
- list.add(name, value);
- }
- }
- if (!magicValues.isEmpty()) {
- list.add(new PyEduMagicDebugValue("magic variables", magicValues));
- }
- return list;
- }
-}
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.ColoredTextContainer;
import com.intellij.ui.SimpleTextAttributes;
+import com.intellij.util.containers.hash.HashMap;
import com.intellij.xdebugger.XSourcePosition;
+import com.intellij.xdebugger.frame.XCompositeNode;
+import com.intellij.xdebugger.frame.XValue;
+import com.intellij.xdebugger.frame.XValueChildrenList;
import com.jetbrains.python.debugger.PyFrameAccessor;
import com.jetbrains.python.debugger.PyStackFrame;
import com.jetbrains.python.debugger.PyStackFrameInfo;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Map;
public class PyEduStackFrame extends PyStackFrame {
public static final String MODULE = "<module>";
public static final String GLOBAL_FRAME = "Globals";
+ public static final String DOUBLE_UNDERSCORE = "__";
private final PyStackFrameInfo myFrameInfo;
private final XSourcePosition myPosition;
.append(MODULE.equals(frameName) ? GLOBAL_FRAME : frameName, regularAttributes);
}
}
+
+ @Override
+ protected void addChildren(@NotNull final XCompositeNode node,
+ @Nullable final XValueChildrenList children) {
+ Map<String, XValue> specialValues = new HashMap<String, XValue>();
+ XValueChildrenList newChildren = new XValueChildrenList();
+ if (children == null) {
+ node.addChildren(XValueChildrenList.EMPTY, true);
+ return;
+ }
+ for (int i = 0; i < children.size(); i++) {
+ String name = children.getName(i);
+ XValue value = children.getValue(i);
+ if (name.startsWith(DOUBLE_UNDERSCORE) && name.endsWith(DOUBLE_UNDERSCORE)) {
+ specialValues.put(name, value);
+ }
+ else {
+ newChildren.add(name, value);
+ }
+ }
+ if (!specialValues.isEmpty()) {
+ newChildren.add(new PyEduMagicDebugValue("special variables", specialValues));
+ }
+ node.addChildren(newChildren, true);
+ }
}
<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.debugValueTransformer" interface="com.jetbrains.python.debugger.PyDebugValueTransformer"/>
</extensionPoints>
<extensions defaultExtensionNs="Pythonid">
+++ /dev/null
-/*
- * 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.debugger;
-
-import com.intellij.openapi.extensions.ExtensionPointName;
-import com.intellij.xdebugger.frame.XValueChildrenList;
-import org.jetbrains.annotations.NotNull;
-
-public interface 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
- * @param children
- * @return modified children list
- */
- XValueChildrenList getTransformedChildren(@NotNull final XValueChildrenList children);
-}
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.xdebugger.frame.XStackFrame;
import com.intellij.xdebugger.frame.XValueChildrenList;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
public class PyStackFrame extends XStackFrame {
try {
XValueChildrenList values = myDebugProcess.loadFrame();
if (!node.isObsolete()) {
- if (values == null) {
- node.addChildren(XValueChildrenList.EMPTY, true);
- return;
- }
- for (PyDebugValueTransformer transformer : Extensions.getExtensions(PyDebugValueTransformer.EP_NAME)) {
- values = transformer.getTransformedChildren(values);
- }
- node.addChildren(values, true);
+ addChildren(node, values);
}
}
catch (PyDebuggerException e) {
});
}
+ protected void addChildren(@NotNull final XCompositeNode node, @Nullable final XValueChildrenList children) {
+ node.addChildren(children != null ? children : XValueChildrenList.EMPTY, true);
+ }
+
public String getThreadId() {
return myFrameInfo.getThreadId();
}