Generate the Javadoc comment header for a bitset choice option encode method.

@param indent      level for the comment.
@param optionToken for the type.
@return a string representation of the Javadoc comment.
544437
public static String generateOptionEncodeJavadoc(final String indent, final Token optionToken)
    {
        final String description = optionToken.description();
        if (null == description || description.isEmpty())
        {
            return "";
        }

        return
            indent + "/**\n" +
            indent + " * " + description + '\n' +
            indent + " *\n" +
            indent + " * @param value true if " + optionToken.name() + " is set or false if not\n" +
            indent + " */\n";
    }
804522
function blockHeader(string, indentPerLevel) {
  var indentIndicator = string[0] === ' ' ? String(indentPerLevel) : '';

  // note the special case: the string '\n' counts as a "trailing" empty line.
  var clip = string[string.length - 1] === '\n';
  var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
  var chomp = keep ? '+' : clip ? '' : '-';

  return indentIndicator + chomp + '\n';
}
663867
public final void mDOCUMENT_COMMENT() throws RecognitionException {
        try {
            int _type = DOCUMENT_COMMENT;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // BELScript.g:253:17: ( '#' (~ ( '\\n' | '\\r' ) )* )
            // BELScript.g:254:5: '#' (~ ( '\\n' | '\\r' ) )*
            {
            match('#'); 
            // BELScript.g:254:9: (~ ( '\\n' | '\\r' ) )*
            loop1:
            do {
                int alt1=2;
                int LA1_0 = input.LA(1);

                if ( ((LA1_0>='\u0000' && LA1_0<='\t')||(LA1_0>='\u000B' && LA1_0<='\f')||(LA1_0>='\u000E' && LA1_0<='\uFFFF')) ) {
                    alt1=1;
                }


                switch (alt1) {
            	case 1 :
            	    // BELScript.g:254:9: ~ ( '\\n' | '\\r' )
            	    {
            	    if ( (input.LA(1)>='\u0000' && input.LA(1)<='\t')||(input.LA(1)>='\u000B' && input.LA(1)<='\f')||(input.LA(1)>='\u000E' && input.LA(1)<='\uFFFF') ) {
            	        input.consume();

            	    }
            	    else {
            	        MismatchedSetException mse = new MismatchedSetException(null,input);
            	        recover(mse);
            	        throw mse;}


            	    }
            	    break;

            	default :
            	    break loop1;
                }
            } while (true);

            _channel=HIDDEN;

            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
699209
public static int optionLength(String option) {
        if(matchOption(option, "qualify", true) ||
           matchOption(option, "qualifyGenerics", true) ||
           matchOption(option, "hideGenerics", true) ||
           matchOption(option, "horizontal", true) ||
           matchOption(option, "all") ||
           matchOption(option, "attributes", true) ||
           matchOption(option, "enumconstants", true) ||
           matchOption(option, "operations", true) ||
           matchOption(option, "enumerations", true) ||
           matchOption(option, "constructors", true) ||
           matchOption(option, "visibility", true) ||
           matchOption(option, "types", true) ||
           matchOption(option, "autosize", true) ||
           matchOption(option, "commentname", true) ||
           matchOption(option, "nodefontabstractitalic", true) ||
           matchOption(option, "postfixpackage", true) ||
           matchOption(option, "noguillemot", true) ||
           matchOption(option, "views", true) ||
           matchOption(option, "inferrel", true) ||
           matchOption(option, "useimports", true) ||
           matchOption(option, "collapsible", true) ||
           matchOption(option, "inferdep", true) ||
           matchOption(option, "inferdepinpackage", true) ||
           matchOption(option, "hideprivateinner", true) ||
           matchOption(option, "compact", true))

            return 1;
        else if(matchOption(option, "nodefillcolor") ||
           matchOption(option, "nodefontcolor") ||
           matchOption(option, "nodefontsize") ||
           matchOption(option, "nodefontname") ||
           matchOption(option, "nodefontclasssize") ||
           matchOption(option, "nodefontclassname") ||
           matchOption(option, "nodefonttagsize") ||
           matchOption(option, "nodefonttagname") ||
           matchOption(option, "nodefontpackagesize") ||
           matchOption(option, "nodefontpackagename") ||
           matchOption(option, "edgefontcolor") ||
           matchOption(option, "edgecolor") ||
           matchOption(option, "edgefontsize") ||
           matchOption(option, "edgefontname") ||
           matchOption(option, "shape") ||
           matchOption(option, "output") ||
           matchOption(option, "outputencoding") ||
           matchOption(option, "bgcolor") ||
           matchOption(option, "hide") ||
           matchOption(option, "include") ||
           matchOption(option, "apidocroot") ||
           matchOption(option, "apidocmap") ||
           matchOption(option, "d") ||
           matchOption(option, "view") ||
           matchOption(option, "inferreltype") ||
           matchOption(option, "inferdepvis") ||
           matchOption(option, "collpackages") ||
           matchOption(option, "nodesep") ||
           matchOption(option, "ranksep") ||
           matchOption(option, "dotexecutable") ||
           matchOption(option, "link"))
           return 2;
        else if(matchOption(option, "contextPattern") ||
           matchOption(option, "linkoffline"))
            return 3;
        else
            return 0;
    }
1349534
public String format(Comment comment, int indentLevel, CommentLocation commentLocation) {

        // Return if there's nothing to do
        if (comment == null || comment.getContent() == null) {
            return null;
        }

        return format(comment.getContent(), indentLevel, commentLocation);
    }
424386
public String format(Comment comment) {
        if (comment == null) {
            return "";
        }

        StringBuilder sb = new StringBuilder();

        for (CommentElement e : comment) {
            if (e instanceof CommentText) {
                sb.append(renderText((CommentText) e));

            } else if (e instanceof InlineLink) {
                sb.append(renderLink((InlineLink) e));
    
            } else if (e instanceof InlineValue) {
                sb.append(renderValue((InlineValue) e));
    
            } else if (e instanceof InlineTag) {
                sb.append(renderTag((InlineTag) e));

            } else {
                sb.append(renderUnrecognized(e));
            }
        }

        return sb.toString();
    }
788691
JCTree typeDeclaration(JCModifiers mods, Comment docComment) {
        int pos = token.pos;
        if (mods == null && token.kind == SEMI) {
            nextToken();
            return toP(F.at(pos).Skip());
        } else {
            return classOrInterfaceOrEnumDeclaration(modifiersOpt(mods), docComment);
        }
    }
1359752
public String format(String comment, int indentLevel, CommentLocation commentLocation) {

        // Return if there's nothing to do
        if (comment == null) {
            return null;
        }

        final StringBuilder indentString = new StringBuilder();
        for (int i = 0; i < indentLevel; i++) {
            indentString.append("    ");
        }

        // Comment ends with newline
        boolean endsWithNewline = (comment.endsWith("\r\n") || comment.endsWith("\n"));

        List<String> matchList = new ArrayList<String>();
        Matcher regexMatcher = commentFormattingRegex.matcher(comment);
        while (regexMatcher.find()) {
            matchList.add(regexMatcher.group());
        }

        StringBuilder builder = new StringBuilder();

        for (int i = 0; i < matchList.size(); i++) {

            String indent;
            String newline;

            if (commentLocation.equals(CommentLocation.END)) {
                indent = " ";
                newline = "";
            } else {
                indent = indentString.toString();
                newline = "\n";
            }

            // We need to handle the last newline
            if (i == 0) {
                builder.append(indent + matchList.get(i).trim() + newline);
            } else if (i == matchList.size() - 1) {
                builder.append(indent + " " + matchList.get(i).trim() + (endsWithNewline ? newline : ""));
            } else {
                builder.append(indent + " " + matchList.get(i).trim() + newline);
            }
        }

        return builder.toString();
    }
1195583
@javax.annotation.Nonnull
  public static String getIndent(@javax.annotation.Nonnull final String txt) {
    @javax.annotation.Nonnull final Matcher matcher = Pattern.compile("^\\s+").matcher(txt);
    return matcher.find() ? matcher.group(0) : "";
  }
29680
public String formatStringAsJavadoc(String input) {

        if (input == null) {
            return null;
        }

        final StringBuilder finalComment = new StringBuilder("/**\n");
        Matcher regexMatcher = commentFormattingRegex.matcher(input);
        while (regexMatcher.find()) {
            finalComment.append("* ");
            finalComment.append(regexMatcher.group());
        }
        finalComment.append("\n*/\n");

        return finalComment.toString();
    }
1325801
static public String encode(byte[] bytes, String indentation) {
        StringBuilder result = new StringBuilder();
        int length = bytes.length;
        if (length == 0) return "";  // empty byte array
        if (indentation != null) result.append(indentation);
        encodeByte(bytes, 0, result);
        for (int i = 1; i < length; i++) {
            if (i % 40 == 0) {
                // format to indented 80 character blocks
                result.append("\n");
                if (indentation != null) result.append(indentation);
            }
            encodeByte(bytes, i, result);
        }
        return result.toString();
    }
1319336
static Comment createCommentFromToken(Token token) {
        String commentText = token.image;
        if (token.kind == JAVADOC_COMMENT) {
            return new JavadocComment(tokenRange(token), commentText.substring(3, commentText.length() - 2));
        } else if (token.kind == MULTI_LINE_COMMENT) {
            return new BlockComment(tokenRange(token), commentText.substring(2, commentText.length() - 2));
        } else if (token.kind == SINGLE_LINE_COMMENT) {
            // line comments have their end of line character(s) included, and we don't want that.
            Range range = new Range(pos(token.beginLine, token.beginColumn), pos(token.endLine, token.endColumn));
            while (commentText.endsWith("\r") || commentText.endsWith("\n")) {
                commentText = commentText.substring(0, commentText.length() - 1);
            }
            range = range.withEnd(pos(range.begin.line, range.begin.column + commentText.length()));
            LineComment comment = new LineComment(tokenRange(token), commentText.substring(2));
            comment.setRange(range);
            return comment;
        }
        throw new AssertionError("Unexpectedly got passed a non-comment token.");
    }
1145789
void writeJavadocComment(String methodComment, Writer writer) throws IOException {
		// From javadoc
		if (methodComment != null) {
			methodComment = methodComment.split("@")[0];
			int lastIndexOf = methodComment.lastIndexOf("\n");
			if (lastIndexOf >= 0) {
				methodComment = methodComment.substring(0, lastIndexOf);
			}
			String comment = methodComment.replaceAll("\n", CR+TAB2+" *");
			writer.append(TAB2).append(" *").append(comment).append(CR);
		}
	}
657487
protected static String toStringForTermedDocument(TermedDocument o) {
		StringBuilder sb = new StringBuilder();
		boolean first;

		sb.append("\n* Labels: ");
		first = true;
		SortedSet<String> labelKeys = new TreeSet<>(o.getLabels()
				.keySet());
		for (String key : labelKeys) {
			if (first) {
				first = false;
			} else {
				sb.append("; ");
			}
			sb.append(toString(o.getLabels().get(key)));
		}

		sb.append("\n* Descriptions: ");
		first = true;
		SortedSet<String> descriptionKeys = new TreeSet<>(o
				.getDescriptions().keySet());
		for (String key : descriptionKeys) {
			if (first) {
				first = false;
			} else {
				sb.append("; ");
			}
			sb.append(toString(o.getDescriptions().get(key)));
		}

		sb.append("\n* Aliases: ");
		first = true;
		SortedSet<String> aliasKeys = new TreeSet<>(o.getAliases()
				.keySet());
		for (String key : aliasKeys) {
			for (MonolingualTextValue mtv : o.getAliases().get(key)) {
				if (first) {
					first = false;
				} else {
					sb.append("; ");
				}
				sb.append(toString(mtv));
			}
		}

		return sb.toString();
	}
1039346
private function _generate(&$options, &$selected, $level = 0)
    {

        $content = '';

        // character(s) used for indenting levels
        $indent = '&nbsp;&nbsp;';

        // iterate through the available options
        foreach ($options as $value => $caption) {

            // if option has child options
            if (is_array($caption)) {

                // create a dummy option group (for valid HTML/XHTML we are not allowed to create nested option groups
                // and also empty optiongroups are not allowed)
                // BUT because in IE7 the "disabled" attribute is not supported and in all versions of IE these
                // can't be styled, we will remove them from JavaScript
                // having a dummy option in them (the option is disabled and, from CSS, rendered invisible)
                $content .= '
                    <optgroup label="' . str_repeat($indent, $level) . $value . '">
                        <option disabled="disabled" class="dummy"></option>
                    </optgroup>
                ';

                // call the method recursively to generate the output for the children options
                $content .= $this->_generate($caption, $selected, $level + 1);

            // if entry is a standard option
            } else {

                // create the appropriate code
                $content .= '<option value="' . $value . '"' .

                    // if anything was selected
					($selected !== '' && $value !== '' &&

                    	(

                            // and the current option is selected
    						(is_array($selected) && in_array($value, $selected)) ||

                    		(!is_array($selected) && (string)$value === (string)$selected)

                        // set the appropriate attribute
    					) ? ' selected="selected"' : ''

                    ) . '>' .

                // indent appropriately
                str_repeat($indent, $level) . $caption . '</option>';

            }

        }

        // return generated content
        return $content;

    }
1008415
private static String print(final String indent, JDToken token) {
        return token.match(new JDToken.MatchBlock<String>() {

            @Override
            public String _case(JDAsterisk x) {
                return "*";
            }

            @Override
            public String _case(JDEOL x) {
                return x.content + indent;
            }

            @Override
            public String _case(JDTag x) {
                return x.name;
            }

            @Override
            public String _case(JDWord x) {
                return x.word;
            }

            @Override
            public String _case(JDWhiteSpace x) {
                return x.ws;
            }
        });
    }
898945
protected void afterEndDocument() {
        depth = 0;
        final Set<StackState> state = scopeState.getFirst();
        if (state.contains(StackState.WROTE_MARKUP)
                && !state.contains(StackState.WROTE_DATA)) { // but not data
            try {
                final String indent = getLineSeparator() + StringUtils.repeat("  ", 0);
                final Characters indentEvent = xmlEventFactory.createCharacters(indent);
                wrappedWriter.add(indentEvent);
            } catch (Exception ignored) {
            }
        }
        scopeState.clear();
        scopeState.push(EnumSet.noneOf(StackState.class)); // start fresh
    }