CompletableFuture<Void> (ArrayReference array, int start, int end, int length, ChildrenBuilder builder, EvaluationContext evaluationContext, AtomicInteger added, AtomicBoolean hiddenNulls) { int chunkLength = Math.min(XCompositeNode.MAX_CHILDREN_TO_SHOW, end - start + 1); return DebuggerUtilsAsync.getValues(array, start, chunkLength) .thenCompose(values -> { int idx = start; for (; idx < start + values.size(); idx++) { Value val = values.get(idx - start); if (ViewsGeneralSettings.getInstance().HIDE_NULL_ARRAY_ELEMENTS && val == null) { hiddenNulls.set(true); continue; } ArrayElementDescriptorImpl descriptor = (ArrayElementDescriptorImpl)builder.getDescriptorManager() .getArrayItemDescriptor(builder.getParentDescriptor(), array, idx); descriptor.setValue(val); DebuggerTreeNode arrayItemNode = ((NodeManagerImpl)builder.getNodeManager()).createNode(descriptor, evaluationContext); builder.addChildren(Collections.singletonList(arrayItemNode), false); if (added.incrementAndGet() >= ENTRIES_LIMIT) { break; } } // process next chunk if needed if (idx < end && added.get() < ENTRIES_LIMIT) { return addChunk(array, idx, end, length, builder, evaluationContext, added, hiddenNulls); } finish(builder, length, added.get(), hiddenNulls.get(), end, idx); return CompletableFuture.completedFuture(null); }); }