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 Pattern
Regular expression for detecting ANTLR tokens(for e.g. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
adjustCodeInlineTagChildToHtml
(DetailNode codeChild) Adjusts certain child of@code
Javadoc inline tag to its analogous html format.static String
constructSubTreeText
(DetailNode node, int childLeftLimit, int childRightLimit) Performs a DFS of the subtree with a node as the root and constructs the text of that tree, ignoring JavadocToken texts.private static Optional<DetailNode>
getFirstChildOfType
(DetailNode node, int tokenType, int offset) Returns the first child node which matches the providedTokenType
and has the children index after the offset value.static boolean
isChildNodeTextMatches
(DetailNode ast, Pattern pattern) Checks whether the first childJavadocTokenType.TEXT
node matches given pattern.private static boolean
isContentToWrite
(DetailNode detailNode) Checks whether selected Javadoc node is considered as something to write.
-
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 DFS of the subtree with a node as the root and constructs the text of that tree, ignoring JavadocToken texts.- Parameters:
node
- root node of subtreechildLeftLimit
- the left index of root children from where to scanchildRightLimit
- the right index of root children till where to scan- Returns:
- constructed text of subtree
-
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@code
Javadoc inline tag to its analogous html format.- Parameters:
codeChild
-@code
child to convert.- Returns:
- converted
@code
child element, otherwise just the original text.
-
getFirstChildOfType
Returns the first child node which matches the providedTokenType
and has the children index after the offset value.- Parameters:
node
- parent nodetokenType
- token type to matchoffset
- children array index offset- Returns:
- the first child satisfying the conditions
-
isChildNodeTextMatches
Checks whether the first childJavadocTokenType.TEXT
node matches given pattern.- Parameters:
ast
- parent javadoc nodepattern
- pattern to match- Returns:
- true if one of child text nodes matches pattern
-