Class InlineTagUtil
java.lang.Object
com.puppycrawl.tools.checkstyle.checks.javadoc.utils.InlineTagUtil
Tools for extracting inline tags from Javadoc comments.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final charCarriage return character.private static final PatternInline tag pattern.private static final PatternPattern to recognize leading "*" characters in Javadoc.private static final charLine feed character.private static final PatternPattern matching a newline.private static final PatternPattern matching whitespace, used bycollapseWhitespace(String). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringcollapseWhitespace(String str) Collapse whitespaces.private static StringconvertLinesToString(String... lines) Convert array of string to single String.extractInlineTags(String... lines) Extract inline Javadoc tags from the given comment.private static LineColumngetLineColumnOfIndex(String source, int index) Get LineColumn from string till index.private static StringremoveLeadingJavaDoc(String source) Remove leading JavaDoc.
-
Field Details
-
INLINE_TAG_PATTERN
Inline tag pattern. -
JAVADOC_PREFIX_PATTERN
Pattern to recognize leading "*" characters in Javadoc. -
WHITESPACE_PATTERN
Pattern matching whitespace, used bycollapseWhitespace(String). -
NEWLINE_PATTERN
Pattern matching a newline. -
LINE_FEED
Line feed character.- See Also:
-
CARRIAGE_RETURN
Carriage return character.- See Also:
-
-
Constructor Details
-
InlineTagUtil
private InlineTagUtil()Prevent instantiation.
-
-
Method Details
-
extractInlineTags
Extract inline Javadoc tags from the given comment.- Parameters:
lines- The Javadoc comment (as lines).- Returns:
- The extracted inline Javadoc tags.
- Throws:
IllegalArgumentException- when comment lines contain newlines
-
convertLinesToString
Convert array of string to single String.- Parameters:
lines- A number of lines, in order.- Returns:
- The lines, joined together with newlines, as a single string.
-
getLineColumnOfIndex
Get LineColumn from string till index.- Parameters:
source- Source string.index- An index into the string.- Returns:
- A position in the source representing what line and column that index appears on.
-
collapseWhitespace
Collapse whitespaces.- Parameters:
str- Source string.- Returns:
- The given string with all whitespace collapsed.
-
removeLeadingJavaDoc
Remove leading JavaDoc.- Parameters:
source- A string to remove leading Javadoc from.- Returns:
- The given string with leading Javadoc "*" characters from each line removed.
-