|
1 /* |
|
2 * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
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/jdk.javadoc.internal.tool |
|
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 import javax.lang.model.util.ElementFilter; |
|
38 |
|
39 import com.sun.source.doctree.DocCommentTree; |
|
40 import com.sun.source.util.DocTrees; |
|
41 import jdk.javadoc.doclet.Doclet; |
|
42 import jdk.javadoc.doclet.Reporter; |
|
43 import jdk.javadoc.doclet.DocletEnvironment; |
|
44 |
|
45 /** First sentence. |
|
46 0 |
|
47 1 |
|
48 2 |
|
49 3 |
|
50 4 |
|
51 5 |
|
52 */ |
|
53 public class NoStar implements Doclet |
|
54 { |
|
55 public static void main(String[] args) { |
|
56 String[] argarray = { |
|
57 "-docletpath", System.getProperty("test.classes", "."), |
|
58 "-doclet", "NoStar", |
|
59 System.getProperty("test.src", ".") + java.io.File.separatorChar + "NoStar.java" |
|
60 }; |
|
61 if (jdk.javadoc.internal.tool.Main.execute(argarray) != 0) |
|
62 throw new Error(); |
|
63 } |
|
64 |
|
65 public boolean run(DocletEnvironment root) { |
|
66 Set<TypeElement> classes = ElementFilter.typesIn(root.getIncludedElements()); |
|
67 if (classes.size() != 1) |
|
68 throw new Error("1 " + Arrays.asList(classes)); |
|
69 TypeElement self = classes.iterator().next(); |
|
70 DocTrees trees = root.getDocTrees(); |
|
71 DocCommentTree docCommentTree = trees.getDocCommentTree(self); |
|
72 String c = docCommentTree.getFullBody().toString(); |
|
73 System.out.println("\"" + c + "\""); |
|
74 return c.equals("First sentence.\n0\n 1\n 2\n 3\n 4\n 5"); |
|
75 } |
|
76 |
|
77 @Override |
|
78 public String getName() { |
|
79 return "Test"; |
|
80 } |
|
81 |
|
82 @Override |
|
83 public Set<Option> getSupportedOptions() { |
|
84 return Collections.emptySet(); |
|
85 } |
|
86 |
|
87 @Override |
|
88 public SourceVersion getSupportedSourceVersion() { |
|
89 return SourceVersion.latest(); |
|
90 } |
|
91 |
|
92 @Override |
|
93 public void init(Locale locale, Reporter reporter) { |
|
94 return; |
|
95 } |
|
96 } |