use of com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl in project intellij-community by JetBrains.
the class ClassRenderer method buildChildren.
@Override
public void buildChildren(final Value value, final ChildrenBuilder builder, final EvaluationContext evaluationContext) {
DebuggerManagerThreadImpl.assertIsManagerThread();
final ValueDescriptorImpl parentDescriptor = (ValueDescriptorImpl) builder.getParentDescriptor();
final NodeManager nodeManager = builder.getNodeManager();
final NodeDescriptorFactory nodeDescriptorFactory = builder.getDescriptorManager();
List<DebuggerTreeNode> children = new ArrayList<>();
if (value instanceof ObjectReference) {
final ObjectReference objRef = (ObjectReference) value;
final ReferenceType refType = objRef.referenceType();
// default ObjectReference processing
List<Field> fields = refType.allFields();
if (!fields.isEmpty()) {
Set<String> names = new HashSet<>();
for (Field field : fields) {
if (shouldDisplay(evaluationContext, objRef, field)) {
FieldDescriptor fieldDescriptor = createFieldDescriptor(parentDescriptor, nodeDescriptorFactory, objRef, field, evaluationContext);
String name = fieldDescriptor.getName();
if (names.contains(name)) {
fieldDescriptor.putUserData(FieldDescriptor.SHOW_DECLARING_TYPE, Boolean.TRUE);
} else {
names.add(name);
}
children.add(nodeManager.createNode(fieldDescriptor, evaluationContext));
}
}
if (children.isEmpty()) {
children.add(nodeManager.createMessageNode(DebuggerBundle.message("message.node.class.no.fields.to.display")));
} else if (XDebuggerSettingsManager.getInstance().getDataViewSettings().isSortValues()) {
children.sort(NodeManagerImpl.getNodeComparator());
}
} else {
children.add(nodeManager.createMessageNode(MessageDescriptor.CLASS_HAS_NO_FIELDS.getLabel()));
}
}
builder.setChildren(children);
}
use of com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl in project intellij-community by JetBrains.
the class CustomFieldInplaceEditor method editNew.
public static void editNew(@NotNull XValueNodeImpl parentNode) {
ValueDescriptorImpl descriptor = ((JavaValue) parentNode.getValueContainer()).getDescriptor();
EnumerationChildrenRenderer renderer = EnumerationChildrenRenderer.getCurrent(descriptor);
XDebuggerTreeNode newNode = parentNode.addTemporaryEditorNode();
DebuggerUIUtil.invokeLater(() -> new CustomFieldInplaceEditor(newNode, null, renderer) {
@Override
public void cancelEditing() {
super.cancelEditing();
parentNode.removeTemporaryEditorNode(newNode);
}
@Override
protected List<Pair<String, TextWithImports>> getRendererChildren() {
if (myRenderer != null) {
return myRenderer.getChildren();
}
String name = getTypeName(descriptor);
EnumerationChildrenRenderer enumerationChildrenRenderer = new EnumerationChildrenRenderer();
enumerationChildrenRenderer.setAppendDefaultChildren(true);
Renderer lastRenderer = descriptor.getLastRenderer();
if (lastRenderer instanceof CompoundNodeRenderer && NodeRendererSettings.getInstance().getCustomRenderers().contains((NodeRenderer) lastRenderer) && !(((CompoundNodeRenderer) lastRenderer).getChildrenRenderer() instanceof ExpressionChildrenRenderer)) {
((CompoundNodeRenderer) lastRenderer).setChildrenRenderer(enumerationChildrenRenderer);
} else {
NodeRenderer renderer = NodeRendererSettings.getInstance().createCompoundTypeRenderer(name, name, null, enumerationChildrenRenderer);
renderer.setEnabled(true);
NodeRendererSettings.getInstance().getCustomRenderers().addRenderer(renderer);
NodeRendererSettings.getInstance().fireRenderersChanged();
}
return enumerationChildrenRenderer.getChildren();
}
}.show());
}
use of com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl in project intellij-community by JetBrains.
the class EditCustomFieldAction method perform.
@Override
protected void perform(XValueNodeImpl node, @NotNull String nodeName, AnActionEvent e) {
ValueDescriptorImpl descriptor = ((JavaValue) node.getValueContainer()).getDescriptor();
EnumerationChildrenRenderer enumerationChildrenRenderer = getParentEnumerationRenderer(descriptor);
if (enumerationChildrenRenderer != null) {
new CustomFieldInplaceEditor(node, (UserExpressionDescriptorImpl) descriptor, enumerationChildrenRenderer).show();
}
}
use of com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl in project intellij-community by JetBrains.
the class ViewAsGroup method calcChildren.
private static AnAction[] calcChildren(List<JavaValue> values) {
List<AnAction> renderers = new ArrayList<>();
List<NodeRenderer> allRenderers = NodeRendererSettings.getInstance().getAllRenderers();
boolean anyValueDescriptor = false;
for (NodeRenderer nodeRenderer : allRenderers) {
boolean allApp = true;
for (JavaValue value : values) {
if (value instanceof JavaReferringObjectsValue) {
// disable for any referrers at all
return AnAction.EMPTY_ARRAY;
}
ValueDescriptorImpl valueDescriptor = value.getDescriptor();
anyValueDescriptor = true;
if (!valueDescriptor.isValueValid() || !nodeRenderer.isApplicable(valueDescriptor.getType())) {
allApp = false;
break;
}
}
if (!anyValueDescriptor) {
return AnAction.EMPTY_ARRAY;
}
if (allApp) {
renderers.add(new RendererAction(nodeRenderer));
}
}
List<AnAction> children = new ArrayList<>();
AnAction[] viewAsActions = ((DefaultActionGroup) ActionManager.getInstance().getAction(DebuggerActions.REPRESENTATION_LIST)).getChildren(null);
for (AnAction viewAsAction : viewAsActions) {
if (viewAsAction instanceof AutoRendererAction) {
if (renderers.size() > 1) {
viewAsAction.getTemplatePresentation().setVisible(true);
children.add(viewAsAction);
}
} else {
children.add(viewAsAction);
}
}
if (!children.isEmpty()) {
children.add(Separator.getInstance());
}
children.addAll(renderers);
return children.toArray(new AnAction[children.size()]);
}
use of com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl in project intellij-community by JetBrains.
the class AdjustArrayRangeAction method update.
@Override
public void update(AnActionEvent e) {
boolean enable = false;
XValueNodeImpl node = XDebuggerTreeActionBase.getSelectedNode(e.getDataContext());
if (node != null) {
XValue container = node.getValueContainer();
if (container instanceof JavaValue) {
ValueDescriptorImpl descriptor = ((JavaValue) container).getDescriptor();
enable = getArrayRenderer(descriptor) != null;
}
}
e.getPresentation().setVisible(enable);
}
Aggregations