static Javadoc convertJavadoc ( TreePath path , String source , JavacEnvironment env , boolean reportWarnings ) { DocTrees docTrees = DocTrees . instance ( env . task ( ) ) ; DocCommentTree docComment = docTrees . getDocCommentTree ( path ) ; if ( docComment == null ) { return null ; // Declaration does not have a javadoc comment. } JavadocConverter converter = new JavadocConverter ( env . treeUtilities ( ) . getElement ( path ) , docComment , source , docTrees , path . getCompilationUnit ( ) , reportWarnings ) ; Javadoc result = new Javadoc ( ) ; // First tag is the description. TagElement newTag = new TagElement ( ) . setTagKind ( TagElement . TagKind . DESCRIPTION ) ; converter . scan ( docComment . getFirstSentence ( ) , newTag ) ; converter . scan ( docComment . getBody ( ) , newTag ) ; if ( ! newTag . getFragments ( ) . isEmpty ( ) ) { List < TreeNode > fragments = newTag . getFragments ( ) ; int start = fragments . get ( 0 ) . getStartPosition ( ) ; TreeNode lastFragment = fragments . get ( fragments . size ( ) - 1 ) ; int end = start + lastFragment . getLength ( ) ; converter . setPos ( newTag , start , end ) ; result . addTag ( newTag ) ; } for ( DocTree tag : docComment . getBlockTags ( ) ) { if ( tag . getKind ( ) != DocTree . Kind . ERRONEOUS ) { newTag = new TagElement ( ) ; converter . scan ( tag , newTag ) ; result . addTag ( newTag ) ; } } return result ; }
Returns an AST node for the javadoc comment of a specified class method or field element .