author | ksrini |
Mon, 13 Mar 2017 17:02:18 -0700 | |
changeset 44288 | c33a416cfcf8 |
parent 44181 | 2075fecdcce1 |
child 44301 | 2f97c71f06f4 |
permissions | -rw-r--r-- |
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
1 |
/* |
44181
2075fecdcce1
8175860: javadoc crashes with incorrect module sourcepath
ksrini
parents:
42277
diff
changeset
|
2 |
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. |
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
4 |
* |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
8 |
* |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
13 |
* accompanied this code). |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
14 |
* |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
18 |
* |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
21 |
* questions. |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
22 |
*/ |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
23 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
24 |
import java.io.IOException; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
25 |
import java.io.PrintWriter; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
26 |
import java.io.StringWriter; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
27 |
import java.nio.file.Path; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
28 |
import java.nio.file.Paths; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
29 |
import java.util.Arrays; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
30 |
import java.util.Collections; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
31 |
import java.util.List; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
32 |
import java.util.Locale; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
33 |
import java.util.Set; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
34 |
import java.util.TreeSet; |
42277 | 35 |
import java.util.stream.Collectors; |
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
36 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
37 |
import javax.lang.model.SourceVersion; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
38 |
import javax.lang.model.element.Element; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
39 |
import javax.lang.model.element.ElementKind; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
40 |
import javax.lang.model.element.ModuleElement; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
41 |
import javax.lang.model.element.PackageElement; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
42 |
import javax.lang.model.element.TypeElement; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
43 |
import javax.lang.model.util.ElementFilter; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
44 |
import javax.lang.model.util.SimpleElementVisitor9; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
45 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
46 |
import jdk.javadoc.doclet.Doclet; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
47 |
import jdk.javadoc.doclet.DocletEnvironment; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
48 |
import jdk.javadoc.doclet.Reporter; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
49 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
50 |
import toolbox.JavadocTask; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
51 |
import toolbox.Task; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
52 |
import toolbox.Task.Expect; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
53 |
import toolbox.TestRunner; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
54 |
import toolbox.ToolBox; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
55 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
56 |
import static toolbox.Task.OutputKind.*; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
57 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
58 |
/** |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
59 |
* Base class for module tests. |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
60 |
*/ |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
61 |
public class ModuleTestBase extends TestRunner { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
62 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
63 |
// Field Separator |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
64 |
private static final String FS = " "; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
65 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
66 |
protected ToolBox tb; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
67 |
private final Class<?> docletClass; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
68 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
69 |
private Task.Result currentTask = null; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
70 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
71 |
ModuleTestBase() { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
72 |
super(System.err); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
73 |
tb = new ToolBox(); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
74 |
ClassLoader cl = ModuleTestBase.class.getClassLoader(); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
75 |
try { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
76 |
docletClass = cl.loadClass("ModuleTestBase$ModulesTesterDoclet"); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
77 |
} catch (ClassNotFoundException cfe) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
78 |
throw new Error(cfe); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
79 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
80 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
81 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
82 |
/** |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
83 |
* Execute methods annotated with @Test, and throw an exception if any |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
84 |
* errors are reported.. |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
85 |
* |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
86 |
* @throws Exception if any errors occurred |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
87 |
*/ |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
88 |
protected void runTests() throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
89 |
runTests(m -> new Object[] { Paths.get(m.getName()) }); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
90 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
91 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
92 |
Task.Result execTask(String... args) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
93 |
return execTask0(false, args); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
94 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
95 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
96 |
Task.Result execNegativeTask(String... args) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
97 |
return execTask0(true, args); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
98 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
99 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
100 |
private Task.Result execTask0(boolean isNegative, String... args) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
101 |
JavadocTask et = new JavadocTask(tb, Task.Mode.API); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
102 |
et.docletClass(docletClass); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
103 |
//Arrays.asList(args).forEach((a -> System.err.println("arg: " + a))); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
104 |
System.err.println(Arrays.asList(args)); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
105 |
currentTask = isNegative |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
106 |
? et.options(args).run(Expect.FAIL) |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
107 |
: et.options(args).run(); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
108 |
return currentTask; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
109 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
110 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
111 |
Path[] findHtmlFiles(Path... paths) throws IOException { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
112 |
return tb.findFiles(".html", paths); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
113 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
114 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
115 |
boolean grep(String regex, Path file) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
116 |
List<String> lines = tb.readAllLines(file); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
117 |
List<String> foundList = tb.grep(regex, lines); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
118 |
return !foundList.isEmpty(); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
119 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
120 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
121 |
String normalize(String in) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
122 |
return in.replace('\\', '/'); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
123 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
124 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
125 |
void checkModulesSpecified(String... args) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
126 |
for (String arg : args) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
127 |
checkDocletOutputPresent("Specified", ElementKind.MODULE, arg); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
128 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
129 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
130 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
131 |
void checkPackagesSpecified(String... args) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
132 |
for (String arg : args) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
133 |
checkDocletOutputPresent("Specified", ElementKind.PACKAGE, arg); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
134 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
135 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
136 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
137 |
void checkTypesSpecified(String... args) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
138 |
for (String arg : args) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
139 |
checkDocletOutputPresent("Specified", ElementKind.CLASS, arg); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
140 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
141 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
142 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
143 |
void checkModulesIncluded(String... args) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
144 |
for (String arg : args) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
145 |
checkDocletOutputPresent("Included", ElementKind.MODULE, arg); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
146 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
147 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
148 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
149 |
void checkPackagesIncluded(String... args) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
150 |
for (String arg : args) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
151 |
checkDocletOutputPresent("Included", ElementKind.PACKAGE, arg); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
152 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
153 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
154 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
155 |
void checkTypesIncluded(String... args) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
156 |
for (String arg : args) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
157 |
checkDocletOutputPresent("Included", ElementKind.CLASS, arg); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
158 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
159 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
160 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
161 |
void checkMembersSelected(String... args) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
162 |
for (String arg : args) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
163 |
checkDocletOutputPresent("Selected", ElementKind.METHOD, arg); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
164 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
165 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
166 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
167 |
void checkModuleMode(String mode) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
168 |
assertPresent("^ModuleMode" + FS + mode); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
169 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
170 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
171 |
void checkStringPresent(String regex) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
172 |
assertPresent(regex); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
173 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
174 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
175 |
void checkDocletOutputPresent(String category, ElementKind kind, String regex) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
176 |
assertPresent("^" + category + " " + kind.toString() + " " + regex); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
177 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
178 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
179 |
void assertPresent(String regex) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
180 |
assertPresent(regex, STDOUT); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
181 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
182 |
|
44288
c33a416cfcf8
8176539: javadoc ignores module-info files on the command line
ksrini
parents:
44181
diff
changeset
|
183 |
void assertMessagePresent(String regex) throws Exception { |
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
184 |
assertPresent(regex, Task.OutputKind.DIRECT); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
185 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
186 |
|
44288
c33a416cfcf8
8176539: javadoc ignores module-info files on the command line
ksrini
parents:
44181
diff
changeset
|
187 |
void assertMessageNotPresent(String regex) throws Exception { |
44181
2075fecdcce1
8175860: javadoc crashes with incorrect module sourcepath
ksrini
parents:
42277
diff
changeset
|
188 |
assertNotPresent(regex, Task.OutputKind.DIRECT); |
2075fecdcce1
8175860: javadoc crashes with incorrect module sourcepath
ksrini
parents:
42277
diff
changeset
|
189 |
} |
2075fecdcce1
8175860: javadoc crashes with incorrect module sourcepath
ksrini
parents:
42277
diff
changeset
|
190 |
|
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
191 |
void assertPresent(String regex, Task.OutputKind kind) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
192 |
List<String> foundList = tb.grep(regex, currentTask.getOutputLines(kind)); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
193 |
if (foundList.isEmpty()) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
194 |
dumpDocletDiagnostics(); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
195 |
throw new Exception(regex + " not found in: " + kind); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
196 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
197 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
198 |
|
44181
2075fecdcce1
8175860: javadoc crashes with incorrect module sourcepath
ksrini
parents:
42277
diff
changeset
|
199 |
void assertNotPresent(String regex, Task.OutputKind kind) throws Exception { |
2075fecdcce1
8175860: javadoc crashes with incorrect module sourcepath
ksrini
parents:
42277
diff
changeset
|
200 |
List<String> foundList = tb.grep(regex, currentTask.getOutputLines(kind)); |
2075fecdcce1
8175860: javadoc crashes with incorrect module sourcepath
ksrini
parents:
42277
diff
changeset
|
201 |
if (!foundList.isEmpty()) { |
2075fecdcce1
8175860: javadoc crashes with incorrect module sourcepath
ksrini
parents:
42277
diff
changeset
|
202 |
dumpDocletDiagnostics(); |
2075fecdcce1
8175860: javadoc crashes with incorrect module sourcepath
ksrini
parents:
42277
diff
changeset
|
203 |
throw new Exception(regex + " found in: " + kind); |
2075fecdcce1
8175860: javadoc crashes with incorrect module sourcepath
ksrini
parents:
42277
diff
changeset
|
204 |
} |
2075fecdcce1
8175860: javadoc crashes with incorrect module sourcepath
ksrini
parents:
42277
diff
changeset
|
205 |
} |
2075fecdcce1
8175860: javadoc crashes with incorrect module sourcepath
ksrini
parents:
42277
diff
changeset
|
206 |
|
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
207 |
void dumpDocletDiagnostics() { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
208 |
for (Task.OutputKind kind : Task.OutputKind.values()) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
209 |
String output = currentTask.getOutput(kind); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
210 |
if (output != null && !output.isEmpty()) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
211 |
System.err.println("<" + kind + ">"); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
212 |
System.err.println(output); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
213 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
214 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
215 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
216 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
217 |
void checkModulesNotSpecified(String... args) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
218 |
for (String arg : args) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
219 |
checkDocletOutputAbsent("Specified", ElementKind.MODULE, arg); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
220 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
221 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
222 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
223 |
void checkPackagesNotSpecified(String... args) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
224 |
for (String arg : args) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
225 |
checkDocletOutputAbsent("Specified", ElementKind.PACKAGE, arg); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
226 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
227 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
228 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
229 |
void checkTypesNotSpecified(String... args) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
230 |
for (String arg : args) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
231 |
checkDocletOutputAbsent("Specified", ElementKind.CLASS, arg); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
232 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
233 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
234 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
235 |
void checkModulesNotIncluded(String... args) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
236 |
for (String arg : args) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
237 |
checkDocletOutputAbsent("Included", ElementKind.MODULE, arg); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
238 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
239 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
240 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
241 |
void checkPackagesNotIncluded(String... args) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
242 |
for (String arg : args) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
243 |
checkDocletOutputAbsent("Included", ElementKind.PACKAGE, arg); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
244 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
245 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
246 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
247 |
void checkTypesNotIncluded(String... args) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
248 |
for (String arg : args) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
249 |
checkDocletOutputAbsent("Included", ElementKind.CLASS, arg); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
250 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
251 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
252 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
253 |
void checkMembersNotSelected(String... args) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
254 |
for (String arg : args) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
255 |
checkDocletOutputAbsent("Selected", ElementKind.METHOD, arg); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
256 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
257 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
258 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
259 |
void checkStringAbsent(String regex) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
260 |
assertAbsent(regex); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
261 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
262 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
263 |
void checkDocletOutputAbsent(String category, ElementKind kind, String regex) throws Exception { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
264 |
assertAbsent("^" + category + FS + kind.toString() + FS + regex); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
265 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
266 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
267 |
void assertAbsent(String regex) throws Exception { |
41161
c73ab5e71cc2
8166127: Develop new tests to cover javadoc module options which are passed to underlying javac
ksrini
parents:
40508
diff
changeset
|
268 |
assertAbsent(regex, STDOUT); |
c73ab5e71cc2
8166127: Develop new tests to cover javadoc module options which are passed to underlying javac
ksrini
parents:
40508
diff
changeset
|
269 |
} |
c73ab5e71cc2
8166127: Develop new tests to cover javadoc module options which are passed to underlying javac
ksrini
parents:
40508
diff
changeset
|
270 |
|
c73ab5e71cc2
8166127: Develop new tests to cover javadoc module options which are passed to underlying javac
ksrini
parents:
40508
diff
changeset
|
271 |
void assertAbsent(String regex, Task.OutputKind kind) throws Exception { |
c73ab5e71cc2
8166127: Develop new tests to cover javadoc module options which are passed to underlying javac
ksrini
parents:
40508
diff
changeset
|
272 |
List<String> foundList = tb.grep(regex, currentTask.getOutputLines(kind)); |
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
273 |
if (!foundList.isEmpty()) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
274 |
dumpDocletDiagnostics(); |
41161
c73ab5e71cc2
8166127: Develop new tests to cover javadoc module options which are passed to underlying javac
ksrini
parents:
40508
diff
changeset
|
275 |
throw new Exception(regex + " found in: " + kind); |
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
276 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
277 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
278 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
279 |
public static class ModulesTesterDoclet implements Doclet { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
280 |
StringWriter sw = new StringWriter(); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
281 |
PrintWriter ps = new PrintWriter(sw); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
282 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
283 |
// csv style output, for simple regex verification |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
284 |
void printDataSet(String header, Set<? extends Element> set) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
285 |
for (Element e : set) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
286 |
ps.print(header); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
287 |
new SimpleElementVisitor9<Void, Void>() { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
288 |
@Override |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
289 |
public Void visitModule(ModuleElement e, Void p) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
290 |
ps.print(FS); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
291 |
ps.print(e.getKind()); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
292 |
ps.print(FS); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
293 |
ps.println(e.getQualifiedName()); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
294 |
return null; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
295 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
296 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
297 |
@Override |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
298 |
public Void visitPackage(PackageElement e, Void p) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
299 |
ps.print(FS); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
300 |
ps.print(e.getKind()); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
301 |
ps.print(FS); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
302 |
ps.println(e.getQualifiedName()); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
303 |
return null; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
304 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
305 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
306 |
@Override |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
307 |
public Void visitType(TypeElement e, Void p) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
308 |
ps.print(FS); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
309 |
ps.print(ElementKind.CLASS); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
310 |
ps.print(FS); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
311 |
ps.println(e.getQualifiedName()); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
312 |
return null; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
313 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
314 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
315 |
@Override |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
316 |
protected Void defaultAction(Element e, Void p) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
317 |
Element encl = e.getEnclosingElement(); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
318 |
CharSequence fqn = new SimpleElementVisitor9<CharSequence, Void>() { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
319 |
@Override |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
320 |
public CharSequence visitModule(ModuleElement e, Void p) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
321 |
return e.getQualifiedName(); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
322 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
323 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
324 |
@Override |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
325 |
public CharSequence visitType(TypeElement e, Void p) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
326 |
return e.getQualifiedName(); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
327 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
328 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
329 |
@Override |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
330 |
public CharSequence visitPackage(PackageElement e, Void p) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
331 |
return e.getQualifiedName(); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
332 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
333 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
334 |
}.visit(encl); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
335 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
336 |
ps.print(FS); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
337 |
ps.print(ElementKind.METHOD); // always METHOD |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
338 |
ps.print(FS); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
339 |
ps.print(fqn); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
340 |
ps.print("."); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
341 |
ps.println(e.getSimpleName()); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
342 |
return null; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
343 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
344 |
}.visit(e); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
345 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
346 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
347 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
348 |
@Override |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
349 |
public boolean run(DocletEnvironment docenv) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
350 |
ps.println("ModuleMode" + FS + docenv.getModuleMode()); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
351 |
printDataSet("Specified", docenv.getSpecifiedElements()); |
42277 | 352 |
printDataSet("Included", docenv.getIncludedElements()); |
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
353 |
printDataSet("Selected", getAllSelectedElements(docenv)); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
354 |
System.out.println(sw); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
355 |
return true; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
356 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
357 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
358 |
Set<Element> getAllSelectedElements(DocletEnvironment docenv) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
359 |
Set<Element> result = new TreeSet<Element>((Element e1, Element e2) -> { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
360 |
// some grouping by kind preferred |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
361 |
int rc = e1.getKind().compareTo(e2.getKind()); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
362 |
if (rc != 0) return rc; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
363 |
rc = e1.toString().compareTo(e2.toString()); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
364 |
if (rc != 0) return rc; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
365 |
return Integer.compare(e1.hashCode(), e2.hashCode()); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
366 |
}); |
42277 | 367 |
Set<? extends Element> elements = docenv.getIncludedElements(); |
368 |
for (ModuleElement me : ElementFilter.modulesIn(elements)) { |
|
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
369 |
addEnclosedElements(docenv, result, me); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
370 |
} |
42277 | 371 |
for (PackageElement pe : ElementFilter.packagesIn(elements)) { |
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
372 |
addEnclosedElements(docenv, result, docenv.getElementUtils().getModuleOf(pe)); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
373 |
addEnclosedElements(docenv, result, pe); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
374 |
} |
42277 | 375 |
for (TypeElement te : ElementFilter.typesIn(elements)) { |
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
376 |
addEnclosedElements(docenv, result, te); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
377 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
378 |
return result; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
379 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
380 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
381 |
void addEnclosedElements(DocletEnvironment docenv, Set<Element> result, Element e) { |
42277 | 382 |
List<Element> elems = e.getEnclosedElements().stream() |
383 |
.filter(el -> docenv.isIncluded(el)) |
|
384 |
.collect(Collectors.toList()); |
|
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
385 |
result.addAll(elems); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
386 |
for (TypeElement t : ElementFilter.typesIn(elems)) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
387 |
addEnclosedElements(docenv, result, t); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
388 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
389 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
390 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
391 |
@Override |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
392 |
public Set<Doclet.Option> getSupportedOptions() { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
393 |
return Collections.emptySet(); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
394 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
395 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
396 |
@Override |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
397 |
public void init(Locale locale, Reporter reporter) {} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
398 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
399 |
@Override |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
400 |
public String getName() { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
401 |
return "ModulesTesterDoclet"; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
402 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
403 |
|
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
404 |
@Override |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
405 |
public SourceVersion getSupportedSourceVersion() { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
406 |
return SourceVersion.latest(); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
407 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
408 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
diff
changeset
|
409 |
} |