Class JavadocDetailNodeParser


  • public class JavadocDetailNodeParser
    extends java.lang.Object
    Used for parsing Javadoc comment as DetailNode tree.
    • Field Detail

      • MSG_JAVADOC_MISSED_HTML_CLOSE

        public static final java.lang.String MSG_JAVADOC_MISSED_HTML_CLOSE
        Message key of error message. Missed close HTML tag breaks structure of parse tree, so parser stops parsing and generates such error message. This case is special because parser prints error like "no viable alternative at input 'b \n *\n'" and it is not clear that error is about missed close HTML tag.
        See Also:
        Constant Field Values
      • MSG_JAVADOC_WRONG_SINGLETON_TAG

        public static final java.lang.String MSG_JAVADOC_WRONG_SINGLETON_TAG
        Message key of error message.
        See Also:
        Constant Field Values
      • MSG_JAVADOC_PARSE_RULE_ERROR

        public static final java.lang.String MSG_JAVADOC_PARSE_RULE_ERROR
        Parse error while rule recognition.
        See Also:
        Constant Field Values
      • MSG_KEY_PARSE_ERROR

        public static final java.lang.String MSG_KEY_PARSE_ERROR
        Error message key for common javadoc errors.
        See Also:
        Constant Field Values
      • MSG_KEY_UNRECOGNIZED_ANTLR_ERROR

        public static final java.lang.String MSG_KEY_UNRECOGNIZED_ANTLR_ERROR
        Unrecognized error from antlr parser.
        See Also:
        Constant Field Values
      • JAVADOC_START

        private static final java.lang.String JAVADOC_START
        Symbols with which javadoc starts.
        See Also:
        Constant Field Values
      • blockCommentLineNumber

        private int blockCommentLineNumber
        Line number of the Block comment AST that is being parsed.
    • Constructor Detail

      • JavadocDetailNodeParser

        public JavadocDetailNodeParser()
    • Method Detail

      • parseJavadocAsDetailNode

        public JavadocDetailNodeParser.ParseStatus parseJavadocAsDetailNode​(DetailAST javadocCommentAst)
        Parses Javadoc comment as DetailNode tree.
        Parameters:
        javadocCommentAst - DetailAST of Javadoc comment
        Returns:
        DetailNode tree of Javadoc comment
      • parseJavadocAsParseTree

        private org.antlr.v4.runtime.tree.ParseTree parseJavadocAsParseTree​(java.lang.String blockComment)
        Parses block comment content as javadoc comment.
        Parameters:
        blockComment - block comment content.
        Returns:
        parse tree
      • convertParseTreeToDetailNode

        private DetailNode convertParseTreeToDetailNode​(org.antlr.v4.runtime.tree.ParseTree parseTreeNode)
        Converts ParseTree (that is generated by ANTLRv4) to DetailNode tree.
        Parameters:
        parseTreeNode - root node of ParseTree
        Returns:
        root of DetailNode tree
      • insertChildrenNodes

        private void insertChildrenNodes​(JavadocNodeImpl[] nodes,
                                         org.antlr.v4.runtime.tree.ParseTree parseTreeParent)
        Creates child nodes for each node from 'nodes' array.
        Parameters:
        parseTreeParent - original ParseTree parent node
        nodes - array of JavadocNodeImpl nodes
      • createChildrenNodes

        private JavadocNodeImpl[] createChildrenNodes​(JavadocNodeImpl parentJavadocNode,
                                                      org.antlr.v4.runtime.tree.ParseTree parseTreeNode)
        Creates children Javadoc nodes base on ParseTree node's children.
        Parameters:
        parentJavadocNode - node that will be parent for created children
        parseTreeNode - original ParseTree node
        Returns:
        array of Javadoc nodes
      • createRootJavadocNode

        private JavadocNodeImpl createRootJavadocNode​(org.antlr.v4.runtime.tree.ParseTree parseTreeNode)
        Creates root JavadocNodeImpl node base on ParseTree root node.
        Parameters:
        parseTreeNode - ParseTree root node
        Returns:
        root Javadoc node
      • createJavadocNode

        private JavadocNodeImpl createJavadocNode​(org.antlr.v4.runtime.tree.ParseTree parseTree,
                                                  DetailNode parent,
                                                  int index)
        Creates JavadocNodeImpl node on base of ParseTree node.
        Parameters:
        parseTree - ParseTree node
        parent - DetailNode that will be parent of new node
        index - child index that has new node
        Returns:
        JavadocNodeImpl node on base of ParseTree node.
      • adjustFirstLineToJavadocIndent

        private void adjustFirstLineToJavadocIndent​(DetailNode tree,
                                                    int javadocColumnNumber)
        Adjust first line nodes to javadoc indent.
        Parameters:
        tree - DetailNode tree root
        javadocColumnNumber - javadoc indent
      • getLine

        private static int getLine​(org.antlr.v4.runtime.tree.ParseTree tree)
        Gets line number from ParseTree node.
        Parameters:
        tree - ParseTree node
        Returns:
        line number
      • getColumn

        private static int getColumn​(org.antlr.v4.runtime.tree.ParseTree tree)
        Gets column number from ParseTree node.
        Parameters:
        tree - ParseTree node
        Returns:
        column number
      • getNextSibling

        private static org.antlr.v4.runtime.tree.ParseTree getNextSibling​(org.antlr.v4.runtime.tree.ParseTree node)
        Gets next sibling of ParseTree node.
        Parameters:
        node - ParseTree node
        Returns:
        next sibling of ParseTree node.
      • getTokenType

        private static int getTokenType​(org.antlr.v4.runtime.tree.ParseTree node)
        Gets token type of ParseTree node from JavadocTokenTypes class.
        Parameters:
        node - ParseTree node.
        Returns:
        token type from JavadocTokenTypes
      • getFormattedNodeClassNameWithoutContext

        private static java.lang.String getFormattedNodeClassNameWithoutContext​(org.antlr.v4.runtime.tree.ParseTree node)
        Gets class name of ParseTree node and removes 'Context' postfix at the end and formats it.
        Parameters:
        node - ParseTree node whose class name is to be formatted and returned
        Returns:
        uppercased class name without the word 'Context' and with appropriately inserted underscores
      • getNodeClassNameWithoutContext

        private static java.lang.String getNodeClassNameWithoutContext​(org.antlr.v4.runtime.tree.ParseTree node)
        Gets class name of ParseTree node and removes 'Context' postfix at the end.
        Parameters:
        node - ParseTree node.
        Returns:
        class name without 'Context'