protected static int computeCharacterPosition(IDocument document,ITextSelection line,int offset,char character,String partitioning){
  String text=line.getText();
  if (text == null)   return 0;
  int insertPos;
  if (character == BRACECHAR) {
    insertPos=computeArrayInitializationPos(document,line,offset,partitioning);
    if (insertPos == -1) {
      insertPos=computeAfterTryDoElse(document,line,offset);
    }
    if (insertPos == -1) {
      insertPos=computeAfterParenthesis(document,line,offset,partitioning);
    }
  }
 else   if (character == SEMICHAR) {
    if (isForStatement(text,offset)) {
      insertPos=-1;
    }
 else {
      int nextPartitionPos=nextPartitionOrLineEnd(document,line,offset,partitioning);
      insertPos=startOfWhitespaceBeforeOffset(text,nextPartitionPos);
      if (insertPos > 0 && text.charAt(insertPos - 1) == character)       insertPos=insertPos - 1;
 else       if (insertPos > 0 && text.charAt(insertPos - 1) == '}') {
        int opening=scanBackward(document,insertPos - 1 + line.getOffset(),partitioning,-1,new char[]{'{'});
        if (opening > -1 && opening < offset + line.getOffset()) {
          if (computeArrayInitializationPos(document,line,opening - line.getOffset(),partitioning) == -1) {
            insertPos=offset;
          }
        }
      }
    }
  }
 else {
    Assert.isTrue(false);
    return -1;
  }
  return insertPos;
}

protected static int computeCharacterPosition ( IDocument document , ITextSelection line , int offset , char character , String partitioning ) { String text = line . getText ( ) ; if ( text == null ) return 0 ; int insertPos ; if ( character == BRACECHAR ) { insertPos = computeArrayInitializationPos ( document , line , offset , partitioning ) ; if ( insertPos == - 1 ) { insertPos = computeAfterTryDoElse ( document , line , offset ) ; } if ( insertPos == - 1 ) { insertPos = computeAfterParenthesis ( document , line , offset , partitioning ) ; } } else if ( character == SEMICHAR ) { if ( isForStatement ( text , offset ) ) { insertPos = - 1 ; } else { int nextPartitionPos = nextPartitionOrLineEnd ( document , line , offset , partitioning ) ; insertPos = startOfWhitespaceBeforeOffset ( text , nextPartitionPos ) ; if ( insertPos > 0 && text . charAt ( insertPos - 1 ) == character ) insertPos = insertPos - 1 ; else if ( insertPos > 0 && text . charAt ( insertPos - 1 ) == '}' ) { int opening = scanBackward ( document , insertPos - 1 + line . getOffset ( ) , partitioning , - 1 , new char [ ] { '{' } ) ; if ( opening > - 1 && opening < offset + line . getOffset ( ) ) { if ( computeArrayInitializationPos ( document , line , opening - line . getOffset ( ) , partitioning ) == - 1 ) { insertPos = offset ; } } } } } else { Assert . isTrue ( false ) ; return - 1 ; } return insertPos ; }
computes the next insert position of the given character in the current line .
