private ExtractionInfo extractMultilineComment ( JsDocToken token , WhitespaceOption option , boolean isMarker , boolean includeAnnotations ) { StringBuilder builder = new StringBuilder ( ) ; int startLineno = - 1 ; int startCharno = - 1 ; if ( isMarker ) { stream . update ( ) ; startLineno = stream . getLineno ( ) ; startCharno = stream . getCharno ( ) + 1 ; String line = getRemainingJSDocLine ( ) ; if ( option != WhitespaceOption . PRESERVE ) { line = line . trim ( ) ; } builder . append ( line ) ; state = State . SEARCHING_ANNOTATION ; token = next ( ) ; } boolean ignoreStar = false ; // Track the start of the line to count whitespace that // the tokenizer skipped. Because this case is rare, it's easier // to do this here than in the tokenizer. int lineStartChar = - 1 ; do { switch ( token ) { case STAR : if ( ignoreStar ) { // Mark the position after the star as the new start of the line. lineStartChar = stream . getCharno ( ) + 1 ; ignoreStar = false ; } else { // The star is part of the comment. padLine ( builder , lineStartChar , option ) ; lineStartChar = - 1 ; builder . append ( ' ' ) ; } token = next ( ) ; while ( token == JsDocToken . STAR ) { if ( lineStartChar != - 1 ) { padLine ( builder , lineStartChar , option ) ; lineStartChar = - 1 ; } builder . append ( ' ' ) ; token = next ( ) ; } continue ; case EOL : if ( option != WhitespaceOption . SINGLE_LINE ) { builder . append ( ' ' ) ; } ignoreStar = true ; lineStartChar = 0 ; token = next ( ) ; continue ; default : ignoreStar = false ; state = State . SEARCHING_ANNOTATION ; boolean isEOC = token == JsDocToken . EOC ; if ( ! isEOC ) { padLine ( builder , lineStartChar , option ) ; lineStartChar = - 1 ; } if ( token == JsDocToken . EOC || token == JsDocToken . EOF || // When we're capturing a license block, annotations // in the block are OK. ( token == JsDocToken . ANNOTATION && ! includeAnnotations ) ) { String multilineText = builder . toString ( ) ; if ( option != WhitespaceOption . PRESERVE ) { multilineText = multilineText . trim ( ) ; } if ( isMarker && ! multilineText . isEmpty ( ) ) { int endLineno = stream . getLineno ( ) ; int endCharno = stream . getCharno ( ) ; jsdocBuilder . markText ( multilineText , startLineno , startCharno , endLineno , endCharno ) ; } return new ExtractionInfo ( multilineText , token ) ; } builder . append ( toString ( token ) ) ; String line = getRemainingJSDocLine ( ) ; if ( option != WhitespaceOption . PRESERVE ) { line = trimEnd ( line ) ; } builder . append ( line ) ; token = next ( ) ; } } while ( true ) ; }
Extracts text from the stream until the end of the comment end of the file or an annotation token is encountered . If the text is being extracted for a JSDoc marker the first line in the stream will always be included in the extract text .