Class JavaComment
- java.lang.Object
-
- net.sourceforge.pmd.lang.java.ast.JavaComment
-
- All Implemented Interfaces:
net.sourceforge.pmd.reporting.Reportable
- Direct Known Subclasses:
JavadocComment
public class JavaComment extends Object implements net.sourceforge.pmd.reporting.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 Modifier and Type Method Description boolean
equals(Object o)
Iterable<net.sourceforge.pmd.lang.document.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<net.sourceforge.pmd.lang.document.Chars>
getFilteredLines(boolean preserveEmptyLines)
static Stream<JavaComment>
getLeadingComments(JavaNode node)
net.sourceforge.pmd.lang.document.FileLocation
getReportLocation()
net.sourceforge.pmd.lang.document.Chars
getText()
Returns the full text of the comment.net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken
getToken()
The token underlying this comment.int
hashCode()
boolean
hasJavadocContent()
static boolean
isComment(net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken token)
Returns true if the given token has the kind of a comment token (there are three such kinds).static boolean
isMarkupWord(net.sourceforge.pmd.lang.document.Chars word)
True if this is a comment delimiter or an asterisk.boolean
isSingleLine()
static net.sourceforge.pmd.lang.document.Chars
removeCommentMarkup(net.sourceforge.pmd.lang.document.Chars line)
Trim the start of the provided line to remove a comment markup opener (//, ///, /*, /**, *
) or closer*/
.
-
-
-
Method Detail
-
getReportLocation
public net.sourceforge.pmd.lang.document.FileLocation getReportLocation()
- Specified by:
getReportLocation
in interfacenet.sourceforge.pmd.reporting.Reportable
-
getToken
public final net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken getToken()
The token underlying this comment.
-
isSingleLine
public boolean isSingleLine()
-
hasJavadocContent
public boolean hasJavadocContent()
-
getText
public net.sourceforge.pmd.lang.document.Chars getText()
Returns the full text of the comment.
-
isComment
public static boolean isComment(net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken token)
Returns true if the given token has the kind of a comment token (there are three such kinds).
-
getFilteredLines
public Iterable<net.sourceforge.pmd.lang.document.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
-
getFilteredLines
public Iterable<net.sourceforge.pmd.lang.document.Chars> getFilteredLines(boolean preserveEmptyLines)
-
isMarkupWord
public static boolean isMarkupWord(net.sourceforge.pmd.lang.document.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 net.sourceforge.pmd.lang.document.Chars removeCommentMarkup(net.sourceforge.pmd.lang.document.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)
-
-