Class JavaComment
java.lang.Object
net.sourceforge.pmd.lang.java.ast.JavaComment
- All Implemented Interfaces:
Reportable
- Direct Known Subclasses:
JavadocComment
Wraps a comment token to provide some utilities.
This is not a node, it's not part of the tree anywhere,
just convenient.
This class represents any kind of comment. A specialized subclass
provides more API for Javadoc comments, see JavadocComment.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanRemoves the leading comment marker (like*) of each line of the comment as well as the start marker (//,/*,/**or///and the end markers (*/).getFilteredLines(boolean preserveEmptyLines) static Stream<JavaComment>getLeadingComments(JavaNode node) getText()Returns the full text of the comment.final JavaccTokengetToken()The token underlying this comment.inthashCode()booleanstatic booleanisComment(JavaccToken token) Returns true if the given token has the kind of a comment token (there are three such kinds).static booleanisMarkupWord(Chars word) True if this is a comment delimiter or an asterisk.booleanstatic CharsremoveCommentMarkup(Chars line) Trim the start of the provided line to remove a comment markup opener (//, ///, /*, /**, *) or closer*/.
-
Method Details
-
getReportLocation
- Specified by:
getReportLocationin interfaceReportable
-
getToken
The token underlying this comment. -
isSingleLine
public boolean isSingleLine() -
hasJavadocContent
public boolean hasJavadocContent() -
getText
Returns the full text of the comment. -
isComment
Returns true if the given token has the kind of a comment token (there are three such kinds). -
getFilteredLines
Removes the leading comment marker (like*) of each line of the comment as well as the start marker (//,/*,/**or///and the end markers (*/).Empty lines are removed.
- Returns:
- List of lines of the comments
-
getFilteredLines
-
isMarkupWord
True if this is a comment delimiter or an asterisk. This tests the whole parameter and not a prefix/suffix. -
removeCommentMarkup
Trim the start of the provided line to remove a comment markup opener (//, ///, /*, /**, *) or closer*/. -
getLeadingComments
-
equals
-
hashCode
public int hashCode()
-