Enum Token.Type
- java.lang.Object
-
- java.lang.Enum<Token.Type>
-
- com.google.googlejavaformat.java.javadoc.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
JavadocWritergets 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
JavadocLexerwhen 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 Summary
Enum Constants Enum Constant Description BEGIN_JAVADOC∕✱✱BLOCKQUOTE_CLOSE_TAGBLOCKQUOTE_OPEN_TAGBR_TAGCODE_CLOSE_TAGCODE_OPEN_TAGEND_JAVADOC✱∕FOOTER_JAVADOC_TAG_STARTThe@foothat begins a block Javadoc tag like@throws.FORCED_NEWLINEA newline in a<pre>or<table>section.HEADER_CLOSE_TAGHEADER_OPEN_TAGHTML_COMMENTLIST_CLOSE_TAGLIST_ITEM_CLOSE_TAGLIST_ITEM_OPEN_TAGLIST_OPEN_TAGLITERALAnything else:foo,<b>,{@code foo}etc.MOE_BEGIN_STRIP_COMMENT<!-- MOE:begin_intracomment_strip -->MOE_END_STRIP_COMMENT<!-- MOE:end_intracomment_strip -->OPTIONAL_LINE_BREAKToken that permits but does not force a line break.PARAGRAPH_CLOSE_TAGPARAGRAPH_OPEN_TAGPRE_CLOSE_TAGPRE_OPEN_TAGTABLE_CLOSE_TAGTABLE_OPEN_TAGWHITESPACEWhitespace that is not in a<pre>or<table>section.
-
Constructor Summary
Constructors Modifier Constructor Description privateType()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Token.TypevalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static Token.Type[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
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@foothat 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
-
BR_TAG
public static final Token.Type BR_TAG
-
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 asJavadocWriteris concerned, this token is meaningless. But its mere existence preventsJavadocLexerfrom joining twoLITERALtokens 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.JavadocLexersometimes 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.
-
-
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 namejava.lang.NullPointerException- if the argument is null
-
-