Example #1
0
 /**
  * Returns children for the given value, creating array partitions if required
  *
  * @param parent expression or variable containing the given value
  * @param value the value to retrieve children for
  * @param context the context in which children have been requested
  * @return children for the given value, creating array partitions if required
  * @throws CoreException
  */
 protected Object[] getValueChildren(
     IDebugElement parent, IValue value, IPresentationContext context) throws CoreException {
   if (value == null) {
     return EMPTY;
   }
   IValue logicalValue = getLogicalValue(value, context);
   if (logicalValue instanceof IIndexedValue) {
     IIndexedValue indexedValue = (IIndexedValue) logicalValue;
     int partitionSize = computeParitionSize(indexedValue);
     if (partitionSize > 1) {
       int offset = indexedValue.getInitialOffset();
       int length = indexedValue.getSize();
       int numPartitions = length / partitionSize;
       int remainder = length % partitionSize;
       if (remainder > 0) {
         numPartitions++;
       }
       IVariable[] partitions = new IVariable[numPartitions];
       for (int i = 0; i < (numPartitions - 1); i++) {
         partitions[i] = new IndexedVariablePartition(parent, indexedValue, offset, partitionSize);
         offset = offset + partitionSize;
       }
       if (remainder == 0) {
         remainder = partitionSize;
       }
       partitions[numPartitions - 1] =
           new IndexedVariablePartition(parent, indexedValue, offset, remainder);
       return partitions;
     }
   }
   if (logicalValue == null) {
     // safeguard against an structure type returning null
     logicalValue = value;
   }
   return logicalValue.getVariables();
 }
Example #2
0
 /**
  * Returns the partition size to use for the given indexed value. The partition size is computed
  * by determining the number of levels that an indexed collection must be nested in order to
  * partition the collection sub-collections of the preferred partition size.
  *
  * @param value indexed value
  * @return size of partitions the value should be subdivided into
  */
 protected int computeParitionSize(IIndexedValue value) {
   int partitionSize = 1;
   try {
     int length = value.getSize();
     int partitionDepth = 0;
     int preferredSize = getArrayPartitionSize();
     int remainder = length % preferredSize;
     length = length / preferredSize;
     while (length > 0) {
       if (remainder == 0 && length == 1) {
         break;
       }
       partitionDepth++;
       remainder = length % preferredSize;
       length = length / preferredSize;
     }
     for (int i = 0; i < partitionDepth; i++) {
       partitionSize = partitionSize * preferredSize;
     }
   } catch (DebugException e) {
   }
   return partitionSize;
 }