Enum Token.Type

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<Token.Type>
    Enclosing class:
    Token

    static enum Token.Type
    extends java.lang.Enum<Token.Type>
    Javadoc token type.

    The general idea is that every token that requires special handling (extra line breaks, indentation, forcing or forbidding whitespace) from JavadocWriter gets its own type. But I haven't been super careful about it, so I'd imagine that we could merge or remove some of these if we wanted. (For example, PARAGRAPH_CLOSE_TAG and LIST_ITEM_CLOSE_TAG could share a common IGNORABLE token type. But their corresponding OPEN tags exist, so I've kept the CLOSE tags.)

    Note, though, that tokens of the same type may still have been handled differently by JavadocLexer when it created them. For example, LITERAL is used for both plain text and inline tags, even though the two affect the lexer's state differently.

    • Enum Constant Detail

      • BEGIN_JAVADOC

        public static final Token.Type BEGIN_JAVADOC
        ∕✱✱
      • END_JAVADOC

        public static final Token.Type END_JAVADOC
        ✱∕
      • FOOTER_JAVADOC_TAG_START

        public static final Token.Type FOOTER_JAVADOC_TAG_START
        The @foo that begins a block Javadoc tag like @throws.
      • LIST_OPEN_TAG

        public static final Token.Type LIST_OPEN_TAG
      • LIST_CLOSE_TAG

        public static final Token.Type LIST_CLOSE_TAG
      • LIST_ITEM_OPEN_TAG

        public static final Token.Type LIST_ITEM_OPEN_TAG
      • LIST_ITEM_CLOSE_TAG

        public static final Token.Type LIST_ITEM_CLOSE_TAG
      • HEADER_OPEN_TAG

        public static final Token.Type HEADER_OPEN_TAG
      • HEADER_CLOSE_TAG

        public static final Token.Type HEADER_CLOSE_TAG
      • PARAGRAPH_OPEN_TAG

        public static final Token.Type PARAGRAPH_OPEN_TAG
      • PARAGRAPH_CLOSE_TAG

        public static final Token.Type PARAGRAPH_CLOSE_TAG
      • BLOCKQUOTE_OPEN_TAG

        public static final Token.Type BLOCKQUOTE_OPEN_TAG
      • BLOCKQUOTE_CLOSE_TAG

        public static final Token.Type BLOCKQUOTE_CLOSE_TAG
      • PRE_OPEN_TAG

        public static final Token.Type PRE_OPEN_TAG
      • PRE_CLOSE_TAG

        public static final Token.Type PRE_CLOSE_TAG
      • CODE_OPEN_TAG

        public static final Token.Type CODE_OPEN_TAG
      • CODE_CLOSE_TAG

        public static final Token.Type CODE_CLOSE_TAG
      • TABLE_OPEN_TAG

        public static final Token.Type TABLE_OPEN_TAG
      • TABLE_CLOSE_TAG

        public static final Token.Type TABLE_CLOSE_TAG
      • MOE_BEGIN_STRIP_COMMENT

        public static final Token.Type MOE_BEGIN_STRIP_COMMENT
        <!-- MOE:begin_intracomment_strip -->
      • MOE_END_STRIP_COMMENT

        public static final Token.Type MOE_END_STRIP_COMMENT
        <!-- MOE:end_intracomment_strip -->
      • HTML_COMMENT

        public static final Token.Type HTML_COMMENT
      • WHITESPACE

        public static final Token.Type WHITESPACE
        Whitespace that is not in a <pre> or <table> section. Whitespace includes leading newlines, asterisks, and tabs and spaces. In the output, it is translated to newlines (with leading spaces and asterisks) or spaces.
      • FORCED_NEWLINE

        public static final Token.Type FORCED_NEWLINE
        A newline in a <pre> or <table> section. We preserve user formatting in these sections, including newlines.
      • OPTIONAL_LINE_BREAK

        public static final Token.Type OPTIONAL_LINE_BREAK
        Token that permits but does not force a line break. The way that we accomplish this is somewhat indirect: As far as JavadocWriter is concerned, this token is meaningless. But its mere existence prevents JavadocLexer from joining two LITERAL tokens that would otherwise be adjacent. Since this token is not real whitespace, the writer may end up writing the literals together with no space between, just as if they'd been joined. However, if they don't fit together on the line, the writer will write the first one, start a new line, and write the second. Hence, the token acts as an optional line break.
      • LITERAL

        public static final Token.Type LITERAL
        Anything else: foo, <b>, {@code foo} etc. JavadocLexer sometimes creates adjacent literal tokens, which it then merges into a single, larger literal token before returning its output.

        This also includes whitespace in a <pre> or <table> section. We preserve user formatting in these sections, including arbitrary numbers of spaces. By treating such whitespace as a literal, we can merge it with adjacent literals, preventing us from autowrapping inside these sections -- and doing so naively, to boot. The wrapped line would have no indentation after "* " or, possibly worse, it might begin with an arbitrary amount of whitespace that didn't fit on the previous line. Of course, by doing this, we're potentially creating lines of more than 100 characters. But it seems fair to call in the humans to resolve such problems.

    • Constructor Detail

      • Type

        private Type()
    • Method Detail

      • values

        public static Token.Type[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Token.Type c : Token.Type.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Token.Type valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null