Buggy code:
public class CodeFormatterVisitor extends ASTVisitor { public static class MultiFieldDeclaration extends FieldDeclaration { FieldDeclaration [ ] declarations ; MultiFieldDeclaration ( FieldDeclaration [ ] declarations ) { } } public static final boolean DEBUG = false ; private static final int NO_MODIFIERS = 0 ; private static final int [ ] SINGLETYPEREFERENCE_EXPECTEDTOKENS = new int [ ] { TerminalTokens . TokenNameIdentifier , TerminalTokens . TokenNameboolean , TerminalTokens . TokenNamebyte , TerminalTokens . TokenNamechar , TerminalTokens . TokenNamedouble , TerminalTokens . TokenNamefloat , TerminalTokens . TokenNameint , TerminalTokens . TokenNamelong , TerminalTokens . TokenNameshort , TerminalTokens . TokenNamevoid } ; private static final int [ ] CLOSING_GENERICS_EXPECTEDTOKENS = new int [ ] { TerminalTokens . TokenNameRIGHT_SHIFT , TerminalTokens . TokenNameUNSIGNED_RIGHT_SHIFT , TerminalTokens . TokenNameGREATER } ; private int chunkKind ; public int lastLocalDeclarationSourceStart ; private Scanner localScanner ; public DefaultCodeFormatterOptions preferences ; public Scribe scribe ; public CodeFormatterVisitor ( DefaultCodeFormatterOptions preferences , Map settings , int offset , int length , CodeSnippetParsingUtil codeSnippetParsingUtil ) { } public void acceptProblem ( IProblem problem ) { } private BinaryExpressionFragmentBuilder buildFragments ( BinaryExpression binaryExpression , BlockScope scope ) { } private CascadingMethodInvocationFragmentBuilder buildFragments ( MessageSend messageSend , BlockScope scope ) { } public boolean checkChunkStart ( int kind ) { } private boolean commentStartsBlock ( int start , int end ) { } private ASTNode [ ] computeMergedMemberDeclarations ( ASTNode [ ] nodes ) { } private ASTNode [ ] computeMergedMemberDeclarations ( TypeDeclaration typeDeclaration ) { } private boolean dumpBinaryExpression ( BinaryExpression binaryExpression , int operator , BlockScope scope ) { } private boolean dumpEqualityExpression ( BinaryExpression binaryExpression , int operator , BlockScope scope ) { } private final TextEdit failedToFormat ( ) { } private void format ( AbstractMethodDeclaration methodDeclaration , ClassScope scope , boolean isChunkStart , boolean isFirstClassBodyDeclaration ) { } private void format ( FieldDeclaration fieldDeclaration , ASTVisitor visitor , MethodScope scope , boolean isChunkStart , boolean isFirstClassBodyDeclaration ) { } private void format ( ImportReference importRef , boolean isLast ) { this . scribe . printNextToken ( TerminalTokens . TokenNameimport ) ; this . preferences . number_of_empty_lines_to_preserve = this . preferences . blank_lines_between_import_groups ; this . scribe . space ( ) ; if ( importRef . isStatic ( ) ) { this . scribe . printNextToken ( TerminalTokens . TokenNamestatic ) ; this . scribe . space ( ) ; } <START_BUG> if ( importRef . onDemand ) { <END_BUG> this . scribe . printQualifiedReference ( importRef . sourceEnd ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameDOT ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameMULTIPLY ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; } else { this . scribe . printQualifiedReference ( importRef . sourceEnd ) ; this . scribe . printNextToken ( TerminalTokens . TokenNameSEMICOLON , this . preferences . insert_space_before_semicolon ) ; } if ( isLast ) { this . scribe . printTrailingComment ( ) ; } else { this . scribe . printTrailingComment ( this . preferences . blank_lines_between_import_groups ) ; } this . scribe . printNewLine ( ) ; } private void format ( CodeFormatterVisitor . MultiFieldDeclaration multiFieldDeclaration , ASTVisitor visitor , MethodScope scope , boolean isChunkStart , boolean isFirstClassBodyDeclaration ) { } public TextEdit format ( String string , ASTNode [ ] nodes ) { } public TextEdit format ( String string , CompilationUnitDeclaration compilationUnitDeclaration ) { } public TextEdit format ( String string , ConstructorDeclaration constructorDeclaration ) { } public TextEdit format ( String string , Expression expression ) { } public TextEdit format ( String string , CommentRegion region ) { } private void format ( TypeDeclaration typeDeclaration ) { } private void format ( TypeDeclaration memberTypeDeclaration , ClassScope scope , boolean isChunkStart , boolean isFirstClassBodyDeclaration ) { } private void formatAnonymousTypeDeclaration ( TypeDeclaration typeDeclaration ) { } private void formatBlock ( Block block , BlockScope scope , String block_brace_position , boolean insertSpaceBeforeOpeningBrace ) { } private void formatCascadingMessageSends ( CascadingMethodInvocationFragmentBuilder builder , BlockScope scope ) { } private void formatClassBodyDeclarations ( ASTNode [ ] nodes ) { } private void formatEmptyTypeDeclaration ( boolean isFirst ) { } private void formatGuardClauseBlock ( Block block , BlockScope scope ) { } private void formatLeftCurlyBrace ( final int line , final String bracePosition ) { } private void formatLocalDeclaration ( LocalDeclaration localDeclaration , BlockScope scope , boolean insertSpaceBeforeComma , boolean insertSpaceAfterComma ) { } private void formatMessageSend ( MessageSend messageSend , BlockScope scope , Alignment messageAlignment ) { } private void formatMethodArguments ( AbstractMethodDeclaration methodDeclaration , boolean spaceBeforeOpenParen , boolean spaceBetweenEmptyParameters , boolean spaceBeforeClosingParen , boolean spaceBeforeFirstParameter , boolean spaceBeforeComma , boolean spaceAfterComma , int methodDeclarationParametersAlignment ) { } private void formatEnumConstantArguments ( FieldDeclaration enumConstant , boolean spaceBeforeOpenParen , boolean spaceBetweenEmptyParameters , boolean spaceBeforeClosingParen , boolean spaceBeforeFirstParameter , boolean spaceBeforeComma , boolean spaceAfterComma , int methodDeclarationParametersAlignment ) { } private void formatNecessaryEmptyStatement ( ) { } private void formatOpeningBrace ( String bracePosition , boolean insertSpaceBeforeBrace ) { } private void formatStatements ( BlockScope scope , final Statement [ ] statements , boolean insertNewLineAfterLastStatement ) { } private void formatThrowsClause ( AbstractMethodDeclaration methodDeclaration , boolean spaceBeforeComma , boolean spaceAfterComma , int alignmentForThrowsClause ) { } private void formatTypeMembers ( TypeDeclaration typeDeclaration ) { } private void formatTypeOpeningBraceForEnumConstant ( String bracePosition , boolean insertSpaceBeforeBrace , TypeDeclaration typeDeclaration ) { } private void formatTypeOpeningBrace ( String bracePosition , boolean insertSpaceBeforeBrace , TypeDeclaration typeDeclaration ) { } private int getDimensions ( ) { } private boolean hasComments ( ) { } private boolean isNextToken ( int tokenName ) { } private boolean isClosingGenericToken ( ) { } private boolean isGuardClause ( Block block ) { } private boolean isMultipleLocalDeclaration ( LocalDeclaration localDeclaration ) { } private boolean isPartOfMultipleLocalDeclaration ( ) { } private void manageClosingParenthesizedExpression ( Expression expression , int numberOfParens ) { } private void manageOpeningParenthesizedExpression ( Expression expression , int numberOfParens ) { } public boolean visit ( AllocationExpression allocationExpression , BlockScope scope ) { }

Fix:
if ( ( ( importRef . bits ) & ( ASTNode . OnDemand ) ) != 0 ) {