Class JavadocMetadataScraperUtil

java.lang.Object
com.puppycrawl.tools.checkstyle.meta.JavadocMetadataScraperUtil

public final class JavadocMetadataScraperUtil extends Object
Class for scraping module metadata from the corresponding class' class-level javadoc.
  • Field Details

    • TOKEN_TEXT_PATTERN

      private static final Pattern TOKEN_TEXT_PATTERN
      Regular expression for detecting ANTLR tokens(for e.g. CLASS_DEF).
  • Constructor Details

  • Method Details

    • constructSubTreeText

      public static String constructSubTreeText(DetailNode startNode, DetailNode endNode)
      Performs a depth-first traversal of the subtree starting at startNode and ending at endNode, and constructs the concatenated text of all nodes in that range, ignoring JavadocToken texts.
      Parameters:
      startNode - the node where traversal begins (inclusive)
      endNode - the node where traversal ends (inclusive)
      Returns:
      the constructed text from the specified subtree range
    • isInsideCodeInlineTag

      private static boolean isInsideCodeInlineTag(DetailNode node)
      Checks whether the given node is inside a @code Javadoc inline tag.
      Parameters:
      node - the node to check
      Returns:
      true if the node is inside a @code inline tag, false otherwise
    • isContentToWrite

      private static boolean isContentToWrite(DetailNode detailNode)
      Checks whether selected Javadoc node is considered as something to write.
      Parameters:
      detailNode - javadoc node to check.
      Returns:
      whether javadoc node is something to write.
    • adjustCodeInlineTagChildToHtml

      Adjusts certain child of @code Javadoc inline tag to its analogous html format.
      Parameters:
      codeChild - @code child to convert.
      Returns:
      converted @code child element, otherwise just the original text.
    • getFirstChildOfType

      private static Optional<DetailNode> getFirstChildOfType(DetailNode node, int tokenType)
      Returns the first child node of the given parent that matches the provided tokenType.
      Parameters:
      node - the parent node
      tokenType - the token type to match
      Returns:
      an Optional containing the first matching child node, or an empty Optional if none is found
    • isChildNodeTextMatches

      public static boolean isChildNodeTextMatches(DetailNode ast, Pattern pattern)
      Checks whether the first child JavadocTokenType.TEXT node matches given pattern.
      Parameters:
      ast - parent javadoc node
      pattern - pattern to match
      Returns:
      true if one of child text nodes matches pattern