private static int nextPartitionOrLineEnd(IDocument document,ITextSelection line,int offset,String partitioning){
  final int docOffset=offset + line.getOffset();
  final int eol=line.getOffset() + line.getLength();
  int nextPartitionPos=eol;
  int validPosition=docOffset;
  try {
    ITypedRegion partition=TextUtilities.getPartition(document,partitioning,nextPartitionPos,true);
    validPosition=getValidPositionForPartition(document,partition,eol);
    while (validPosition == -1) {
      nextPartitionPos=partition.getOffset() - 1;
      if (nextPartitionPos < docOffset) {
        validPosition=docOffset;
        break;
      }
      partition=TextUtilities.getPartition(document,partitioning,nextPartitionPos,false);
      validPosition=getValidPositionForPartition(document,partition,eol);
    }
  }
 catch (  BadLocationException e) {
  }
  validPosition=Math.max(validPosition,docOffset);
  validPosition-=line.getOffset();
  return validPosition;
}

private static int nextPartitionOrLineEnd ( IDocument document , ITextSelection line , int offset , String partitioning ) { final int docOffset = offset + line . getOffset ( ) ; final int eol = line . getOffset ( ) + line . getLength ( ) ; int nextPartitionPos = eol ; int validPosition = docOffset ; try { ITypedRegion partition = TextUtilities . getPartition ( document , partitioning , nextPartitionPos , true ) ; validPosition = getValidPositionForPartition ( document , partition , eol ) ; while ( validPosition == - 1 ) { nextPartitionPos = partition . getOffset ( ) - 1 ; if ( nextPartitionPos < docOffset ) { validPosition = docOffset ; break ; } partition = TextUtilities . getPartition ( document , partitioning , nextPartitionPos , false ) ; validPosition = getValidPositionForPartition ( document , partition , eol ) ; } } catch ( BadLocationException e ) { } validPosition = Math . max ( validPosition , docOffset ) ; validPosition -= line . getOffset ( ) ; return validPosition ; }
returns a position in the first java partition after the last non - empty and non - comment partition . there is no non - whitespace from the returned position to the end of the partition it is contained in .
