Buggy code:
public class Scribe { private static final String EMPTY_STRING = "" ; private static final int INITIAL_SIZE = 100 ; private boolean checkLineWrapping ; public int column ; private int [ ] [ ] commentPositions ; public Alignment currentAlignment ; public int currentToken ; private OptimizedReplaceEdit [ ] edits ; public int editsIndex ; public CodeFormatterVisitor formatter ; public int indentationLevel ; public int lastNumberOfNewLines ; public int line ; private int [ ] lineEnds ; private String lineSeparator ; public Alignment memberAlignment ; public boolean needSpace = false ; public int nlsTagCounter ; public int pageWidth ; public boolean pendingSpace = false ; public Scanner scanner ; public int scannerEndPosition ; public int tabLength ; public int indentationSize ; private int textRegionEnd ; private int textRegionStart ; public int tabChar ; public int numberOfIndentations ; private boolean useTabsOnlyForLeadingIndents ; private final boolean indentEmptyLines ; Scribe ( CodeFormatterVisitor formatter , long sourceLevel , int offset , int length , CodeSnippetParsingUtil codeSnippetParsingUtil ) { } private final void addDeleteEdit ( int start , int end ) { } public final void addInsertEdit ( int insertPosition , String insertedString ) { } private final void addOptimizedReplaceEdit ( int offset , int length , String replacement ) { } public final void addReplaceEdit ( int start , int end , String replacement ) { } public void alignFragment ( Alignment alignment , int fragmentIndex ) { } public void checkNLSTag ( int sourceStart ) { } public void consumeNextToken ( ) { } public Alignment createAlignment ( String name , int mode , int count , int sourceRestart ) { } public Alignment createAlignment ( String name , int mode , int count , int sourceRestart , boolean adjust ) { } public Alignment createAlignment ( String name , int mode , int tieBreakRule , int count , int sourceRestart ) { } public Alignment createAlignment ( String name , int mode , int count , int sourceRestart , int continuationIndent , boolean adjust ) { } public Alignment createAlignment ( String name , int mode , int tieBreakRule , int count , int sourceRestart , int continuationIndent , boolean adjust ) { } public Alignment createMemberAlignment ( String name , int mode , int count , int sourceRestart ) { } public void enterAlignment ( Alignment alignment ) { } public void enterMemberAlignment ( Alignment alignment ) { } public void exitAlignment ( Alignment alignment , boolean discardAlignment ) { } public void exitMemberAlignment ( Alignment alignment ) { } public Alignment getAlignment ( String name ) { } public int getColumnIndentationLevel ( ) { } public final int getCommentIndex ( int position ) { } public String getEmptyLines ( int linesNumber ) { } public OptimizedReplaceEdit getLastEdit ( ) { } public final int getLineEnd ( int lineNumber ) { } Alignment getMemberAlignment ( ) { } public String getNewLine ( ) { } public int getNextIndentationLevel ( int someColumn ) { } private String getPreserveEmptyLines ( int count ) { } public TextEdit getRootEdit ( ) { } public void handleLineTooLong ( ) { } private boolean hasNLSTag ( int sourceStart ) { } public void indent ( ) { } public void initializeScanner ( char [ ] compilationUnitSource ) { this . scanner . setSource ( compilationUnitSource ) ; this . scannerEndPosition = compilationUnitSource . length ; <START_BUG> this . scanner . resetTo ( 0 , this . scannerEndPosition ) ; <END_BUG> this . edits = new OptimizedReplaceEdit [ Scribe . INITIAL_SIZE ] ; } private boolean isValidEdit ( OptimizedReplaceEdit edit ) { } private void preserveEmptyLines ( int count , int insertPosition ) { } private void print ( char [ ] s , boolean considerSpaceIfAny ) { } private void printBlockComment ( char [ ] s , boolean isJavadoc ) { } public void printEndOfCompilationUnit ( ) { } public void printComment ( ) { } private void printCommentLine ( char [ ] s ) { } public void printEmptyLines ( int linesNumber ) { } private void printEmptyLines ( int linesNumber , int insertPosition ) { } void printIndentationIfNecessary ( ) { } private void printIndentationIfNecessary ( StringBuffer buffer ) { } public void printModifiers ( Annotation [ ] annotations , ASTVisitor visitor ) { } public void printNewLine ( ) { } public void printNewLine ( int insertPosition ) { } public void printNextToken ( int expectedTokenType ) { } public void printNextToken ( int expectedTokenType , boolean considerSpaceIfAny ) { } public void printNextToken ( int [ ] expectedTokenTypes ) { } public void printNextToken ( int [ ] expectedTokenTypes , boolean considerSpaceIfAny ) { } public void printArrayQualifiedReference ( int numberOfTokens , int sourceEnd ) { } public void printQualifiedReference ( int sourceEnd ) { } private void printRule ( StringBuffer stringBuffer ) { } public void printTrailingComment ( ) { } void redoAlignment ( AlignmentException e ) { } void redoMemberAlignment ( AlignmentException e ) { } public void reset ( ) { } private void resetAt ( Location location ) { } private void resize ( ) { } public void space ( ) { } public String toString ( ) { } public void unIndent ( ) { } }

Fix:
this . scanner . resetTo ( 0 , ( ( this . scannerEndPosition ) - 1 ) ) ;