use of com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl in project intellij-community by JetBrains.
the class DebuggerTreeBase method getTipText.
@Nullable
private String getTipText(DebuggerTreeNodeImpl node) {
NodeDescriptorImpl descriptor = node.getDescriptor();
if (descriptor instanceof ValueDescriptorImpl) {
String text = ((ValueDescriptorImpl) descriptor).getValueText();
final String tipText = DebuggerUtilsEx.prepareValueText(text, myProject);
if (!tipText.isEmpty() && (tipText.indexOf('\n') >= 0 || !getVisibleRect().contains(getRowBounds(getRowForPath(new TreePath(node.getPath())))))) {
return tipText;
}
}
return node.getMarkupTooltipText() != null ? "" : null;
}
use of com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl in project intellij-community by JetBrains.
the class JavaMarkObjectActionHandler method perform.
@Override
public void perform(@NotNull Project project, AnActionEvent event) {
final DebuggerTreeNodeImpl node = DebuggerAction.getSelectedNode(event.getDataContext());
if (node == null) {
return;
}
final NodeDescriptorImpl descriptor = node.getDescriptor();
if (!(descriptor instanceof ValueDescriptorImpl)) {
return;
}
final DebuggerTree tree = node.getTree();
tree.saveState(node);
final Component parent = event.getData(CONTEXT_COMPONENT);
final ValueDescriptorImpl valueDescriptor = ((ValueDescriptorImpl) descriptor);
final DebuggerContextImpl debuggerContext = tree.getDebuggerContext();
final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
final ValueMarkup markup = valueDescriptor.getMarkup(debugProcess);
debugProcess.getManagerThread().invoke(new DebuggerContextCommandImpl(debuggerContext) {
public Priority getPriority() {
return Priority.HIGH;
}
public void threadAction() {
boolean sessionRefreshNeeded = true;
try {
if (markup != null) {
valueDescriptor.setMarkup(debugProcess, null);
} else {
final String defaultText = valueDescriptor.getName();
final Ref<Pair<ValueMarkup, Boolean>> result = new Ref<>(null);
try {
final boolean suggestAdditionalMarkup = canSuggestAdditionalMarkup(debugProcess, valueDescriptor.getValue());
SwingUtilities.invokeAndWait(() -> {
ObjectMarkupPropertiesDialog dialog = new ObjectMarkupPropertiesDialog(parent, defaultText, suggestAdditionalMarkup);
if (dialog.showAndGet()) {
result.set(Pair.create(dialog.getConfiguredMarkup(), dialog.isMarkAdditionalFields()));
}
});
} catch (InterruptedException ignored) {
} catch (InvocationTargetException e) {
LOG.error(e);
}
final Pair<ValueMarkup, Boolean> pair = result.get();
if (pair != null) {
valueDescriptor.setMarkup(debugProcess, pair.first);
if (pair.second) {
final Value value = valueDescriptor.getValue();
final Map<ObjectReference, ValueMarkup> additionalMarkup = suggestMarkup((ObjectReference) value);
if (!additionalMarkup.isEmpty()) {
final Map<ObjectReference, ValueMarkup> map = NodeDescriptorImpl.getMarkupMap(debugProcess);
if (map != null) {
for (Map.Entry<ObjectReference, ValueMarkup> entry : additionalMarkup.entrySet()) {
final ObjectReference key = entry.getKey();
if (!map.containsKey(key)) {
map.put(key, entry.getValue());
}
}
}
}
}
} else {
sessionRefreshNeeded = false;
}
}
} finally {
final boolean _sessionRefreshNeeded = sessionRefreshNeeded;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
tree.restoreState(node);
final TreeBuilder model = tree.getMutableModel();
refreshLabelsRecursively(model.getRoot(), model, valueDescriptor.getValue());
if (_sessionRefreshNeeded) {
final DebuggerSession session = debuggerContext.getDebuggerSession();
if (session != null) {
session.refresh(true);
}
}
}
private void refreshLabelsRecursively(Object node, TreeBuilder model, Value value) {
if (node instanceof DebuggerTreeNodeImpl) {
final DebuggerTreeNodeImpl _node = (DebuggerTreeNodeImpl) node;
final NodeDescriptorImpl descriptor = _node.getDescriptor();
if (descriptor instanceof ValueDescriptor && Comparing.equal(value, ((ValueDescriptor) descriptor).getValue())) {
_node.labelChanged();
}
}
final int childCount = model.getChildCount(node);
for (int idx = 0; idx < childCount; idx++) {
refreshLabelsRecursively(model.getChild(node, idx), model, value);
}
}
});
}
}
});
}
use of com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl in project intellij-community by JetBrains.
the class AdjustArrayRangeAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
if (debugProcess == null) {
return;
}
final Project project = debuggerContext.getProject();
final XValueNodeImpl node = XDebuggerTreeActionBase.getSelectedNode(e.getDataContext());
if (node == null) {
return;
}
final XValue container = node.getValueContainer();
if (!(container instanceof JavaValue)) {
return;
}
final ValueDescriptorImpl descriptor = ((JavaValue) container).getDescriptor();
ArrayRenderer renderer = getArrayRenderer(descriptor);
if (renderer == null) {
return;
}
//String title = createNodeTitle("", selectedNode);
//String label = selectedNode.toString();
//int index = label.indexOf('=');
//if (index > 0) {
// title = title + " " + label.substring(index);
//}
String title = node.getName();
final ArrayRenderer clonedRenderer = renderer.clone();
clonedRenderer.setForced(true);
if (ShowSettingsUtil.getInstance().editConfigurable(project, new NamedArrayConfigurable(title, clonedRenderer))) {
debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(debuggerContext.getSuspendContext()) {
@Override
public void contextAction() throws Exception {
final Renderer lastRenderer = descriptor.getLastRenderer();
if (lastRenderer instanceof ArrayRenderer) {
((JavaValue) container).setRenderer(clonedRenderer, node);
} else if (lastRenderer instanceof CompoundNodeRenderer) {
final CompoundNodeRenderer compoundRenderer = (CompoundNodeRenderer) lastRenderer;
final ChildrenRenderer childrenRenderer = compoundRenderer.getChildrenRenderer();
if (childrenRenderer instanceof ExpressionChildrenRenderer) {
ExpressionChildrenRenderer.setPreferableChildrenRenderer(descriptor, clonedRenderer);
((JavaValue) container).reBuild(node);
}
}
}
});
}
}
use of com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl in project intellij-community by JetBrains.
the class AdjustArrayRangeAction method createNodeTitle.
private static String createNodeTitle(String prefix, DebuggerTreeNodeImpl node) {
if (node != null) {
DebuggerTreeNodeImpl parent = node.getParent();
NodeDescriptorImpl descriptor = parent.getDescriptor();
if (descriptor instanceof ValueDescriptorImpl && ((ValueDescriptorImpl) descriptor).isArray()) {
int index = parent.getIndex(node);
return createNodeTitle(prefix, parent) + "[" + index + "]";
}
String name = (node.getDescriptor() != null) ? node.getDescriptor().getName() : null;
return (name != null) ? prefix + " " + name : prefix;
}
return prefix;
}
use of com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl in project intellij-community by JetBrains.
the class ClassRenderer method calcLabel.
protected static String calcLabel(ValueDescriptor descriptor) {
final ValueDescriptorImpl valueDescriptor = (ValueDescriptorImpl) descriptor;
final Value value = valueDescriptor.getValue();
if (value instanceof ObjectReference) {
if (value instanceof StringReference) {
return ((StringReference) value).value();
} else if (value instanceof ClassObjectReference) {
ReferenceType type = ((ClassObjectReference) value).reflectedType();
return (type != null) ? type.name() : "{...}";
} else {
final ObjectReference objRef = (ObjectReference) value;
final Type type = objRef.type();
if (type instanceof ClassType && ((ClassType) type).isEnum()) {
final String name = getEnumConstantName(objRef, (ClassType) type);
if (name != null) {
return name;
} else {
return type.name();
}
} else {
return "";
}
}
} else if (value == null) {
//noinspection HardCodedStringLiteral
return "null";
} else {
return DebuggerBundle.message("label.undefined");
}
}
Aggregations