mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
reduced memory used by debugger - do not store full value labels
This commit is contained in:
@@ -169,7 +169,13 @@ public class JavaValue extends XNamedValue implements NodeDescriptorProvider, XV
|
||||
|
||||
@Override
|
||||
public void contextAction() throws Exception {
|
||||
callback.evaluated(myValueDescriptor.getValueText());
|
||||
final ValueDescriptorImpl fullValueDescriptor = myValueDescriptor.getFullValueDescriptor();
|
||||
fullValueDescriptor.updateRepresentation(myEvaluationContext, new DescriptorLabelListener() {
|
||||
@Override
|
||||
public void labelChanged() {
|
||||
callback.evaluated(fullValueDescriptor.getValueText());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.xdebugger.frame.XValueModifier;
|
||||
import com.sun.jdi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -59,17 +58,30 @@ public class JavaValueModifier extends XValueModifier {
|
||||
myJavaValue = javaValue;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getInitialValueEditorText() {
|
||||
Value value = myJavaValue.getDescriptor().getValue();
|
||||
public void calculateInitialValueEditorText(final XInitialValueCallback callback) {
|
||||
final Value value = myJavaValue.getDescriptor().getValue();
|
||||
if (value instanceof PrimitiveValue) {
|
||||
return myJavaValue.getValueString();
|
||||
callback.setValue(myJavaValue.getValueString());
|
||||
}
|
||||
else if (value instanceof StringReference) {
|
||||
return StringUtil.wrapWithDoubleQuote(DebuggerUtils.translateStringValue(myJavaValue.getValueString()));
|
||||
final EvaluationContextImpl evaluationContext = myJavaValue.getEvaluationContext();
|
||||
evaluationContext.getManagerThread().schedule(new SuspendContextCommandImpl(evaluationContext.getSuspendContext()) {
|
||||
@Override
|
||||
public Priority getPriority() {
|
||||
return Priority.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextAction() throws Exception {
|
||||
callback.setValue(
|
||||
StringUtil.wrapWithDoubleQuote(DebuggerUtils.translateStringValue(DebuggerUtils.getValueAsString(evaluationContext, value))));
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
callback.setValue(null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//public void update(AnActionEvent e) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.debugger.engine.evaluation.EvaluateException;
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
|
||||
import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
|
||||
import com.intellij.debugger.impl.DebuggerContextImpl;
|
||||
import com.intellij.debugger.impl.DebuggerUtilsEx;
|
||||
import com.intellij.debugger.jdi.VirtualMachineProxyImpl;
|
||||
import com.intellij.debugger.settings.NodeRendererSettings;
|
||||
import com.intellij.debugger.ui.tree.DebuggerTreeNode;
|
||||
@@ -58,6 +59,7 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
|
||||
|
||||
private String myIdLabel;
|
||||
private String myValueText;
|
||||
private boolean myFullValue = false;
|
||||
|
||||
@Nullable
|
||||
private Icon myValueIcon;
|
||||
@@ -328,8 +330,32 @@ public abstract class ValueDescriptorImpl extends NodeDescriptorImpl implements
|
||||
return calcValueName() + " = " + myIdLabel + myValueText;
|
||||
}
|
||||
|
||||
public ValueDescriptorImpl getFullValueDescriptor() {
|
||||
ValueDescriptorImpl descriptor = new ValueDescriptorImpl(myProject, myValue) {
|
||||
@Override
|
||||
public Value calcValue(EvaluationContextImpl evaluationContext) throws EvaluateException {
|
||||
return myValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String calcValueName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
descriptor.myFullValue = true;
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueLabel(String label) {
|
||||
if (!myFullValue) {
|
||||
label = DebuggerUtilsEx.truncateString(label);
|
||||
}
|
||||
myValueText = label;
|
||||
myIdLabel = getIdLabel(label);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -38,7 +38,18 @@ public abstract class XValueModifier {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously calculates initial value
|
||||
*/
|
||||
public void calculateInitialValueEditorText(XInitialValueCallback callback) {
|
||||
callback.setValue(getInitialValueEditorText());
|
||||
}
|
||||
|
||||
public interface XModificationCallback extends XValueCallback {
|
||||
void valueModified();
|
||||
}
|
||||
|
||||
public interface XInitialValueCallback {
|
||||
void setValue(String initialValue);
|
||||
}
|
||||
}
|
||||
+29
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -40,7 +40,7 @@ public class SetValueInplaceEditor extends XDebuggerTreeInplaceEditor {
|
||||
private final XValueModifier myModifier;
|
||||
private final XValueNodeImpl myValueNode;
|
||||
|
||||
public SetValueInplaceEditor(final XValueNodeImpl node, @NotNull final String nodeName) {
|
||||
private SetValueInplaceEditor(final XValueNodeImpl node, @NotNull final String nodeName) {
|
||||
super(node, "setValue");
|
||||
myValueNode = node;
|
||||
myModifier = myValueNode.getValueContainer().getModifier();
|
||||
@@ -57,9 +57,34 @@ public class SetValueInplaceEditor extends XDebuggerTreeInplaceEditor {
|
||||
myEditorPanel.add(nameLabel, BorderLayout.WEST);
|
||||
|
||||
myEditorPanel.add(myExpressionEditor.getComponent(), BorderLayout.CENTER);
|
||||
final String value = myModifier != null ? myModifier.getInitialValueEditorText() : null;
|
||||
myExpressionEditor.setExpression(XExpressionImpl.fromText(value));
|
||||
}
|
||||
|
||||
public static void show(final XValueNodeImpl node, @NotNull final String nodeName) {
|
||||
final SetValueInplaceEditor editor = new SetValueInplaceEditor(node, nodeName);
|
||||
|
||||
if (editor.myModifier != null) {
|
||||
editor.myModifier.calculateInitialValueEditorText(new XValueModifier.XInitialValueCallback() {
|
||||
@Override
|
||||
public void setValue(final String initialValue) {
|
||||
AppUIUtil.invokeOnEdt(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
editor.show(initialValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
editor.show(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void show(String initialValue) {
|
||||
myExpressionEditor.setExpression(XExpressionImpl.fromText(initialValue));
|
||||
myExpressionEditor.selectAll();
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -47,7 +47,6 @@ public class XSetValueAction extends XDebuggerTreeActionBase {
|
||||
}
|
||||
|
||||
protected void perform(final XValueNodeImpl node, @NotNull final String nodeName, final AnActionEvent e) {
|
||||
XDebuggerTreeInplaceEditor editor = new SetValueInplaceEditor(node, nodeName);
|
||||
editor.show();
|
||||
SetValueInplaceEditor.show(node, nodeName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user