author | bobv |
Tue, 07 Nov 2017 10:30:53 -0500 | |
changeset 47801 | c7b50c23ea71 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
36526 | 2 |
* Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 22 |
*/ |
23 |
||
24 |
/* |
|
25 |
* @test |
|
26 |
* @bug 4587562 |
|
27 |
* @summary tool: Indentation messed up for javadoc comments omitting preceding * |
|
28 |
* @author gafter |
|
36526 | 29 |
* @modules jdk.javadoc/jdk.javadoc.internal.tool |
10 | 30 |
* @run main NoStar |
31 |
*/ |
|
32 |
||
33 |
import java.util.*; |
|
34 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
35 |
import javax.lang.model.SourceVersion; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
36 |
import javax.lang.model.element.TypeElement; |
42277 | 37 |
import javax.lang.model.util.ElementFilter; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
38 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
39 |
import com.sun.source.doctree.DocCommentTree; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
40 |
import com.sun.source.util.DocTrees; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
41 |
import jdk.javadoc.doclet.Doclet; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
42 |
import jdk.javadoc.doclet.Reporter; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
43 |
import jdk.javadoc.doclet.DocletEnvironment; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
44 |
|
10 | 45 |
/** First sentence. |
46 |
0 |
|
47 |
1 |
|
48 |
2 |
|
49 |
3 |
|
50 |
4 |
|
51 |
5 |
|
52 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
53 |
public class NoStar implements Doclet |
10 | 54 |
{ |
55 |
public static void main(String[] args) { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
56 |
String[] argarray = { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
57 |
"-docletpath", System.getProperty("test.classes", "."), |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
58 |
"-doclet", "NoStar", |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
59 |
System.getProperty("test.src", ".") + java.io.File.separatorChar + "NoStar.java" |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
60 |
}; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
61 |
if (jdk.javadoc.internal.tool.Main.execute(argarray) != 0) |
10 | 62 |
throw new Error(); |
63 |
} |
|
64 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
65 |
public boolean run(DocletEnvironment root) { |
42277 | 66 |
Set<TypeElement> classes = ElementFilter.typesIn(root.getIncludedElements()); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
67 |
if (classes.size() != 1) |
10 | 68 |
throw new Error("1 " + Arrays.asList(classes)); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
69 |
TypeElement self = classes.iterator().next(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
70 |
DocTrees trees = root.getDocTrees(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
71 |
DocCommentTree docCommentTree = trees.getDocCommentTree(self); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
72 |
String c = docCommentTree.getFullBody().toString(); |
10 | 73 |
System.out.println("\"" + c + "\""); |
74 |
return c.equals("First sentence.\n0\n 1\n 2\n 3\n 4\n 5"); |
|
75 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
76 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
77 |
@Override |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
78 |
public String getName() { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
79 |
return "Test"; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
80 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
81 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
82 |
@Override |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
83 |
public Set<Option> getSupportedOptions() { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
84 |
return Collections.emptySet(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
85 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
86 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
87 |
@Override |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
88 |
public SourceVersion getSupportedSourceVersion() { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
89 |
return SourceVersion.latest(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
90 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
91 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
92 |
@Override |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
93 |
public void init(Locale locale, Reporter reporter) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
94 |
return; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
30730
diff
changeset
|
95 |
} |
10 | 96 |
} |