return xml
+def get_type_qualifier(type):
+ return getattr(type, "__module__", "")
+
def var_to_xml(val, name, doTrim=True, additionalInXml=''):
""" single variable or dictionary to xml representation """
v = val
_type, typeName, resolver = get_type(v)
+ type_qualifier = get_type_qualifier(_type)
+
do_not_call_value_str = False
if isinstance(resolver, pydevd_resolver.djangoFormResolver.__class__):
name = quote(name, '/>_= ') #TODO: Fix PY-5834 without using quote
except:
pass
- xml = '<var name="%s" type="%s"' % (make_valid_xml_value(name), make_valid_xml_value(typeName))
+ xml = '<var name="%s" type="%s" qualifier="%s"' % (make_valid_xml_value(name), make_valid_xml_value(typeName), make_valid_xml_value(type_qualifier))
if value:
#cannot be too big... communication may not handle it.
package com.jetbrains.python.debugger;
+import com.google.common.base.Strings;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
private String myTempName = null;
private final String myType;
+ private final String myTypeQualifier;
private final String myValue;
private final boolean myContainer;
private final PyDebugValue myParent;
private final boolean myErrorOnEval;
- public PyDebugValue(@NotNull final String name, final String type, final String value, final boolean container,
+ public PyDebugValue(@NotNull final String name, final String type, String typeQualifier, final String value, final boolean container,
boolean errorOnEval, final PyFrameAccessor frameAccessor) {
- this(name, type, value, container, errorOnEval, null, frameAccessor);
+ this(name, type, typeQualifier, value, container, errorOnEval, null, frameAccessor);
}
- public PyDebugValue(@NotNull final String name, final String type, final String value, final boolean container,
+ public PyDebugValue(@NotNull final String name, final String type, String typeQualifier, final String value, final boolean container,
boolean errorOnEval, final PyDebugValue parent, final PyFrameAccessor frameAccessor) {
super(name);
myType = type;
+ myTypeQualifier = Strings.isNullOrEmpty(typeQualifier) ? null : typeQualifier;
myValue = value;
myContainer = container;
myErrorOnEval = errorOnEval;
}
public PyDebugValue setParent(@Nullable PyDebugValue parent) {
- return new PyDebugValue(myName, myType, myValue, myContainer, myErrorOnEval, parent, myFrameAccessor);
+ return new PyDebugValue(myName, myType, null, myValue, myContainer, myErrorOnEval, parent, myFrameAccessor);
}
public PyDebugValue getParent() {
}
public PyDebugValue setName(String newName) {
- return new PyDebugValue(newName, myType, myValue, myContainer, myErrorOnEval, myParent, myFrameAccessor);
+ return new PyDebugValue(newName, myType, null, myValue, myContainer, myErrorOnEval, myParent, myFrameAccessor);
}
@Nullable
@Override
public void computeTypeSourcePosition(@NotNull XNavigatable navigatable) {
- navigatable.setSourcePosition(myFrameAccessor.getSourcePositionForType(myType));
+
+ navigatable.setSourcePosition(myFrameAccessor.getSourcePositionForType(getQualifiedType()));
+ }
+
+ public String getQualifiedType() {
+ if (Strings.isNullOrEmpty(myType))
+ return null;
+ return (myTypeQualifier == null) ? myType : (myTypeQualifier + "." + myType);
+ }
+
+ public String getTypeQualifier() {
+ return myTypeQualifier;
}
}
public PyReferringObjectsValue(@NotNull String name,
String type,
+ String typeQualifier,
String value,
boolean container, boolean errorOnEval, @NotNull PyFrameAccessor frameAccessor) {
- super(name, type, value, container, errorOnEval, frameAccessor);
+ super(name, type, typeQualifier, value, container, errorOnEval, frameAccessor);
myReferrersLoader = frameAccessor.getReferrersLoader();
}
public PyReferringObjectsValue(PyDebugValue debugValue) {
- this(debugValue.getName(), debugValue.getType(), debugValue.getValue(), debugValue.isContainer(), debugValue.isErrorOnEval(), debugValue.getFrameAccessor());
+ this(debugValue.getName(), debugValue.getType(), debugValue.getTypeQualifier(), debugValue.getValue(), debugValue.isContainer(), debugValue.isErrorOnEval(), debugValue.getFrameAccessor());
}
@Override
}
protected PyDebugValue extend(final PyDebugValue value) {
- return new PyDebugValue(value.getName(), value.getType(), value.getValue(), value.isContainer(), value.isErrorOnEval(), null, myDebugProcess);
+ return new PyDebugValue(value.getName(), value.getType(), value.getTypeQualifier(), value.getValue(), value.isContainer(), value.isErrorOnEval(), null, myDebugProcess);
}
public XValueChildrenList getVariables() {
@Override
protected PyDebugValue extend(final PyDebugValue value) {
- return new PyDebugValue(value.getName(), value.getType(), value.getValue(), value.isContainer(), value.isErrorOnEval(), myParent,
+ return new PyDebugValue(value.getName(), value.getType(), value.getTypeQualifier(), value.getValue(), value.isContainer(), value.isErrorOnEval(), myParent,
myDebugProcess);
}
}
final String name = readString(reader, "name", null);
final String type = readString(reader, "type", null);
+ final String qualifier = readString(reader, "qualifier", null); //to be able to get the fully qualified type if necessary
+
String value = readString(reader, "value", null);
final String isContainer = readString(reader, "isContainer", "");
final String isErrorOnEval = readString(reader, "isErrorOnEval", "");
value = value.substring(type.length() + 2);
}
- return new PyDebugValue(name, type, value, "True".equals(isContainer), "True".equals(isErrorOnEval), frameAccessor);
+ return new PyDebugValue(name, type, qualifier, value, "True".equals(isContainer), "True".equals(isErrorOnEval), frameAccessor);
}
public static ArrayChunk parseArrayValues(final String text, final PyFrameAccessor frameAccessor) throws PyDebuggerException {
String max = readString(reader, "max", null);
String min = readString(reader, "min", null);
result =
- new ArrayChunk(new PyDebugValue(slice, null, null, false, false, frameAccessor), slice, rows, cols, max, min, format, type, null);
+ new ArrayChunk(new PyDebugValue(slice, null, null, null, false, false, frameAccessor), slice, rows, cols, max, min, format, type, null);
reader.moveUp();
}
import com.jetbrains.python.console.PythonDebugLanguageConsoleView;
import com.jetbrains.python.console.pydev.PydevCompletionVariant;
import com.jetbrains.python.debugger.pydev.*;
+import com.jetbrains.python.psi.PyClass;
import com.jetbrains.python.psi.PyFunction;
import com.jetbrains.python.psi.PyImportElement;
+import com.jetbrains.python.psi.PyPsiFacade;
import com.jetbrains.python.psi.resolve.PyResolveUtil;
import com.jetbrains.python.psi.types.PyClassType;
import com.jetbrains.python.psi.types.PyType;
@Nullable
@Override
public XSourcePosition getSourcePositionForName(String name) {
+ if (name == null)
+ return null;
XSourcePosition currentPosition = getCurrentFrameSourcePosition();
final PsiFile file = getPsiFile(currentPosition);
PyResolveUtil.scopeCrawlUp(new PsiScopeProcessor() {
@Override
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
- if (!(element instanceof PyImportElement)) {
+ if ((element instanceof PyImportElement)) {
+ PyImportElement importElement = (PyImportElement)element;
+ if (name.equals(importElement.getVisibleName())) {
+ if (elementRef.isNull()) {
+ elementRef.set(element);
+ }
+ return false;
+
+ }
+ return true;
+ }
+ else {
if (elementRef.isNull()) {
elementRef.set(element);
}
+ return false;
}
- return false;
}
@Nullable
if (file == null) return null;
- PyType type = PyTypeParser.getTypeByName(file, typeName);
- if (type instanceof PyClassType) {
- return XSourcePositionImpl.createByElement(((PyClassType)type).getPyClass());
+ if (!typeName.contains(".")) {
+ PyType type = PyTypeParser.getTypeByName(file, typeName);
+
+ if (type instanceof PyClassType) {
+ return XSourcePositionImpl.createByElement(((PyClassType)type).getPyClass());
+ }
+ }
+
+ PyPsiFacade psiFacade = PyPsiFacade.getInstance(getProject());
+ PyClass aClass = psiFacade.findClass(typeName);
+ if (aClass != null)
+ {
+ return XSourcePositionImpl.createByElement(aClass);
}
return null;
public class PyDebuggerEvaluator extends XDebuggerEvaluator {
- private static final PyDebugValue NONE = new PyDebugValue("", "NoneType", "None", false, false, null, null);
+ private static final PyDebugValue NONE = new PyDebugValue("", "NoneType", null, "None", false, false, null, null);
private Project myProject;
private final PyFrameAccessor myDebugProcess;
public ListenableFuture<ArrayChunk> load(final Pair<Integer, Integer> key) throws Exception {
final PyDebugValue value = myProvider.getDebugValue();
final PyDebugValue slicedValue =
- new PyDebugValue(myProvider.getSliceText(), value.getType(), value.getValue(), value.isContainer(), value.isErrorOnEval(),
+ new PyDebugValue(myProvider.getSliceText(), value.getType(), value.getTypeQualifier(), value.getValue(), value.isContainer(), value.isErrorOnEval(),
value.getParent(), value.getFrameAccessor());
ListenableFutureTask<ArrayChunk> task = ListenableFutureTask.create(new Callable<ArrayChunk>() {
*/
package com.jetbrains.python.debugger.array;
-import com.google.common.util.concurrent.ListenableFutureTask;
import com.intellij.codeInsight.hint.HintManager;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.Result;
-import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.RangeMarker;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
-import com.intellij.util.Consumer;
import com.intellij.util.ui.UIUtil;
-import com.intellij.xdebugger.evaluation.XDebuggerEvaluator;
-import com.intellij.xdebugger.frame.XValue;
import com.jetbrains.python.debugger.*;
import org.jetbrains.annotations.NotNull;
-import javax.management.InvalidAttributeValueException;
import javax.swing.*;
-import javax.swing.table.TableCellEditor;
import java.awt.*;
import java.awt.event.*;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
final PyDebugValue value = getDebugValue();
PyDebugValue parent = value.getParent();
final PyDebugValue slicedValue =
- new PyDebugValue(slice, value.getType(), value.getValue(), value.isContainer(), value.isErrorOnEval(),
+ new PyDebugValue(slice, value.getType(), null, value.getValue(), value.isContainer(), value.isErrorOnEval(),
parent, value.getFrameAccessor());
final String format = getFormat().isEmpty() ? "%" : getFormat();