summaryrefslogtreecommitdiff
path: root/java/debugger/impl/src/com/intellij/debugger/engine
diff options
context:
space:
mode:
Diffstat (limited to 'java/debugger/impl/src/com/intellij/debugger/engine')
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/JavaStackFrame.java37
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java111
-rw-r--r--java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java14
3 files changed, 122 insertions, 40 deletions
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaStackFrame.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaStackFrame.java
index db28c4bf34a7..3f649e2b1dab 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaStackFrame.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaStackFrame.java
@@ -38,13 +38,11 @@ import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.ColoredTextContainer;
-import com.intellij.ui.SimpleTextAttributes;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.evaluation.XDebuggerEvaluator;
-import com.intellij.xdebugger.frame.XCompositeNode;
-import com.intellij.xdebugger.frame.XStackFrame;
-import com.intellij.xdebugger.frame.XValueChildrenList;
+import com.intellij.xdebugger.frame.*;
+import com.intellij.xdebugger.frame.presentation.XValuePresentation;
import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants;
import com.intellij.xdebugger.settings.XDebuggerSettingsManager;
import com.sun.jdi.*;
@@ -53,6 +51,7 @@ import com.sun.jdi.event.ExceptionEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import javax.swing.*;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -316,7 +315,8 @@ public class JavaStackFrame extends XStackFrame {
for (Value argValue : argValues) {
children.add(createArgumentValue(index++, argValue, null, evaluationContext));
}
- node.setMessage(MessageDescriptor.LOCAL_VARIABLES_INFO_UNAVAILABLE.getLabel(), XDebuggerUIConstants.INFORMATION_MESSAGE_ICON, SimpleTextAttributes.REGULAR_ATTRIBUTES, null);
+ //node.setMessage(MessageDescriptor.LOCAL_VARIABLES_INFO_UNAVAILABLE.getLabel(), XDebuggerUIConstants.INFORMATION_MESSAGE_ICON, SimpleTextAttributes.REGULAR_ATTRIBUTES, null);
+ children.add(new DummyMessageValueNode(MessageDescriptor.LOCAL_VARIABLES_INFO_UNAVAILABLE.getLabel(), XDebuggerUIConstants.INFORMATION_MESSAGE_ICON));
//myChildren.add(myNodeManager.createMessageNode(MessageDescriptor.LOCAL_VARIABLES_INFO_UNAVAILABLE));
// trying to collect values from variable slots
@@ -339,6 +339,33 @@ public class JavaStackFrame extends XStackFrame {
}
}
+ static class DummyMessageValueNode extends XNamedValue {
+ private final String myMessage;
+ private final Icon myIcon;
+
+ public DummyMessageValueNode(String message, Icon icon) {
+ super("");
+ myMessage = message;
+ myIcon = icon;
+ }
+
+ @Override
+ public void computePresentation(@NotNull XValueNode node, @NotNull XValuePlace place) {
+ node.setPresentation(myIcon, new XValuePresentation() {
+ @NotNull
+ @Override
+ public String getSeparator() {
+ return "";
+ }
+
+ @Override
+ public void renderValue(@NotNull XValueTextRenderer renderer) {
+ renderer.renderValue(myMessage);
+ }
+ }, false);
+ }
+ }
+
private JavaValue createArgumentValue(int index, Value value, String name, EvaluationContextImpl evaluationContext) {
ArgumentValueDescriptorImpl descriptor = myNodeManager.getArgumentValueDescriptor(null, index, value, name);
// setContext is required to calculate correct name
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java b/java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java
index 0a691d332207..9cfb2bfde84e 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/JavaValue.java
@@ -36,21 +36,30 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.CommonClassNames;
import com.intellij.psi.PsiExpression;
+import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.xdebugger.frame.*;
import com.intellij.xdebugger.frame.presentation.XRegularValuePresentation;
import com.intellij.xdebugger.frame.presentation.XStringValuePresentation;
import com.intellij.xdebugger.frame.presentation.XValuePresentation;
+import com.intellij.xdebugger.impl.evaluate.XValueCompactPresentation;
+import com.intellij.xdebugger.impl.ui.XValueTextProvider;
+import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
+import com.sun.jdi.ArrayReference;
+import com.sun.jdi.ArrayType;
+import com.sun.jdi.Value;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
+import java.util.ArrayList;
import java.util.List;
/**
* @author egor
*/
-public class JavaValue extends XNamedValue implements NodeDescriptorProvider {
+public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XValueTextProvider {
private static final Logger LOG = Logger.getInstance(JavaValue.class);
private final JavaValue myParent;
@@ -74,7 +83,7 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider {
return new JavaValue(parent, valueDescriptor, evaluationContext, nodeManager);
}
- static JavaValue create(@NotNull ValueDescriptorImpl valueDescriptor,
+ public static JavaValue create(@NotNull ValueDescriptorImpl valueDescriptor,
EvaluationContextImpl evaluationContext,
NodeManagerImpl nodeManager) {
return create(null, valueDescriptor, evaluationContext, nodeManager, true);
@@ -156,7 +165,7 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider {
});
}
- private static class JavaValuePresentation extends XValuePresentation {
+ private static class JavaValuePresentation extends XValuePresentation implements XValueCompactPresentation {
private final String myValue;
private final String myType;
private final String myError;
@@ -175,6 +184,12 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider {
@Override
public void renderValue(@NotNull XValueTextRenderer renderer) {
+ renderValue(renderer, null);
+ }
+
+ @Override
+ public void renderValue(@NotNull XValueTextRenderer renderer, @Nullable XValueNodeImpl node) {
+ boolean compact = node != null;
if (myError != null) {
if (myValue.endsWith(myError)) {
renderer.renderValue(myValue.substring(0, myValue.length() - myError.length()));
@@ -182,6 +197,34 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider {
renderer.renderError(myError);
}
else {
+ if (compact && node.getValueContainer() instanceof JavaValue) {
+ final JavaValue container = (JavaValue)node.getValueContainer();
+
+ if (container.getDescriptor().isArray()) {
+ final ArrayReference value = (ArrayReference)container.getDescriptor().getValue();
+ final ArrayType type = (ArrayType)container.getDescriptor().getType();
+ if (type != null) {
+ final String typeName = type.componentTypeName();
+ if (TypeConversionUtil.isPrimitive(typeName) || CommonClassNames.JAVA_LANG_STRING.equals(typeName)) {
+ int max = CommonClassNames.JAVA_LANG_STRING.equals(typeName) ? 5 : 10;
+ final List<Value> values = value.getValues();
+ int i = 0;
+ final List<String> vals = new ArrayList<String>(max);
+ while (i < values.size() && i <= max) {
+ vals.add(StringUtil.first(values.get(i).toString(), 15, true));
+ i++;
+ }
+ String more = "";
+ if (vals.size() < values.size()) {
+ more = ", + " + (values.size() - vals.size()) + " more";
+ }
+
+ renderer.renderValue("{" + StringUtil.join(vals, ", ") + more + "}");
+ return;
+ }
+ }
+ }
+ }
renderer.renderValue(myValue);
}
}
@@ -269,23 +312,7 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider {
children.add(create(JavaValue.this, (ValueDescriptorImpl)descriptor, myEvaluationContext, myNodeManager, false));
}
else if (descriptor instanceof MessageDescriptor) {
- children.add("", new XValue() {
- @Override
- public void computePresentation(@NotNull XValueNode node, @NotNull XValuePlace place) {
- node.setPresentation(null, new XValuePresentation() {
- @NotNull
- @Override
- public String getSeparator() {
- return "";
- }
-
- @Override
- public void renderValue(@NotNull XValueTextRenderer renderer) {
- renderer.renderValue(descriptor.getLabel());
- }
- }, false);
- }
- });
+ children.add(new JavaStackFrame.DummyMessageValueNode(descriptor.getLabel(), null));
}
}
}
@@ -299,19 +326,36 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider {
}
@Override
- public void computeSourcePosition(@NotNull XNavigatable navigatable) {
- if (myValueDescriptor instanceof FieldDescriptorImpl) {
- SourcePosition position = ((FieldDescriptorImpl)myValueDescriptor).getSourcePosition(getProject(), getDebuggerContext());
- if (position != null) {
- navigatable.setSourcePosition(DebuggerUtilsEx.toXSourcePosition(position));
+ public void computeSourcePosition(@NotNull final XNavigatable navigatable) {
+ if (myEvaluationContext.getSuspendContext().isResumed()) return;
+ myEvaluationContext.getDebugProcess().getManagerThread().schedule(new SuspendContextCommandImpl(myEvaluationContext.getSuspendContext()) {
+ @Override
+ public Priority getPriority() {
+ return Priority.NORMAL;
}
- }
- if (myValueDescriptor instanceof LocalVariableDescriptorImpl) {
- SourcePosition position = ((LocalVariableDescriptorImpl)myValueDescriptor).getSourcePosition(getProject(), getDebuggerContext());
- if (position != null) {
- navigatable.setSourcePosition(DebuggerUtilsEx.toXSourcePosition(position));
+
+ @Override
+ public void contextAction() throws Exception {
+ ApplicationManager.getApplication().runReadAction(new Runnable() {
+ @Override
+ public void run() {
+ if (myValueDescriptor instanceof FieldDescriptorImpl) {
+ SourcePosition position = ((FieldDescriptorImpl)myValueDescriptor).getSourcePosition(getProject(), getDebuggerContext());
+ if (position != null) {
+ navigatable.setSourcePosition(DebuggerUtilsEx.toXSourcePosition(position));
+ }
+ }
+ if (myValueDescriptor instanceof LocalVariableDescriptorImpl) {
+ SourcePosition position =
+ ((LocalVariableDescriptorImpl)myValueDescriptor).getSourcePosition(getProject(), getDebuggerContext());
+ if (position != null) {
+ navigatable.setSourcePosition(DebuggerUtilsEx.toXSourcePosition(position));
+ }
+ }
+ }
+ });
}
- }
+ });
}
private DebuggerContextImpl getDebuggerContext() {
@@ -393,4 +437,9 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider {
}
return evaluationExpression;
}
+
+ @Override
+ public String getValueText() {
+ return myValueDescriptor.getValueText();
+ }
}
diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java
index 2c31e75cc521..016b01ed6f96 100644
--- a/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java
+++ b/java/debugger/impl/src/com/intellij/debugger/engine/PositionManagerImpl.java
@@ -27,6 +27,7 @@ import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.NullableComputable;
import com.intellij.openapi.util.Ref;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.search.FilenameIndex;
import com.intellij.psi.search.GlobalSearchScope;
@@ -194,12 +195,17 @@ public class PositionManagerImpl implements PositionManager {
return element.getContainingFile();
}
else {
- // for now just take the first file with the required name
- // TODO: if there are more than one, we can try matching package name and sourcePath if available
+ // try to search by filename
try {
PsiFile[] files = FilenameIndex.getFilesByName(project, refType.sourceName(), GlobalSearchScope.allScope(project));
- if (files.length > 0) {
- return files[0];
+ for (PsiFile file : files) {
+ if (file instanceof PsiJavaFile) {
+ for (PsiClass cls : ((PsiJavaFile)file).getClasses()) {
+ if (StringUtil.equals(originalQName, cls.getQualifiedName())) {
+ return file;
+ }
+ }
+ }
}
}
catch (AbsentInformationException ignore) {