use of com.intellij.debugger.ui.impl.watch.NodeManagerImpl in project intellij-community by JetBrains.
the class ArrayRenderer method buildChildren.
public void buildChildren(Value value, ChildrenBuilder builder, EvaluationContext evaluationContext) {
DebuggerManagerThreadImpl.assertIsManagerThread();
List<DebuggerTreeNode> children = new ArrayList<>();
NodeManagerImpl nodeManager = (NodeManagerImpl) builder.getNodeManager();
NodeDescriptorFactory descriptorFactory = builder.getDescriptorManager();
if (!myForced) {
builder.initChildrenArrayRenderer(this);
}
ArrayReference array = (ArrayReference) value;
if (array.length() > 0) {
int added = 0;
if (ENTRIES_LIMIT > END_INDEX - START_INDEX + 1) {
ENTRIES_LIMIT = END_INDEX - START_INDEX;
}
if (ENTRIES_LIMIT <= 0) {
ENTRIES_LIMIT = 1;
}
if (array.length() - 1 >= START_INDEX) {
int start = START_INDEX;
int end = array.length() - 1 < END_INDEX ? array.length() - 1 : END_INDEX;
int idx;
for (idx = start; idx <= end; idx++) {
if (ViewsGeneralSettings.getInstance().HIDE_NULL_ARRAY_ELEMENTS && elementIsNull(array, idx))
continue;
DebuggerTreeNode arrayItemNode = nodeManager.createNode(descriptorFactory.getArrayItemDescriptor(builder.getParentDescriptor(), array, idx), evaluationContext);
if (arrayItemNode == null)
continue;
//if(added >= (ENTRIES_LIMIT + 1)/ 2) break;
children.add(arrayItemNode);
added++;
}
start = idx;
//List<DebuggerTreeNode> childrenTail = new ArrayList<DebuggerTreeNode>();
//for (idx = end; idx >= start; idx--) {
// DebuggerTreeNode arrayItemNode = nodeManager.createNode(descriptorFactory.getArrayItemDescriptor(builder.getParentDescriptor(), array, idx), evaluationContext);
//
// if (arrayItemNode == null) continue;
// if (ViewsGeneralSettings.getInstance().HIDE_NULL_ARRAY_ELEMENTS && ((ValueDescriptorImpl)arrayItemNode.getDescriptor()).isNull()) continue;
// if(added >= ENTRIES_LIMIT) break;
// childrenTail.add(arrayItemNode);
// added++;
//}
//array is printed in the following way
// ...
// items1...itemENTRIES_LIMIT/2
// ...
// itemENTRIES_LIMIT/2+1...itemENTRIES_LIMIT
// ...
//when itemENTRIES_LIMIT/2+1...itemENTRIES_LIMIT set is empty, we should not add middle "..." node
//if(idx >= start && !(ENTRIES_LIMIT == 1 && END_INDEX < array.length())) {
// children.add(nodeManager.createMessageNode(new MessageDescriptor(MORE_ELEMENTS, MessageDescriptor.SPECIAL)));
//}
//for (ListIterator<DebuggerTreeNode> iterator = childrenTail.listIterator(childrenTail.size()); iterator.hasPrevious();) {
// DebuggerTreeNode debuggerTreeNode = iterator.previous();
// children.add(debuggerTreeNode);
//}
}
if (added == 0) {
if (START_INDEX == 0 && array.length() - 1 <= END_INDEX) {
children.add(nodeManager.createMessageNode(MessageDescriptor.ALL_ELEMENTS_IN_RANGE_ARE_NULL));
} else {
children.add(nodeManager.createMessageNode(DebuggerBundle.message("message.node.all.array.elements.null", START_INDEX, END_INDEX)));
}
} else {
if (!myForced && END_INDEX < array.length() - 1) {
//children.add(nodeManager.createMessageNode(new MessageDescriptor(MORE_ELEMENTS, MessageDescriptor.SPECIAL)));
builder.setRemaining(array.length() - 1 - END_INDEX);
}
}
}
builder.setChildren(children);
}
use of com.intellij.debugger.ui.impl.watch.NodeManagerImpl in project android by JetBrains.
the class ArrayMapRendererBase method buildChildren.
/** Builds a list of {@link DebuggerTreeNode}'s that are the children of this node. */
@Override
public void buildChildren(Value value, ChildrenBuilder builder, EvaluationContext evaluationContext) {
DebuggerManagerThreadImpl.assertIsManagerThread();
List<DebuggerTreeNode> children = new ArrayList<DebuggerTreeNode>();
NodeManagerImpl nodeManager = (NodeManagerImpl) builder.getNodeManager();
NodeDescriptorFactory descriptorFactory = builder.getDescriptorManager();
int size;
try {
size = getArrayMapSize(value, evaluationContext);
} catch (Exception e) {
size = 0;
}
for (int i = 0, n = Math.min(size, MAX_CHILDREN); i < n; i++) {
// For each entry, display the value at that entry. TODO: we need to show the key corresponding to this as well.
// We used to show the key and value by using the following expression:
// String expression = String.format("new Object[] {this.keyAt(%1$d), this.valueAt(%2$d)}", i, i);
// But it turns out that this throws "java.lang.ClassNotFoundException: [LObject;"
// Until we find an alternate scheme, just show the value.
String expression = String.format("this.valueAt(%1$d)", i);
UserExpressionData descriptorData = new UserExpressionData((ValueDescriptorImpl) builder.getParentDescriptor(), myFqn, String.format("value[%1$d]", i), new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, expression, "", StdFileTypes.JAVA));
UserExpressionDescriptor userExpressionDescriptor = descriptorFactory.getUserExpressionDescriptor(builder.getParentDescriptor(), descriptorData);
DebuggerTreeNode arrayMapItemNode = nodeManager.createNode(userExpressionDescriptor, evaluationContext);
children.add(arrayMapItemNode);
}
if (size > MAX_CHILDREN) {
children.add(nodeManager.createMessageNode(new MessageDescriptor(MORE_ELEMENTS, MessageDescriptor.SPECIAL)));
}
builder.setChildren(children);
}
Aggregations