int (final AbstractBlockWrapper parent, final int offset) { AbstractBlockWrapper parentBlockToUse = getLastNestedCompositeBlockForSameRange(parent); if (!(parentBlockToUse instanceof CompositeBlockWrapper)) return 0; final List<AbstractBlockWrapper> subBlocks = ((CompositeBlockWrapper)parentBlockToUse).getChildren(); if (subBlocks != null) { for (int i = 0; i < subBlocks.size(); i++) { AbstractBlockWrapper block = subBlocks.get(i); if (block.getStartOffset() >= offset) return i; } return subBlocks.size(); } else { return 0; } }