Class JavaComment
- java.lang.Object
-
- net.sourceforge.pmd.lang.java.ast.JavaComment
-
- All Implemented Interfaces:
Reportable
- Direct Known Subclasses:
JavadocComment
public class JavaComment extends Object implements Reportable
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
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
equals(Object o)
Iterable<Chars>
getFilteredLines()
Removes the leading comment marker (like*
) of each line of the comment as well as the start marker (//
,/*
or/**
and the end markers (*/
).Iterable<Chars>
getFilteredLines(boolean preserveEmptyLines)
String
getImage()
Deprecated.UsegetText()
static Stream<JavaComment>
getLeadingComments(JavaNode node)
FileLocation
getReportLocation()
Chars
getText()
Returns the full text of the comment.JavaccToken
getToken()
The token underlying this comment.int
hashCode()
boolean
hasJavadocContent()
static boolean
isComment(JavaccToken token)
Returns true if the given token has the kind of a comment token (there are three such kinds).static boolean
isMarkupWord(Chars word)
True if this is a comment delimiter or an asterisk.boolean
isSingleLine()
static Chars
removeCommentMarkup(Chars line)
Trim the start of the provided line to remove a comment markup opener (//, /*, /**, *
) or closer* /
.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sourceforge.pmd.reporting.Reportable
getBeginColumn, getBeginLine, getEndColumn, getEndLine
-
-
-
-
Method Detail
-
getReportLocation
public FileLocation getReportLocation()
- Specified by:
getReportLocation
in interfaceReportable
-
getImage
@Deprecated public String getImage()
Deprecated.UsegetText()
-
getToken
public final JavaccToken getToken()
The token underlying this comment.
-
isSingleLine
public boolean isSingleLine()
-
hasJavadocContent
public boolean hasJavadocContent()
-
getText
public Chars getText()
Returns the full text of the comment.
-
isComment
public static boolean isComment(JavaccToken token)
Returns true if the given token has the kind of a comment token (there are three such kinds).
-
getFilteredLines
public Iterable<Chars> 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
-
isMarkupWord
public static boolean isMarkupWord(Chars word)
True if this is a comment delimiter or an asterisk. This tests the whole parameter and not a prefix/suffix.
-
removeCommentMarkup
public static Chars removeCommentMarkup(Chars line)
Trim the start of the provided line to remove a comment markup opener (//, /*, /**, *
) or closer* /
.
-
getLeadingComments
public static Stream<JavaComment> getLeadingComments(JavaNode node)
-
-