Class JavadocMetadataScraperUtil
java.lang.Object
com.puppycrawl.tools.checkstyle.meta.JavadocMetadataScraperUtil
Class for scraping module metadata from the corresponding class' class-level javadoc.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final PatternRegular expression for detecting ANTLR tokens(for e.g. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringadjustCodeInlineTagChildToHtml(DetailNode codeChild) Adjusts certain child of@codeJavadoc inline tag to its analogous html format.static StringadjustLiteralInlineTagChildToText(DetailNode literalChild) Adjusts a child of@literalJavadoc inline tag to its XML-escaped plain text form.static StringconstructSubTreeText(DetailNode startNode, DetailNode endNode) Performs a depth-first traversal of the subtree starting atstartNodeand ending atendNode, and constructs the concatenated text of all nodes in that range, ignoringJavadocTokentexts.private static StringescapeXmlChars(String text) Escapes special XML characters in the given text.private static Optional<DetailNode> getFirstChildOfType(DetailNode node, int tokenType) Returns the first child node of the given parent that matches the providedtokenType.static booleanisChildNodeTextMatches(DetailNode ast, Pattern pattern) Checks whether the first childJavadocTokenType.TEXTnode matches given pattern.private static booleanisContentToWrite(DetailNode detailNode) Checks whether selected Javadoc node is considered as something to write.private static booleanChecks whether the given node is inside a@codeJavadoc inline tag.private static booleanChecks whether the given node is inside a@literalJavadoc inline tag.
-
Field Details
-
TOKEN_TEXT_PATTERN
Regular expression for detecting ANTLR tokens(for e.g. CLASS_DEF).
-
-
Constructor Details
-
JavadocMetadataScraperUtil
private JavadocMetadataScraperUtil()Private utility constructor.
-
-
Method Details
-
constructSubTreeText
Performs a depth-first traversal of the subtree starting atstartNodeand ending atendNode, and constructs the concatenated text of all nodes in that range, ignoringJavadocTokentexts.- Parameters:
startNode- the node where traversal begins (inclusive)endNode- the node where traversal ends (inclusive)- Returns:
- the constructed text from the specified subtree range
-
isInsideCodeInlineTag
Checks whether the given node is inside a@codeJavadoc inline tag.- Parameters:
node- the node to check- Returns:
- true if the node is inside a
@codeinline tag, false otherwise
-
isInsideLiteralInlineTag
Checks whether the given node is inside a@literalJavadoc inline tag.- Parameters:
node- the node to check- Returns:
- true if the node is inside a
@literalinline tag, false otherwise
-
isContentToWrite
Checks whether selected Javadoc node is considered as something to write.- Parameters:
detailNode- javadoc node to check.- Returns:
- whether javadoc node is something to write.
-
adjustCodeInlineTagChildToHtml
Adjusts certain child of@codeJavadoc inline tag to its analogous html format.- Parameters:
codeChild-@codechild to convert.- Returns:
- converted
@codechild element, otherwise just the original text.
-
adjustLiteralInlineTagChildToText
Adjusts a child of@literalJavadoc inline tag to its XML-escaped plain text form.- Parameters:
literalChild- child node of the@literalinline tag.- Returns:
- escaped text for content nodes, or empty string for structural tokens.
-
escapeXmlChars
Escapes special XML characters in the given text.- Parameters:
text- the text to escape.- Returns:
- text with XML special characters escaped.
-
getFirstChildOfType
Returns the first child node of the given parent that matches the providedtokenType. -
isChildNodeTextMatches
Checks whether the first childJavadocTokenType.TEXTnode matches given pattern.- Parameters:
ast- parent javadoc nodepattern- pattern to match- Returns:
- true if one of child text nodes matches pattern
-