Class CommentUtil


  • @Deprecated
    public final class CommentUtil
    extends Object
    Deprecated.
    This utility class is deprecated and will be removed with PMD 7.0.0. Its methods have been intended to parse javadoc tags. A more useful solution will be added around the AST node FormalComment, which contains as children JavadocElement nodes, which in turn provide access to the JavadocTag.
    • Method Detail

      • wordAfter

        @Deprecated
        public static String wordAfter​(String text,
                                       int position)
        Deprecated.
        This method is deprecated and will be removed with PMD 7.0.0. This method has been intended to parse javadoc tags. A more useful solution will be added around the AST node FormalComment, which contains as children JavadocElement nodes, which in turn provide access to the JavadocTag.
        Gets the next word (characters until next whitespace, punctuation, or anything that is not a letter or digit) at the given position.
        Parameters:
        text - the complete text
        position - the position, at which the word starts
        Returns:
        the word
      • javadocContentAfter

        @Deprecated
        public static String javadocContentAfter​(String text,
                                                 int position)
        Deprecated.
        This method is deprecated and will be removed with PMD 7.0.0. This method has been intended to parse javadoc tags. A more useful solution will be added around the AST node FormalComment, which contains as children JavadocElement nodes, which in turn provide access to the JavadocTag.
        Gets the remaining line after a specific position.
        Parameters:
        text - the complete text
        position - the position from which the comment should be returned
        Returns:
        the part of the text
      • javadocTagsIn

        @Deprecated
        public static Map<String,​Integer> javadocTagsIn​(String comment)
        Deprecated.
        This method is deprecated and will be removed with PMD 7.0.0. This method has been intended to parse javadoc tags. A more useful solution will be added around the AST node FormalComment, which contains as children JavadocElement nodes, which in turn provide access to the JavadocTag.
        Finds all the javadoc tags in the (formal) comment. Returns a map from javadoc tag to index position.

        Note: If a tag is used multiple times, the last occurrence is returned.

        Parameters:
        comment - the raw comment
        Returns:
        mapping of javadoc tag to index position
      • multiLinesIn

        @Deprecated
        public static List<String> multiLinesIn​(String comment)
        Deprecated.
        This method will be removed with PMD 7.0.0. It has been replaced by Comment.getFilteredComment().
        Removes the leading comment marker (like *) of each line of the comment as well as the start marker (//, /* or /** and the end markers (*/).
        Parameters:
        comment - the raw comment
        Returns:
        List of lines of the comments
      • trim

        @Deprecated
        public static List<String> trim​(List<String> lines)
        Deprecated.
        This method will be removed with PMD 7.0.0. It is not needed anymore, since Comment.getFilteredComment() returns already the filtered and trimmed comment text.
        Similar to the String.trim() function, this one removes the leading and trailing empty/blank lines from the line list.
        Parameters:
        lines - the list of lines, which might contain empty lines
        Returns:
        the lines without leading or trailing blank lines.