Class JavadocLexer
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Patternprivate static final Patternprivate static final Patternprivate final NestingCounterprivate static final Patternprivate static final Patternprivate final NestingCounterprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate final CharStreamprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final com.google.common.base.CharMatcherprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate static final Patternprivate final NestingCounterprivate booleanprivate static final Patternprivate static final Patternprivate final NestingCounter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprivate static PatterncloseTagPattern(String namePattern) private Token.Typeprivate static voiddeindentPreCodeBlock(com.google.common.collect.ImmutableList.Builder<Token> output, com.google.common.collect.PeekingIterator<Token> tokens) private static com.google.common.collect.ImmutableList<Token> deindentPreCodeBlocks(List<Token> input) Adjust indentation inside `private static Patternprivate com.google.common.collect.ImmutableList<Token> private static booleanprivate static com.google.common.collect.ImmutableList<Token> inferParagraphTags(List<Token> input) Where the input has two consecutive line breaks between literals, insert a<p>tag between the literals.private static com.google.common.collect.ImmutableList<Token> Join together adjacent literal tokens, and join together adjacent whitespace tokens.(package private) static com.google.common.collect.ImmutableList<Token> Takes a Javadoc comment, including ∕✱✱ and ✱∕, and returns tokens, including ∕✱✱ and ✱∕.private static StringnormalizeLineEndings(String input) The lexer crashes on windows line endings, so for now just normalize to `\n`.private static PatternopenTagPattern(String namePattern) private static com.google.common.collect.ImmutableList<Token> optionalizeSpacesAfterLinks(List<Token> input) Replaces whitespace after ahref=...>token with an "optional link break." This allows us to output either<a href=foo>foo</a>or<a href=foo>\nfoo</a>, depending on how much space we have left on the line.private booleanprivate Tokenprivate static StringstripJavadocBeginAndEnd(String input)
-
Field Details
-
NON_UNIX_LINE_ENDING
-
input
-
braceDepth
-
preDepth
-
codeDepth
-
tableDepth
-
somethingSinceNewline
private boolean somethingSinceNewline -
NEWLINE
private static final com.google.common.base.CharMatcher NEWLINE -
NEWLINE_PATTERN
-
FOOTER_TAG_PATTERN
-
MOE_BEGIN_STRIP_COMMENT_PATTERN
-
MOE_END_STRIP_COMMENT_PATTERN
-
HTML_COMMENT_PATTERN
-
PRE_OPEN_PATTERN
-
PRE_CLOSE_PATTERN
-
CODE_OPEN_PATTERN
-
CODE_CLOSE_PATTERN
-
TABLE_OPEN_PATTERN
-
TABLE_CLOSE_PATTERN
-
LIST_OPEN_PATTERN
-
LIST_CLOSE_PATTERN
-
LIST_ITEM_OPEN_PATTERN
-
LIST_ITEM_CLOSE_PATTERN
-
HEADER_OPEN_PATTERN
-
HEADER_CLOSE_PATTERN
-
PARAGRAPH_OPEN_PATTERN
-
PARAGRAPH_CLOSE_PATTERN
-
BLOCKQUOTE_OPEN_PATTERN
-
BLOCKQUOTE_CLOSE_PATTERN
-
BR_PATTERN
-
INLINE_TAG_OPEN_PATTERN
-
LITERAL_PATTERN
-
-
Constructor Details
-
JavadocLexer
-
-
Method Details
-
lex
static com.google.common.collect.ImmutableList<Token> lex(String input) throws JavadocLexer.LexException Takes a Javadoc comment, including ∕✱✱ and ✱∕, and returns tokens, including ∕✱✱ and ✱∕.- Throws:
JavadocLexer.LexException
-
normalizeLineEndings
The lexer crashes on windows line endings, so for now just normalize to `\n`. -
stripJavadocBeginAndEnd
-
generateTokens
private com.google.common.collect.ImmutableList<Token> generateTokens() throws JavadocLexer.LexException- Throws:
JavadocLexer.LexException
-
readToken
- Throws:
JavadocLexer.LexException
-
consumeToken
- Throws:
JavadocLexer.LexException
-
preserveExistingFormatting
private boolean preserveExistingFormatting() -
checkMatchingTags
- Throws:
JavadocLexer.LexException
-
joinAdjacentLiteralsAndAdjacentWhitespace
private static com.google.common.collect.ImmutableList<Token> joinAdjacentLiteralsAndAdjacentWhitespace(List<Token> input) Join together adjacent literal tokens, and join together adjacent whitespace tokens.For literal tokens, this means something like
["<b>", "foo", "</b>"] => ["<b>foo</b>"]. SeeLITERAL_PATTERNfor discussion of why those tokens are separate to begin with.Whitespace tokens are treated analogously. We don't really "want" to join whitespace tokens, but in the course of joining literals, we incidentally join whitespace, too. We do take advantage of the joining later on: It simplifies
inferParagraphTags(java.util.List<com.google.googlejavaformat.java.javadoc.Token>).Note that we do not merge a literal token and a whitespace token together.
-
inferParagraphTags
Where the input has two consecutive line breaks between literals, insert a<p>tag between the literals.This method must be called after
joinAdjacentLiteralsAndAdjacentWhitespace(java.util.List<com.google.googlejavaformat.java.javadoc.Token>), as it assumes that adjacent whitespace tokens have already been joined. -
optionalizeSpacesAfterLinks
private static com.google.common.collect.ImmutableList<Token> optionalizeSpacesAfterLinks(List<Token> input) Replaces whitespace after ahref=...>token with an "optional link break." This allows us to output either<a href=foo>foo</a>or<a href=foo>\nfoo</a>, depending on how much space we have left on the line.This method must be called after
joinAdjacentLiteralsAndAdjacentWhitespace(java.util.List<com.google.googlejavaformat.java.javadoc.Token>), as it assumes that adjacent whitespace tokens have already been joined. -
deindentPreCodeBlocks
private static com.google.common.collect.ImmutableList<Token> deindentPreCodeBlocks(List<Token> input) Adjust indentation inside `` blocks. <p>Also trim leading and trailing blank lines, and move the trailing `` to its own line. -
deindentPreCodeBlock
-
hasMultipleNewlines
-
fullCommentPattern
-
openTagPattern
-
closeTagPattern
-