13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 4587562 27 * @summary tool: Indentation messed up for javadoc comments omitting preceding * 28 * @author gafter 29 * @modules jdk.javadoc 30 * @run main NoStar 31 */ 32 33 import com.sun.javadoc.*; 34 import java.util.*; 35 36 /** First sentence. 37 0 38 1 39 2 40 3 41 4 42 5 43 */ 44 public class NoStar extends Doclet 45 { 46 public static void main(String[] args) { 47 if (com.sun.tools.javadoc.Main. 48 execute("javadoc", "NoStar", NoStar.class.getClassLoader(), 49 new String[] {System.getProperty("test.src", ".") + java.io.File.separatorChar + "NoStar.java"}) != 0) 50 throw new Error(); 51 } 52 53 public static boolean start(com.sun.javadoc.RootDoc root) { 54 ClassDoc[] classes = root.classes(); 55 if (classes.length != 1) 56 throw new Error("1 " + Arrays.asList(classes)); 57 ClassDoc self = classes[0]; 58 String c = self.commentText(); 59 System.out.println("\"" + c + "\""); 60 return c.equals("First sentence.\n0\n 1\n 2\n 3\n 4\n 5"); 61 } 62 } | 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 4587562 27 * @summary tool: Indentation messed up for javadoc comments omitting preceding * 28 * @author gafter 29 * @modules jdk.javadoc 30 * @run main NoStar 31 */ 32 33 import java.util.*; 34 35 import javax.lang.model.SourceVersion; 36 import javax.lang.model.element.TypeElement; 37 38 import com.sun.source.doctree.DocCommentTree; 39 import com.sun.source.util.DocTrees; 40 import jdk.javadoc.doclet.Doclet; 41 import jdk.javadoc.doclet.Reporter; 42 import jdk.javadoc.doclet.DocletEnvironment; 43 44 /** First sentence. 45 0 46 1 47 2 48 3 49 4 50 5 51 */ 52 public class NoStar implements Doclet 53 { 54 public static void main(String[] args) { 55 String[] argarray = { 56 "-docletpath", System.getProperty("test.classes", "."), 57 "-doclet", "NoStar", 58 System.getProperty("test.src", ".") + java.io.File.separatorChar + "NoStar.java" 59 }; 60 if (jdk.javadoc.internal.tool.Main.execute(argarray) != 0) 61 throw new Error(); 62 } 63 64 public boolean run(DocletEnvironment root) { 65 Set<TypeElement> classes = root.getIncludedClasses(); 66 if (classes.size() != 1) 67 throw new Error("1 " + Arrays.asList(classes)); 68 TypeElement self = classes.iterator().next(); 69 DocTrees trees = root.getDocTrees(); 70 DocCommentTree docCommentTree = trees.getDocCommentTree(self); 71 String c = docCommentTree.getFullBody().toString(); 72 System.out.println("\"" + c + "\""); 73 return c.equals("First sentence.\n0\n 1\n 2\n 3\n 4\n 5"); 74 } 75 76 @Override 77 public String getName() { 78 return "Test"; 79 } 80 81 @Override 82 public Set<Option> getSupportedOptions() { 83 return Collections.emptySet(); 84 } 85 86 @Override 87 public SourceVersion getSupportedSourceVersion() { 88 return SourceVersion.latest(); 89 } 90 91 @Override 92 public void init(Locale locale, Reporter reporter) { 93 return; 94 } 95 } |