validPosition= getValidPositionForPartition(document, partition, eol); while (validPosition == -1) { nextPartitionPos= partition.getOffset() - 1; if (nextPartitionPos <= docOffset) { validPosition= docOffset; break;
if (partition != null) { validPosition= getValidPositionForPartition(document, partition, eol); while (validPosition == -1) { nextPartitionPos= partition.getOffset() - 1; if (nextPartitionPos <= docOffset) { validPosition= docOffset; break; } partition= TextUtilities.getPartition(document, partitioning, nextPartitionPos); validPosition= getValidPositionForPartition(document, partition, eol);
	private static int nextPartitionOrLineEnd(IDocument document, ITextSelection line, int offset, String partitioning) {		// run relative to document		final int docOffset= offset + line.getOffset();		final int eol= line.getOffset() + line.getLength();		int nextPartitionPos= eol; // init with line end		int validPosition= docOffset;		try {			ITypedRegion partition= TextUtilities.getPartition(document, partitioning, nextPartitionPos);			validPosition= getValidPositionForPartition(document, partition, eol);			while (validPosition == -1) {				nextPartitionPos= partition.getOffset() - 1;				if (nextPartitionPos <= docOffset) {					validPosition= docOffset;					break;				}				partition= TextUtilities.getPartition(document, partitioning, nextPartitionPos);				validPosition= getValidPositionForPartition(document, partition, eol);			}		} catch (BadLocationException e) {		}		validPosition= Math.max(validPosition, docOffset);		// make relative to line		validPosition -= line.getOffset();		return validPosition;	}