Buggy code:
public class JSFormatterNodeBuilder extends AbstractFormatterNodeBuilder { private FormatterDocument document ; private boolean hasErrors ; private Set < Integer > singleLinecommentEndOffsets ; private Set < Integer > multiLinecommentEndOffsets ; public IFormatterContainerNode build ( IParseNode parseResult , FormatterDocument document ) { } public boolean hasErrors ( ) { } private void generateCommentEndOffsets ( IParseNode [ ] comments ) { singleLinecommentEndOffsets = new HashSet < Integer > ( ) ; multiLinecommentEndOffsets = new HashSet < Integer > ( ) ; if ( comments == null ) { return ; } boolean onOffEnabled = document . getBoolean ( FORMATTER_OFF_ON_ENABLED ) ; LinkedHashMap < Integer , String > commentsMap = ( onOffEnabled ) ? new LinkedHashMap < Integer , String > ( comments . length ) : null ; for ( IParseNode comment : comments ) { short commentType = comment . getNodeType ( ) ; int end = comment . getEndingOffset ( ) ; if ( commentType == ( IJSNodeTypes . SINGLE_LINE_COMMENT ) ) { <START_BUG> singleLinecommentEndOffsets . add ( getNextNonWhiteCharOffset ( document , end ) ) ; <END_BUG> } else if ( ( ( commentType == ( IJSNodeTypes . MULTI_LINE_COMMENT ) ) || ( commentType == ( IJSNodeTypes . SDOC_COMMENT ) ) ) || ( commentType == ( IJSNodeTypes . VSDOC_COMMENT ) ) ) { multiLinecommentEndOffsets . add ( getNextNonWhiteCharOffset ( document , ( end + 1 ) ) ) ; } if ( onOffEnabled ) { int start = comment . getStartingOffset ( ) ; String commentStr = document . get ( start , end ) ; commentsMap . put ( start , commentStr ) ; } } if ( onOffEnabled && ( ! ( commentsMap . isEmpty ( ) ) ) ) { Pattern onPattern = Pattern . compile ( Pattern . quote ( document . getString ( FORMATTER_ON ) ) ) ; Pattern offPattern = Pattern . compile ( Pattern . quote ( document . getString ( FORMATTER_OFF ) ) ) ; setOffOnRegions ( FormatterUtils . resolveOnOffRegions ( commentsMap , onPattern , offPattern , ( ( document . getLength ( ) ) - 1 ) ) ) ; } } private boolean hasSingleCommentBefore ( int offset ) { } private boolean hasMultiLineCommentBefore ( int offset ) { } private boolean hasAnyCommentBefore ( int offset ) { } private class JSFormatterTreeWalker extends JSTreeWalker { @ Override public void visit ( JSFunctionNode node ) { } @ Override public void visit ( JSErrorNode node ) { } @ Override public void visit ( JSFalseNode node ) { } @ Override public void visit ( JSTrueNode node ) { } @ Override public void visit ( JSEmptyNode node ) { } @ Override public void visit ( JSPostUnaryOperatorNode node ) { } @ Override public void visit ( JSPreUnaryOperatorNode node ) { } @ Override public void visit ( JSConditionalNode node ) { } @ Override public void visit ( JSIfNode node ) { } @ Override public void visit ( JSDoNode node ) { } @ Override public void visit ( JSArrayNode node ) { } @ Override public void visit ( JSElementsNode node ) { } @ Override public void visit ( JSWhileNode node ) { } @ Override public void visit ( JSForNode node ) { } @ Override public void visit ( JSForInNode node ) { } @ Override public void visit ( JSWithNode node ) { } @ Override public void visit ( JSStatementsNode node ) { } @ Override public void visit ( JSObjectNode node ) { } @ Override public void visit ( JSNameValuePairNode node ) { } @ Override public void visit ( JSSwitchNode node ) { } @ Override public void visit ( JSCaseNode node ) { } @ Override public void visit ( JSDefaultNode node ) { } @ Override public void visit ( JSTryNode node ) { } @ Override public void visit ( JSCatchNode node ) { } @ Override public void visit ( JSFinallyNode node ) { } @ Override public void visit ( JSVarNode node ) { } @ Override public void visit ( JSDeclarationNode node ) { } @ Override public void visit ( JSAssignmentNode node ) { } @ Override public void visit ( JSIdentifierNode node ) { } public void visit ( JSConstructNode node ) { } @ Override public void visit ( JSBinaryArithmeticOperatorNode node ) { } @ Override public void visit ( JSArgumentsNode node ) { } @ Override public void visit ( JSBinaryBooleanOperatorNode node ) { } @ Override public void visit ( JSContinueNode node ) { } @ Override public void visit ( JSCommaNode node ) { } @ Override public void visit ( JSInvokeNode node ) { } @ Override public void visit ( JSReturnNode node ) { } @ Override public void visit ( JSThrowNode node ) { } @ Override public void visit ( JSBreakNode node ) { } @ Override public void visit ( JSGroupNode node ) { } @ Override public void visit ( JSGetElementNode node ) { } @ Override public void visit ( JSGetPropertyNode node ) { } public void visit ( JSNumberNode node ) { } @ Override public void visit ( JSStringNode node ) { } @ Override public void visit ( JSNullNode node ) { } @ Override public void visit ( JSThisNode node ) { } @ Override public void visit ( JSRegexNode node ) { } private FormatterJSDefaultLineNode pushLineNode ( JSNode node ) { } private void pushNodeInParentheses ( char openChar , char closeChar , int parenLookupStart , int parenLookupEnd , JSNode node , boolean visitOnlyChildren ) { } private void visitNodeLists ( List < ? extends JSNode > leftNodes , List < ? extends JSNode > rightNodes , TypeOperator pairsOperator , TypePunctuation pairsSeparator ) { } private void pushTypeOperator ( TypeOperator operator , int startOffset , boolean isUnary ) { } private void pushTypePunctuation ( TypePunctuation punctuation , int startOffset ) { }

Fix:
singleLinecommentEndOffsets . add ( getNextNonWhiteCharOffset ( document , ( end + 1 ) ) ) ;