Class 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 Detail

      • 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
      • getFilteredLines

        public Iterable<Chars> getFilteredLines​(boolean preserveEmptyLines)
      • 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 * /.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object