author | ksrini |
Sat, 25 Feb 2017 18:02:06 -0800 | |
changeset 44020 | ef5f709f4fd8 |
parent 42828 | cce89649f958 |
child 44189 | dd311cfb920b |
permissions | -rw-r--r-- |
10 | 1 |
/* |
44020
ef5f709f4fd8
8175055: Errors reported by Arguments.validate should (probably) be fatal
ksrini
parents:
42828
diff
changeset
|
2 |
* Copyright (c) 1997, 2017, 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
26 |
package jdk.javadoc.internal.tool; |
10 | 27 |
|
14258 | 28 |
import java.io.File; |
29 |
import java.io.IOException; |
|
30 |
import java.io.PrintWriter; |
|
31936 | 31 |
import java.nio.file.Path; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
32 |
import java.text.BreakIterator; |
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
33 |
import java.text.Collator; |
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
34 |
import java.util.ArrayList; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
35 |
import java.util.Arrays; |
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
36 |
import java.util.Collection; |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
37 |
import java.util.Collections; |
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
38 |
import java.util.Comparator; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
39 |
import java.util.List; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
40 |
import java.util.Locale; |
29291
076c277565f7
8073550: java* tools: replace obj.getClass hacks with Assert.checkNonNull or Objects.requireNonNull
mcimadamore
parents:
27379
diff
changeset
|
41 |
import java.util.Objects; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
42 |
import java.util.Set; |
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
43 |
import java.util.stream.Collectors; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
44 |
import java.util.stream.Stream; |
36526 | 45 |
|
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
46 |
import javax.tools.JavaFileManager; |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
47 |
import javax.tools.JavaFileObject; |
31936 | 48 |
import javax.tools.StandardJavaFileManager; |
49 |
import javax.tools.StandardLocation; |
|
14258 | 50 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
51 |
import com.sun.tools.javac.api.JavacTrees; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
52 |
import com.sun.tools.javac.file.BaseFileManager; |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
53 |
import com.sun.tools.javac.file.JavacFileManager; |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
54 |
import com.sun.tools.javac.main.Arguments; |
10 | 55 |
import com.sun.tools.javac.main.CommandLine; |
37393
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
56 |
import com.sun.tools.javac.main.OptionHelper; |
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
57 |
import com.sun.tools.javac.main.OptionHelper.GrumpyHelper; |
31936 | 58 |
import com.sun.tools.javac.platform.PlatformDescription; |
59 |
import com.sun.tools.javac.platform.PlatformUtils; |
|
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
60 |
import com.sun.tools.javac.util.ClientCodeException; |
10 | 61 |
import com.sun.tools.javac.util.Context; |
11052 | 62 |
import com.sun.tools.javac.util.Log; |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
63 |
import com.sun.tools.javac.util.Log.WriterKind; |
10 | 64 |
import com.sun.tools.javac.util.Options; |
42277 | 65 |
import com.sun.tools.javac.util.StringUtils; |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
66 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
67 |
import jdk.javadoc.doclet.Doclet; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
68 |
import jdk.javadoc.doclet.Doclet.Option; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
69 |
import jdk.javadoc.doclet.DocletEnvironment; |
41451 | 70 |
import jdk.javadoc.internal.tool.Main.Result; |
10 | 71 |
|
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
72 |
import static javax.tools.DocumentationTool.Location.*; |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
73 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
74 |
import static com.sun.tools.javac.main.Option.*; |
41451 | 75 |
import static jdk.javadoc.internal.tool.Main.Result.*; |
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
76 |
|
10 | 77 |
/** |
78 |
* Main program of Javadoc. |
|
79 |
* Previously named "Main". |
|
80 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
81 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
82 |
* If you write code that depends on this, you do so at your own risk. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
83 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
84 |
* deletion without notice.</b> |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
85 |
* |
10 | 86 |
* @author Robert Field |
87 |
* @author Neal Gafter (rewrite) |
|
88 |
*/ |
|
14543 | 89 |
public class Start extends ToolOption.Helper { |
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
90 |
|
38617 | 91 |
@SuppressWarnings("deprecation") |
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
92 |
private static final Class<?> OldStdDoclet = |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
93 |
com.sun.tools.doclets.standard.Standard.class; |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
94 |
|
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
95 |
private static final Class<?> StdDoclet = |
39179
c04b68e23fa4
8154399: Need replacement for jdk.javadoc/com.sun.tools.doclets.standard.Standard
jjg
parents:
38918
diff
changeset
|
96 |
jdk.javadoc.doclets.StandardDoclet.class; |
14442 | 97 |
/** Context for this invocation. */ |
98 |
private final Context context; |
|
10 | 99 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
100 |
private static final String ProgramName = "javadoc"; |
10 | 101 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
102 |
private Messager messager; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
103 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
104 |
private final String docletName; |
10 | 105 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
106 |
private final ClassLoader classLoader; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
107 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
108 |
private Class<?> docletClass; |
10 | 109 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
110 |
private Doclet doclet; |
10 | 111 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
112 |
// used to determine the locale for the messager |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
113 |
private Locale locale; |
10 | 114 |
|
115 |
||
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
116 |
/** |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
117 |
* In API mode, exceptions thrown while calling the doclet are |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
118 |
* propagated using ClientCodeException. |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
119 |
*/ |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
120 |
private boolean apiMode; |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
121 |
|
27320
f0739350a62d
8062504: javadoc Start does not close file managers that it opens
jjg
parents:
25874
diff
changeset
|
122 |
private JavaFileManager fileManager; |
f0739350a62d
8062504: javadoc Start does not close file managers that it opens
jjg
parents:
25874
diff
changeset
|
123 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
124 |
Start() { |
41448 | 125 |
this(null, null, null, null, null, null); |
1365 | 126 |
} |
127 |
||
41448 | 128 |
Start(PrintWriter outWriter, PrintWriter errWriter) { |
129 |
this(null, null, outWriter, errWriter, null, null); |
|
10 | 130 |
} |
131 |
||
41448 | 132 |
Start(Context context, String programName, |
133 |
PrintWriter outWriter, PrintWriter errWriter, |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
134 |
String docletName, ClassLoader classLoader) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
135 |
this.context = context == null ? new Context() : context; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
136 |
String pname = programName == null ? ProgramName : programName; |
41448 | 137 |
this.messager = (outWriter == null && errWriter == null) |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
138 |
? new Messager(this.context, pname) |
41448 | 139 |
: new Messager(this.context, pname, outWriter, errWriter); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
140 |
this.docletName = docletName; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
141 |
this.classLoader = classLoader; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
142 |
this.docletClass = null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
143 |
this.locale = Locale.getDefault(); |
10 | 144 |
} |
145 |
||
14543 | 146 |
public Start(Context context) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
147 |
this.docletClass = null; |
29291
076c277565f7
8073550: java* tools: replace obj.getClass hacks with Assert.checkNonNull or Objects.requireNonNull
mcimadamore
parents:
27379
diff
changeset
|
148 |
this.context = Objects.requireNonNull(context); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
149 |
this.apiMode = true; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
150 |
this.docletName = null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
151 |
this.classLoader = null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
152 |
this.locale = Locale.getDefault(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
153 |
} |
14543 | 154 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
155 |
void initMessager() { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
156 |
if (!apiMode) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
157 |
return; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
158 |
if (messager == null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
159 |
Log log = context.get(Log.logKey); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
160 |
if (log instanceof Messager) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
161 |
messager = (Messager) log; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
162 |
} else { |
40232
4995ab1a4558
8162359: javac should use stdout for --help and --version
jjg
parents:
39179
diff
changeset
|
163 |
PrintWriter out = context.get(Log.errKey); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
164 |
messager = (out == null) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
165 |
? new Messager(context, ProgramName) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
166 |
: new Messager(context, ProgramName, out, out); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
167 |
} |
14543 | 168 |
} |
169 |
} |
|
170 |
||
10 | 171 |
/** |
172 |
* Usage |
|
173 |
*/ |
|
14543 | 174 |
@Override |
175 |
void usage() { |
|
41451 | 176 |
usage("main.usage", OptionKind.STANDARD, "main.usage.foot"); |
14543 | 177 |
} |
178 |
||
179 |
@Override |
|
180 |
void Xusage() { |
|
41451 | 181 |
usage("main.Xusage", OptionKind.EXTENDED, "main.Xusage.foot"); |
10 | 182 |
} |
183 |
||
41451 | 184 |
private void usage(String headerKey, OptionKind kind, String footerKey) { |
185 |
messager.notice(headerKey); |
|
186 |
showToolOptions(kind); |
|
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
187 |
|
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
188 |
// let doclet print usage information |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
189 |
if (docletClass != null) { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
190 |
String name = doclet.getName(); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
191 |
messager.notice("main.doclet.usage.header", name); |
41451 | 192 |
showDocletOptions(kind == OptionKind.EXTENDED |
193 |
? Option.Kind.EXTENDED |
|
194 |
: Option.Kind.STANDARD); |
|
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
195 |
} |
41451 | 196 |
if (footerKey != null) |
197 |
messager.notice(footerKey); |
|
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
198 |
} |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
199 |
|
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
200 |
void showToolOptions(OptionKind kind) { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
201 |
Comparator<ToolOption> comp = new Comparator<ToolOption>() { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
202 |
final Collator collator = Collator.getInstance(Locale.US); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
203 |
{ collator.setStrength(Collator.PRIMARY); } |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
204 |
|
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
205 |
@Override |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
206 |
public int compare(ToolOption o1, ToolOption o2) { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
207 |
return collator.compare(o1.primaryName, o2.primaryName); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
208 |
} |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
209 |
}; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
210 |
|
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
211 |
Stream.of(ToolOption.values()) |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
212 |
.filter(opt -> opt.kind == kind) |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
213 |
.sorted(comp) |
42827
36468b5fa7f4
8181370: Convert anonymous inner classes into lambdas/method references
mcimadamore
parents:
42277
diff
changeset
|
214 |
.forEach(this::showToolOption); |
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
215 |
} |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
216 |
|
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
217 |
void showToolOption(ToolOption option) { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
218 |
List<String> names = option.getNames(); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
219 |
String parameters; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
220 |
if (option.hasArg || option.primaryName.endsWith(":")) { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
221 |
String sep = (option == ToolOption.J) || option.primaryName.endsWith(":") ? "" : " "; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
222 |
parameters = sep + option.getParameters(messager); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
223 |
} else { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
224 |
parameters = ""; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
225 |
} |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
226 |
String description = option.getDescription(messager); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
227 |
showUsage(names, parameters, description); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
228 |
} |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
229 |
|
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
230 |
void showDocletOptions(Option.Kind kind) { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
231 |
Comparator<Doclet.Option> comp = new Comparator<Doclet.Option>() { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
232 |
final Collator collator = Collator.getInstance(Locale.US); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
233 |
{ collator.setStrength(Collator.PRIMARY); } |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
234 |
|
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
235 |
@Override |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
236 |
public int compare(Doclet.Option o1, Doclet.Option o2) { |
42277 | 237 |
return collator.compare(o1.getNames().get(0), o2.getNames().get(0)); |
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
238 |
} |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
239 |
}; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
240 |
|
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
241 |
doclet.getSupportedOptions().stream() |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
242 |
.filter(opt -> opt.getKind() == kind) |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
243 |
.sorted(comp) |
42827
36468b5fa7f4
8181370: Convert anonymous inner classes into lambdas/method references
mcimadamore
parents:
42277
diff
changeset
|
244 |
.forEach(this::showDocletOption); |
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
245 |
} |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
246 |
|
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
247 |
void showDocletOption(Doclet.Option option) { |
42277 | 248 |
List<String> names = option.getNames(); |
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
249 |
String parameters; |
42277 | 250 |
String optname = names.get(0); |
251 |
if (option.getArgumentCount() > 0 || optname.endsWith(":")) { |
|
252 |
String sep = optname.endsWith(":") ? "" : " "; |
|
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
253 |
parameters = sep + option.getParameters(); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
254 |
} else { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
255 |
parameters = ""; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
256 |
} |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
257 |
String description = option.getDescription(); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
258 |
showUsage(names, parameters, description); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
259 |
} |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
260 |
|
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
261 |
// The following constants are intended to format the output to |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
262 |
// be similar to that of the java launcher: i.e. "java -help". |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
263 |
|
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
264 |
/** The indent for the option synopsis. */ |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
265 |
private static final String SMALL_INDENT = " "; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
266 |
/** The automatic indent for the description. */ |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
267 |
private static final String LARGE_INDENT = " "; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
268 |
/** The space allowed for the synopsis, if the description is to be shown on the same line. */ |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
269 |
private static final int DEFAULT_SYNOPSIS_WIDTH = 13; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
270 |
/** The nominal maximum line length, when seeing if text will fit on a line. */ |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
271 |
private static final int DEFAULT_MAX_LINE_LENGTH = 80; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
272 |
/** The format for a single-line help entry. */ |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
273 |
private static final String COMPACT_FORMAT = SMALL_INDENT + "%-" + DEFAULT_SYNOPSIS_WIDTH + "s %s"; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
274 |
|
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
275 |
void showUsage(List<String> names, String parameters, String description) { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
276 |
String synopses = names.stream() |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
277 |
.map(s -> s + parameters) |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
278 |
.collect(Collectors.joining(", ")); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
279 |
// If option synopses and description fit on a single line of reasonable length, |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
280 |
// display using COMPACT_FORMAT |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
281 |
if (synopses.length() < DEFAULT_SYNOPSIS_WIDTH |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
282 |
&& !description.contains("\n") |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
283 |
&& (SMALL_INDENT.length() + DEFAULT_SYNOPSIS_WIDTH + 1 + description.length() <= DEFAULT_MAX_LINE_LENGTH)) { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
284 |
messager.printNotice(String.format(COMPACT_FORMAT, synopses, description)); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
285 |
return; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
286 |
} |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
287 |
|
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
288 |
// If option synopses fit on a single line of reasonable length, show that; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
289 |
// otherwise, show 1 per line |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
290 |
if (synopses.length() <= DEFAULT_MAX_LINE_LENGTH) { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
291 |
messager.printNotice(SMALL_INDENT + synopses); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
292 |
} else { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
293 |
for (String name: names) { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
294 |
messager.printNotice(SMALL_INDENT + name + parameters); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
295 |
} |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
296 |
} |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
297 |
|
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
298 |
// Finally, show the description |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
299 |
messager.printNotice(LARGE_INDENT + description.replace("\n", "\n" + LARGE_INDENT)); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
300 |
} |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
301 |
|
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
302 |
|
5850
6f095ff5b469
6958836: javadoc should support -Xmaxerrs and -Xmaxwarns
jjg
parents:
5520
diff
changeset
|
303 |
/** |
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
304 |
* Main program - external wrapper. In order to maintain backward |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
305 |
* CLI compatibility, we dispatch to the old tool or the old doclet's |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
306 |
* Start mechanism, based on the options present on the command line |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
307 |
* with the following precedence: |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
308 |
* 1. presence of -Xold, dispatch to old tool |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
309 |
* 2. doclet variant, if old, dispatch to old Start |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
310 |
* 3. taglet variant, if old, dispatch to old Start |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
311 |
* |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
312 |
* Thus the presence of -Xold switches the tool, soon after command files |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
313 |
* if any, are expanded, this is performed here, noting that the messager |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
314 |
* is available at this point in time. |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
315 |
* The doclet/taglet tests are performed in the begin method, further on, |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
316 |
* this is to minimize argument processing and most importantly the impact |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
317 |
* of class loader creation, needed to detect the doclet/taglet class variants. |
10 | 318 |
*/ |
38614 | 319 |
@SuppressWarnings("deprecation") |
41451 | 320 |
Result begin(String... argv) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
321 |
// Preprocess @file arguments |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
322 |
try { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
323 |
argv = CommandLine.parse(argv); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
324 |
} catch (IOException e) { |
41451 | 325 |
error("main.cant.read", e.getMessage()); |
326 |
return ERROR; |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
327 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
328 |
|
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
329 |
if (argv.length > 0 && "-Xold".equals(argv[0])) { |
41451 | 330 |
warn("main.legacy_api"); |
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
331 |
String[] nargv = Arrays.copyOfRange(argv, 1, argv.length); |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
332 |
int rc = com.sun.tools.javadoc.Main.execute( |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
333 |
messager.programName, |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
334 |
messager.getWriter(WriterKind.ERROR), |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
335 |
messager.getWriter(WriterKind.WARNING), |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
336 |
messager.getWriter(WriterKind.NOTICE), |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
337 |
"com.sun.tools.doclets.standard.Standard", |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
338 |
nargv); |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
339 |
return (rc == 0) ? OK : ERROR; |
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
340 |
} |
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42827
diff
changeset
|
341 |
return begin(Arrays.asList(argv), Collections.emptySet()); |
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
342 |
} |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
343 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
344 |
// Called by 199 API. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
345 |
public boolean begin(Class<?> docletClass, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
346 |
Iterable<String> options, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
347 |
Iterable<? extends JavaFileObject> fileObjects) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
348 |
this.docletClass = docletClass; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
349 |
List<String> opts = new ArrayList<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
350 |
for (String opt: options) |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
351 |
opts.add(opt); |
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
352 |
|
41451 | 353 |
return begin(opts, fileObjects).isOK(); |
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
354 |
} |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
355 |
|
38614 | 356 |
@SuppressWarnings("deprecation") |
41451 | 357 |
private Result begin(List<String> options, Iterable<? extends JavaFileObject> fileObjects) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
358 |
fileManager = context.get(JavaFileManager.class); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
359 |
if (fileManager == null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
360 |
JavacFileManager.preRegister(context); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
361 |
fileManager = context.get(JavaFileManager.class); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
362 |
if (fileManager instanceof BaseFileManager) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
363 |
((BaseFileManager) fileManager).autoClose = true; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
364 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
365 |
} |
41451 | 366 |
|
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
367 |
// locale, doclet and maybe taglet, needs to be determined first |
41451 | 368 |
try { |
369 |
docletClass = preprocess(fileManager, options); |
|
370 |
} catch (ToolException te) { |
|
371 |
if (!te.result.isOK()) { |
|
372 |
if (te.message != null) { |
|
373 |
messager.printError(te.message); |
|
374 |
} |
|
375 |
Throwable t = te.getCause(); |
|
376 |
dumpStack(t == null ? te : t); |
|
377 |
} |
|
378 |
return te.result; |
|
379 |
} catch (OptionException oe) { |
|
380 |
if (oe.message != null) { |
|
381 |
messager.printError(oe.message); |
|
382 |
} |
|
383 |
oe.m.run(); |
|
384 |
Throwable t = oe.getCause(); |
|
385 |
dumpStack(t == null ? oe : t); |
|
386 |
return oe.result; |
|
387 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
388 |
if (jdk.javadoc.doclet.Doclet.class.isAssignableFrom(docletClass)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
389 |
// no need to dispatch to old, safe to init now |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
390 |
initMessager(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
391 |
messager.setLocale(locale); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
392 |
try { |
38918
bf1ed1a40f5b
8155880: Fix langtools usage of the deprecated Class.newInstance method
darcy
parents:
38617
diff
changeset
|
393 |
Object o = docletClass.getConstructor().newInstance(); |
37759
f0b5daef41b6
8155516: Suppress warnings from uses of deprecated Class.newInstance langtools
darcy
parents:
37757
diff
changeset
|
394 |
doclet = (Doclet) o; |
38918
bf1ed1a40f5b
8155880: Fix langtools usage of the deprecated Class.newInstance method
darcy
parents:
38617
diff
changeset
|
395 |
} catch (ReflectiveOperationException exc) { |
41451 | 396 |
if (apiMode) { |
397 |
throw new ClientCodeException(exc); |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
398 |
} |
41451 | 399 |
error("main.could_not_instantiate_class", docletClass); |
400 |
return ERROR; |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
401 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
402 |
} else { |
41451 | 403 |
if (apiMode) { |
37938
42baa89d2156
8075703: jdk.javadoc module exports com.sun.tools.javadoc package which contains a lot of internal API.
jjg
parents:
37759
diff
changeset
|
404 |
com.sun.tools.javadoc.main.Start ostart |
42baa89d2156
8075703: jdk.javadoc module exports com.sun.tools.javadoc package which contains a lot of internal API.
jjg
parents:
37759
diff
changeset
|
405 |
= new com.sun.tools.javadoc.main.Start(context); |
41451 | 406 |
return ostart.begin(docletClass, options, fileObjects) |
407 |
? OK |
|
408 |
: ERROR; |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
409 |
} |
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
410 |
warn("main.legacy_api"); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
411 |
String[] array = options.toArray(new String[options.size()]); |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
412 |
int rc = com.sun.tools.javadoc.Main.execute( |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
413 |
messager.programName, |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
414 |
messager.getWriter(WriterKind.ERROR), |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
415 |
messager.getWriter(WriterKind.WARNING), |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
416 |
messager.getWriter(WriterKind.NOTICE), |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
417 |
"com.sun.tools.doclets.standard.Standard", |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
418 |
array); |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
419 |
return (rc == 0) ? OK : ERROR; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
420 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
421 |
|
41451 | 422 |
Result result = OK; |
10 | 423 |
try { |
44020
ef5f709f4fd8
8175055: Errors reported by Arguments.validate should (probably) be fatal
ksrini
parents:
42828
diff
changeset
|
424 |
result = parseAndExecute(options, fileObjects); |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
425 |
} catch (com.sun.tools.javac.main.Option.InvalidValueException e) { |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
426 |
messager.printError(e.getMessage()); |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
427 |
Throwable t = e.getCause(); |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
428 |
dumpStack(t == null ? e : t); |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
429 |
return ERROR; |
41451 | 430 |
} catch (OptionException toe) { |
431 |
if (toe.message != null) |
|
432 |
messager.printError(toe.message); |
|
433 |
||
434 |
toe.m.run(); |
|
435 |
Throwable t = toe.getCause(); |
|
436 |
dumpStack(t == null ? toe : t); |
|
437 |
return toe.result; |
|
438 |
} catch (ToolException exc) { |
|
439 |
if (exc.message != null) { |
|
440 |
messager.printError(exc.message); |
|
441 |
} |
|
442 |
Throwable t = exc.getCause(); |
|
443 |
if (result == ABNORMAL) { |
|
444 |
reportInternalError(t == null ? exc : t); |
|
445 |
} else { |
|
446 |
dumpStack(t == null ? exc : t); |
|
447 |
} |
|
448 |
return exc.result; |
|
10 | 449 |
} catch (OutOfMemoryError ee) { |
41451 | 450 |
error("main.out.of.memory"); |
451 |
result = SYSERR; |
|
452 |
dumpStack(ee); |
|
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
453 |
} catch (ClientCodeException e) { |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
454 |
// simply rethrow these exceptions, to be caught and handled by JavadocTaskImpl |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
455 |
throw e; |
41451 | 456 |
} catch (Error | Exception ee) { |
457 |
error("main.fatal.error", ee); |
|
458 |
reportInternalError(ee); |
|
459 |
result = ABNORMAL; |
|
10 | 460 |
} finally { |
27379
5ae894733e09
8062579: JavacTask, DocumentationTask impls should close file manager when possible
jjg
parents:
27320
diff
changeset
|
461 |
if (fileManager != null |
5ae894733e09
8062579: JavacTask, DocumentationTask impls should close file manager when possible
jjg
parents:
27320
diff
changeset
|
462 |
&& fileManager instanceof BaseFileManager |
5ae894733e09
8062579: JavacTask, DocumentationTask impls should close file manager when possible
jjg
parents:
27320
diff
changeset
|
463 |
&& ((BaseFileManager) fileManager).autoClose) { |
27320
f0739350a62d
8062504: javadoc Start does not close file managers that it opens
jjg
parents:
25874
diff
changeset
|
464 |
try { |
f0739350a62d
8062504: javadoc Start does not close file managers that it opens
jjg
parents:
25874
diff
changeset
|
465 |
fileManager.close(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
466 |
} catch (IOException ignore) {} |
27320
f0739350a62d
8062504: javadoc Start does not close file managers that it opens
jjg
parents:
25874
diff
changeset
|
467 |
} |
41451 | 468 |
boolean haveErrorWarnings = messager.hasErrors() |
469 |
|| (rejectWarnings && messager.hasWarnings()); |
|
470 |
if (!result.isOK() && !haveErrorWarnings) { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
471 |
// the doclet failed, but nothing reported, flag it!. |
41451 | 472 |
error("main.unknown.error"); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
473 |
} |
41451 | 474 |
if (haveErrorWarnings && result.isOK()) { |
475 |
result = ERROR; |
|
476 |
} |
|
477 |
messager.printErrorWarningCounts(); |
|
10 | 478 |
messager.flush(); |
479 |
} |
|
41451 | 480 |
return result; |
481 |
} |
|
482 |
||
483 |
private void reportInternalError(Throwable t) { |
|
484 |
messager.printErrorUsingKey("doclet.internal.report.bug"); |
|
485 |
dumpStack(true, t); |
|
486 |
} |
|
487 |
||
488 |
private void dumpStack(Throwable t) { |
|
489 |
dumpStack(false, t); |
|
490 |
} |
|
491 |
||
492 |
private void dumpStack(boolean enabled, Throwable t) { |
|
493 |
if (t != null && (enabled || dumpOnError)) { |
|
494 |
t.printStackTrace(System.err); |
|
495 |
} |
|
10 | 496 |
} |
497 |
||
498 |
/** |
|
499 |
* Main program - internal |
|
500 |
*/ |
|
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
501 |
@SuppressWarnings("unchecked") |
44020
ef5f709f4fd8
8175055: Errors reported by Arguments.validate should (probably) be fatal
ksrini
parents:
42828
diff
changeset
|
502 |
private Result parseAndExecute(List<String> argList, Iterable<? extends JavaFileObject> fileObjects) |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
503 |
throws ToolException, OptionException, com.sun.tools.javac.main.Option.InvalidValueException { |
10 | 504 |
long tm = System.currentTimeMillis(); |
505 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
506 |
List<String> javaNames = new ArrayList<>(); |
5850
6f095ff5b469
6958836: javadoc should support -Xmaxerrs and -Xmaxwarns
jjg
parents:
5520
diff
changeset
|
507 |
|
14543 | 508 |
compOpts = Options.instance(context); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
509 |
|
19508
e2cd0ed6c9b0
8011043: Warn about use of 1.5 and earlier source and target values
darcy
parents:
18005
diff
changeset
|
510 |
// Make sure no obsolete source/target messages are reported |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
511 |
try { |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
512 |
com.sun.tools.javac.main.Option.XLINT_CUSTOM.process(getOptionHelper(), "-Xlint:-options"); |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
513 |
} catch (com.sun.tools.javac.main.Option.InvalidValueException ignore) { |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
514 |
} |
10 | 515 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
516 |
doclet.init(locale, messager); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
517 |
parseArgs(argList, javaNames); |
14543 | 518 |
|
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
519 |
Arguments arguments = Arguments.instance(context); |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
520 |
arguments.init(ProgramName); |
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
521 |
arguments.allowEmpty(); |
44020
ef5f709f4fd8
8175055: Errors reported by Arguments.validate should (probably) be fatal
ksrini
parents:
42828
diff
changeset
|
522 |
if (!arguments.validate()) { |
ef5f709f4fd8
8175055: Errors reported by Arguments.validate should (probably) be fatal
ksrini
parents:
42828
diff
changeset
|
523 |
// Arguments does not always increase the error count in the |
ef5f709f4fd8
8175055: Errors reported by Arguments.validate should (probably) be fatal
ksrini
parents:
42828
diff
changeset
|
524 |
// case of errors, so increment the error count only if it has |
ef5f709f4fd8
8175055: Errors reported by Arguments.validate should (probably) be fatal
ksrini
parents:
42828
diff
changeset
|
525 |
// not been updated previously, preventing complaints by callers |
ef5f709f4fd8
8175055: Errors reported by Arguments.validate should (probably) be fatal
ksrini
parents:
42828
diff
changeset
|
526 |
if (!messager.hasErrors() && !messager.hasWarnings()) |
ef5f709f4fd8
8175055: Errors reported by Arguments.validate should (probably) be fatal
ksrini
parents:
42828
diff
changeset
|
527 |
messager.nerrors++; |
ef5f709f4fd8
8175055: Errors reported by Arguments.validate should (probably) be fatal
ksrini
parents:
42828
diff
changeset
|
528 |
return CMDERR; |
ef5f709f4fd8
8175055: Errors reported by Arguments.validate should (probably) be fatal
ksrini
parents:
42828
diff
changeset
|
529 |
} |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
530 |
|
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
531 |
if (fileManager instanceof BaseFileManager) { |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
532 |
((BaseFileManager) fileManager).handleOptions(fileManagerOpts); |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
533 |
} |
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
22163
diff
changeset
|
534 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
535 |
String platformString = compOpts.get("--release"); |
31936 | 536 |
|
537 |
if (platformString != null) { |
|
538 |
if (compOpts.isSet("-source")) { |
|
41451 | 539 |
String text = messager.getText("main.release.bootclasspath.conflict", "-source"); |
540 |
throw new ToolException(CMDERR, text); |
|
31936 | 541 |
} |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
40232
diff
changeset
|
542 |
if (fileManagerOpts.containsKey(BOOT_CLASS_PATH)) { |
41451 | 543 |
String text = messager.getText("main.release.bootclasspath.conflict", |
544 |
BOOT_CLASS_PATH.getPrimaryName()); |
|
545 |
throw new ToolException(CMDERR, text); |
|
31936 | 546 |
} |
547 |
||
548 |
PlatformDescription platformDescription = |
|
549 |
PlatformUtils.lookupPlatformDescription(platformString); |
|
550 |
||
551 |
if (platformDescription == null) { |
|
41451 | 552 |
String text = messager.getText("main.unsupported.release.version", platformString); |
553 |
throw new IllegalArgumentException(text); |
|
31936 | 554 |
} |
555 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
556 |
compOpts.put(SOURCE, platformDescription.getSourceVersion()); |
31936 | 557 |
|
558 |
context.put(PlatformDescription.class, platformDescription); |
|
559 |
||
560 |
Collection<Path> platformCP = platformDescription.getPlatformPath(); |
|
561 |
||
562 |
if (platformCP != null) { |
|
563 |
if (fileManager instanceof StandardJavaFileManager) { |
|
564 |
StandardJavaFileManager sfm = (StandardJavaFileManager) fileManager; |
|
41451 | 565 |
try { |
566 |
sfm.setLocationFromPaths(StandardLocation.PLATFORM_CLASS_PATH, platformCP); |
|
567 |
} catch (IOException ioe) { |
|
568 |
throw new ToolException(SYSERR, ioe.getMessage(), ioe); |
|
569 |
} |
|
31936 | 570 |
} else { |
41451 | 571 |
String text = messager.getText("main.release.not.standard.file.manager", |
572 |
platformString); |
|
573 |
throw new ToolException(ABNORMAL, text); |
|
31936 | 574 |
} |
575 |
} |
|
576 |
} |
|
577 |
||
14442 | 578 |
compOpts.notifyListeners(); |
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
579 |
List<String> modules = (List<String>) jdtoolOpts.computeIfAbsent(ToolOption.MODULE, |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
580 |
s -> Collections.EMPTY_LIST); |
10 | 581 |
|
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
582 |
if (modules.isEmpty()) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
583 |
List<String> subpkgs = (List<String>) jdtoolOpts.computeIfAbsent(ToolOption.SUBPACKAGES, |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
584 |
s -> Collections.EMPTY_LIST); |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
585 |
if (subpkgs.isEmpty()) { |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
586 |
if (javaNames.isEmpty() && isEmpty(fileObjects)) { |
41451 | 587 |
String text = messager.getText("main.No_modules_packages_or_classes_specified"); |
588 |
throw new ToolException(CMDERR, text); |
|
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
589 |
} |
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
590 |
} |
10 | 591 |
} |
592 |
||
593 |
JavadocTool comp = JavadocTool.make0(context); |
|
44020
ef5f709f4fd8
8175055: Errors reported by Arguments.validate should (probably) be fatal
ksrini
parents:
42828
diff
changeset
|
594 |
if (comp == null) return ABNORMAL; |
10 | 595 |
|
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
596 |
DocletEnvironment docEnv = comp.getEnvironment(jdtoolOpts, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
597 |
javaNames, |
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
598 |
fileObjects); |
10 | 599 |
|
14441
6c066a762e05
8002146: javadoc doesn't release resources in a timely manner
jjg
parents:
14260
diff
changeset
|
600 |
// release resources |
6c066a762e05
8002146: javadoc doesn't release resources in a timely manner
jjg
parents:
14260
diff
changeset
|
601 |
comp = null; |
6c066a762e05
8002146: javadoc doesn't release resources in a timely manner
jjg
parents:
14260
diff
changeset
|
602 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
603 |
if (breakiterator || !locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
604 |
JavacTrees trees = JavacTrees.instance(context); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
605 |
trees.setBreakIterator(BreakIterator.getSentenceInstance(locale)); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
606 |
} |
10 | 607 |
// pass off control to the doclet |
44020
ef5f709f4fd8
8175055: Errors reported by Arguments.validate should (probably) be fatal
ksrini
parents:
42828
diff
changeset
|
608 |
Result returnStatus = docEnv != null && doclet.run(docEnv) |
ef5f709f4fd8
8175055: Errors reported by Arguments.validate should (probably) be fatal
ksrini
parents:
42828
diff
changeset
|
609 |
? OK |
ef5f709f4fd8
8175055: Errors reported by Arguments.validate should (probably) be fatal
ksrini
parents:
42828
diff
changeset
|
610 |
: ERROR; |
10 | 611 |
|
612 |
// We're done. |
|
613 |
if (compOpts.get("-verbose") != null) { |
|
614 |
tm = System.currentTimeMillis() - tm; |
|
615 |
messager.notice("main.done_in", Long.toString(tm)); |
|
616 |
} |
|
617 |
||
44020
ef5f709f4fd8
8175055: Errors reported by Arguments.validate should (probably) be fatal
ksrini
parents:
42828
diff
changeset
|
618 |
return returnStatus; |
10 | 619 |
} |
620 |
||
42277 | 621 |
boolean matches(List<String> names, String arg) { |
622 |
for (String name : names) { |
|
623 |
if (StringUtils.toLowerCase(name).equals(StringUtils.toLowerCase(arg))) |
|
624 |
return true; |
|
625 |
} |
|
626 |
return false; |
|
627 |
} |
|
628 |
||
629 |
boolean matches(Doclet.Option option, String arg) { |
|
630 |
if (matches(option.getNames(), arg)) |
|
631 |
return true; |
|
632 |
int sep = arg.indexOf(':'); |
|
633 |
String targ = arg.substring(0, sep + 1); |
|
634 |
return matches(option.getNames(), targ); |
|
635 |
} |
|
636 |
||
637 |
Set<? extends Doclet.Option> docletOptions = null; |
|
41451 | 638 |
int handleDocletOptions(int idx, List<String> args, boolean isToolOption) |
639 |
throws OptionException { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
640 |
if (docletOptions == null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
641 |
docletOptions = doclet.getSupportedOptions(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
642 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
643 |
String arg = args.get(idx); |
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
644 |
String argBase, argVal; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
645 |
if (arg.startsWith("--") && arg.contains("=")) { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
646 |
int sep = arg.indexOf("="); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
647 |
argBase = arg.substring(0, sep); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
648 |
argVal = arg.substring(sep + 1); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
649 |
} else { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
650 |
argBase = arg; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
651 |
argVal = null; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
652 |
} |
41451 | 653 |
String text = null; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
654 |
for (Doclet.Option opt : docletOptions) { |
42277 | 655 |
if (matches(opt, argBase)) { |
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
656 |
if (argVal != null) { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
657 |
switch (opt.getArgumentCount()) { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
658 |
case 0: |
41451 | 659 |
text = messager.getText("main.unnecessary_arg_provided", argBase); |
660 |
throw new OptionException(ERROR, this::usage, text); |
|
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
661 |
case 1: |
42277 | 662 |
opt.process(arg, Arrays.asList(argVal)); |
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
663 |
break; |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
664 |
default: |
41451 | 665 |
text = messager.getText("main.only_one_argument_with_equals", argBase); |
666 |
throw new OptionException(ERROR, this::usage, text); |
|
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
667 |
} |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
668 |
} else { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
669 |
if (args.size() - idx -1 < opt.getArgumentCount()) { |
41451 | 670 |
text = messager.getText("main.requires_argument", arg); |
671 |
throw new OptionException(ERROR, this::usage, text); |
|
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
672 |
} |
42277 | 673 |
opt.process(arg, args.subList(idx + 1, args.size())); |
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
674 |
idx += opt.getArgumentCount(); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
675 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
676 |
return idx; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
677 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
678 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
679 |
// check if arg is accepted by the tool before emitting error |
41451 | 680 |
if (!isToolOption) { |
681 |
text = messager.getText("main.invalid_flag", arg); |
|
682 |
throw new OptionException(ERROR, this::usage, text); |
|
683 |
} |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
684 |
return idx; |
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
685 |
} |
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
686 |
|
41451 | 687 |
private Class<?> preprocess(JavaFileManager jfm, |
688 |
List<String> argv) throws ToolException, OptionException { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
689 |
// doclet specifying arguments |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
690 |
String userDocletPath = null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
691 |
String userDocletName = null; |
14545
2e7bab0639b8
6493690: javadoc should have a javax.tools.Tool service provider installed in tools.jar
jjg
parents:
14543
diff
changeset
|
692 |
|
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
693 |
// taglet specifying arguments, since tagletpath is a doclet |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
694 |
// functionality, assume they are repeated and inspect all. |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
695 |
List<File> userTagletPath = new ArrayList<>(); |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
696 |
List<String> userTagletNames = new ArrayList<>(); |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
697 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
698 |
// Step 1: loop through the args, set locale early on, if found. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
699 |
for (int i = 0 ; i < argv.size() ; i++) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
700 |
String arg = argv.get(i); |
41451 | 701 |
if (arg.equals(ToolOption.DUMPONERROR.primaryName)) { |
702 |
dumpOnError = true; |
|
703 |
} else if (arg.equals(ToolOption.LOCALE.primaryName)) { |
|
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
704 |
checkOneArg(argv, i++); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
705 |
String lname = argv.get(i); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
706 |
locale = getLocale(lname); |
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
707 |
} else if (arg.equals(ToolOption.DOCLET.primaryName)) { |
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
708 |
checkOneArg(argv, i++); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
709 |
if (userDocletName != null) { |
41451 | 710 |
if (apiMode) { |
711 |
throw new IllegalArgumentException("More than one doclet specified (" + |
|
712 |
userDocletName + " and " + argv.get(i) + ")."); |
|
713 |
} |
|
714 |
String text = messager.getText("main.more_than_one_doclet_specified_0_and_1", |
|
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
715 |
userDocletName, argv.get(i)); |
41451 | 716 |
throw new ToolException(CMDERR, text); |
10 | 717 |
} |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
718 |
if (docletName != null) { |
41451 | 719 |
if (apiMode) { |
720 |
throw new IllegalArgumentException("More than one doclet specified (" + |
|
721 |
docletName + " and " + argv.get(i) + ")."); |
|
722 |
} |
|
723 |
String text = messager.getText("main.more_than_one_doclet_specified_0_and_1", |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
724 |
docletName, argv.get(i)); |
41451 | 725 |
throw new ToolException(CMDERR, text); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
726 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
727 |
userDocletName = argv.get(i); |
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
728 |
} else if (arg.equals(ToolOption.DOCLETPATH.primaryName)) { |
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
729 |
checkOneArg(argv, i++); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
730 |
if (userDocletPath == null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
731 |
userDocletPath = argv.get(i); |
10 | 732 |
} else { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
733 |
userDocletPath += File.pathSeparator + argv.get(i); |
10 | 734 |
} |
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
735 |
} else if ("-taglet".equals(arg)) { |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
736 |
userTagletNames.add(argv.get(i + 1)); |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
737 |
} else if ("-tagletpath".equals(arg)) { |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
738 |
for (String pathname : argv.get(i + 1).split(File.pathSeparator)) { |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
739 |
userTagletPath.add(new File(pathname)); |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
740 |
} |
10 | 741 |
} |
742 |
} |
|
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
743 |
|
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
744 |
// Step 2: a doclet is provided, nothing more to do. |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
745 |
if (docletClass != null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
746 |
return docletClass; |
10 | 747 |
} |
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
748 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
749 |
// Step 3: doclet name specified ? if so find a ClassLoader, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
750 |
// and load it. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
751 |
if (userDocletName != null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
752 |
ClassLoader cl = classLoader; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
753 |
if (cl == null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
754 |
if (!fileManager.hasLocation(DOCLET_PATH)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
755 |
List<File> paths = new ArrayList<>(); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
756 |
if (userDocletPath != null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
757 |
for (String pathname : userDocletPath.split(File.pathSeparator)) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
758 |
paths.add(new File(pathname)); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
759 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
760 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
761 |
try { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
762 |
((StandardJavaFileManager)fileManager).setLocation(DOCLET_PATH, paths); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
763 |
} catch (IOException ioe) { |
41451 | 764 |
if (apiMode) { |
765 |
throw new IllegalArgumentException("Could not set location for " + |
|
766 |
userDocletPath, ioe); |
|
767 |
} |
|
768 |
String text = messager.getText("main.doclet_could_not_set_location", |
|
769 |
userDocletPath); |
|
770 |
throw new ToolException(CMDERR, text, ioe); |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
771 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
772 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
773 |
cl = fileManager.getClassLoader(DOCLET_PATH); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
774 |
if (cl == null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
775 |
// despite doclet specified on cmdline no classloader found! |
41451 | 776 |
if (apiMode) { |
777 |
throw new IllegalArgumentException("Could not obtain classloader to load " |
|
778 |
+ userDocletPath); |
|
779 |
} |
|
780 |
String text = messager.getText("main.doclet_no_classloader_found", |
|
781 |
userDocletName); |
|
782 |
throw new ToolException(CMDERR, text); |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
783 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
784 |
} |
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
785 |
try { |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
786 |
Class<?> klass = cl.loadClass(userDocletName); |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
787 |
return klass; |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
788 |
} catch (ClassNotFoundException cnfe) { |
41451 | 789 |
if (apiMode) { |
790 |
throw new IllegalArgumentException("Cannot find doclet class " + userDocletName, |
|
791 |
cnfe); |
|
792 |
} |
|
793 |
String text = messager.getText("main.doclet_class_not_found", userDocletName); |
|
794 |
throw new ToolException(CMDERR, text, cnfe); |
|
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
795 |
} |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
796 |
} |
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
797 |
|
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
798 |
// Step 4: we have a doclet, try loading it |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
799 |
if (docletName != null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
800 |
try { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
801 |
return Class.forName(docletName, true, getClass().getClassLoader()); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
802 |
} catch (ClassNotFoundException cnfe) { |
41451 | 803 |
if (apiMode) { |
804 |
throw new IllegalArgumentException("Cannot find doclet class " + userDocletName); |
|
805 |
} |
|
806 |
String text = messager.getText("main.doclet_class_not_found", userDocletName); |
|
807 |
throw new ToolException(CMDERR, text, cnfe); |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
808 |
} |
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
809 |
} |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
810 |
|
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
811 |
// Step 5: we don't have a doclet specified, do we have taglets ? |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
812 |
if (!userTagletNames.isEmpty() && hasOldTaglet(userTagletNames, userTagletPath)) { |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
813 |
// found a bogey, return the old doclet |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
814 |
return OldStdDoclet; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
815 |
} |
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
816 |
|
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
817 |
// finally |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
818 |
return StdDoclet; |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
819 |
} |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
820 |
|
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
821 |
/* |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
822 |
* This method returns true iff it finds a legacy taglet, but for |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
823 |
* all other conditions including errors it returns false, allowing |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
824 |
* nature to take its own course. |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
825 |
*/ |
38617 | 826 |
@SuppressWarnings("deprecation") |
41451 | 827 |
private boolean hasOldTaglet(List<String> tagletNames, List<File> tagletPaths) throws ToolException { |
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
828 |
if (!fileManager.hasLocation(TAGLET_PATH)) { |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
829 |
try { |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
830 |
((StandardJavaFileManager) fileManager).setLocation(TAGLET_PATH, tagletPaths); |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
831 |
} catch (IOException ioe) { |
41451 | 832 |
String text = messager.getText("main.doclet_could_not_set_location", tagletPaths); |
833 |
throw new ToolException(CMDERR, text, ioe); |
|
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
834 |
} |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
835 |
} |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
836 |
ClassLoader cl = fileManager.getClassLoader(TAGLET_PATH); |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
837 |
if (cl == null) { |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
838 |
// no classloader found! |
41451 | 839 |
String text = messager.getText("main.doclet_no_classloader_found", tagletNames.get(0)); |
840 |
throw new ToolException(CMDERR, text); |
|
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
841 |
} |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
842 |
for (String tagletName : tagletNames) { |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
843 |
try { |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
844 |
Class<?> klass = cl.loadClass(tagletName); |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
845 |
if (com.sun.tools.doclets.Taglet.class.isAssignableFrom(klass)) { |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
846 |
return true; |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
847 |
} |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
848 |
} catch (ClassNotFoundException cnfe) { |
41451 | 849 |
String text = messager.getText("main.doclet_class_not_found", tagletName); |
850 |
throw new ToolException(CMDERR, text, cnfe); |
|
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
851 |
} |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
852 |
} |
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
853 |
return false; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
854 |
} |
10 | 855 |
|
41451 | 856 |
private void parseArgs(List<String> args, List<String> javaNames) throws ToolException, |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
857 |
OptionException, com.sun.tools.javac.main.Option.InvalidValueException { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
858 |
for (int i = 0 ; i < args.size() ; i++) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
859 |
String arg = args.get(i); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
860 |
ToolOption o = ToolOption.get(arg); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
861 |
if (o != null) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
862 |
// handle a doclet argument that may be needed however |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
863 |
// don't increment the index, and allow the tool to consume args |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
864 |
handleDocletOptions(i, args, true); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
865 |
if (o.hasArg) { |
41252
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
866 |
if (arg.startsWith("--") && arg.contains("=")) { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
867 |
o.process(this, arg.substring(arg.indexOf('=') + 1)); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
868 |
} else { |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
869 |
checkOneArg(args, i++); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
870 |
o.process(this, args.get(i)); |
058d83c9b1c7
8166144: New javadoc options don't conform to JEP 293 (GNU style options)
jjg
parents:
40508
diff
changeset
|
871 |
} |
37393
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
872 |
} else if (o.hasSuffix) { |
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
873 |
o.process(this, arg); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
874 |
} else { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
875 |
o.process(this); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
876 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
877 |
} else if (arg.startsWith("-XD")) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
878 |
// hidden javac options |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
879 |
String s = arg.substring("-XD".length()); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
880 |
int eq = s.indexOf('='); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
881 |
String key = (eq < 0) ? s : s.substring(0, eq); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
882 |
String value = (eq < 0) ? s : s.substring(eq+1); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
883 |
compOpts.put(key, value); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
884 |
} else if (arg.startsWith("-")) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
885 |
i = handleDocletOptions(i, args, false); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
886 |
} else { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
887 |
javaNames.add(arg); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
888 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
889 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
890 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
891 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
892 |
private <T> boolean isEmpty(Iterable<T> iter) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
893 |
return !iter.iterator().hasNext(); |
10 | 894 |
} |
895 |
||
896 |
/** |
|
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
897 |
* Check the one arg option. |
10 | 898 |
* Error and exit if one argument is not provided. |
899 |
*/ |
|
41451 | 900 |
private void checkOneArg(List<String> args, int index) throws OptionException { |
40508
74ef30d16fb9
8159305: Enhance the javadoc tool to support module related options
ksrini
parents:
40308
diff
changeset
|
901 |
if ((index + 1) >= args.size() || args.get(index + 1).startsWith("-d")) { |
41451 | 902 |
String text = messager.getText("main.requires_argument", args.get(index)); |
903 |
throw new OptionException(CMDERR, this::usage, text); |
|
10 | 904 |
} |
905 |
} |
|
906 |
||
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
907 |
void error(String key, Object... args) { |
41451 | 908 |
messager.printErrorUsingKey(key, args); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
909 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
910 |
|
37750
d213951c811b
8154482: javadoc tool must support legacy doclet and taglet
ksrini
parents:
37393
diff
changeset
|
911 |
void warn(String key, Object... args) { |
41451 | 912 |
messager.printWarningUsingKey(key, args); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
913 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
914 |
|
10 | 915 |
/** |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
916 |
* Get the locale if specified on the command line |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
917 |
* else return null and if locale option is not used |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
918 |
* then return default locale. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
919 |
*/ |
41451 | 920 |
private Locale getLocale(String localeName) throws ToolException { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
921 |
Locale userlocale = null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
922 |
if (localeName == null || localeName.isEmpty()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
923 |
return Locale.getDefault(); |
10 | 924 |
} |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
925 |
int firstuscore = localeName.indexOf('_'); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
926 |
int seconduscore = -1; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
927 |
String language = null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
928 |
String country = null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
929 |
String variant = null; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
930 |
if (firstuscore == 2) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
931 |
language = localeName.substring(0, firstuscore); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
932 |
seconduscore = localeName.indexOf('_', firstuscore + 1); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
933 |
if (seconduscore > 0) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
934 |
if (seconduscore != firstuscore + 3 |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
935 |
|| localeName.length() <= seconduscore + 1) { |
41451 | 936 |
String text = messager.getText("main.malformed_locale_name", localeName); |
937 |
throw new ToolException(CMDERR, text); |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
938 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
939 |
country = localeName.substring(firstuscore + 1, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
940 |
seconduscore); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
941 |
variant = localeName.substring(seconduscore + 1); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
942 |
} else if (localeName.length() == firstuscore + 3) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
943 |
country = localeName.substring(firstuscore + 1); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
944 |
} else { |
41451 | 945 |
String text = messager.getText("main.malformed_locale_name", localeName); |
946 |
throw new ToolException(CMDERR, text); |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
947 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
948 |
} else if (firstuscore == -1 && localeName.length() == 2) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
949 |
language = localeName; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
950 |
} else { |
41451 | 951 |
String text = messager.getText("main.malformed_locale_name", localeName); |
952 |
throw new ToolException(CMDERR, text); |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
953 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
954 |
userlocale = searchLocale(language, country, variant); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
955 |
if (userlocale == null) { |
41451 | 956 |
String text = messager.getText("main.illegal_locale_name", localeName); |
957 |
throw new ToolException(CMDERR, text); |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
958 |
} else { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
959 |
return userlocale; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
960 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
961 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
962 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
963 |
/** |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
964 |
* Search the locale for specified language, specified country and |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
965 |
* specified variant. |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
966 |
*/ |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
967 |
private Locale searchLocale(String language, String country, |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
968 |
String variant) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
969 |
for (Locale loc : Locale.getAvailableLocales()) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
970 |
if (loc.getLanguage().equals(language) && |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
971 |
(country == null || loc.getCountry().equals(country)) && |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
972 |
(variant == null || loc.getVariant().equals(variant))) { |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
973 |
return loc; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
974 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
975 |
} |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31936
diff
changeset
|
976 |
return null; |
10 | 977 |
} |
37393
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
978 |
|
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
979 |
@Override |
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
980 |
OptionHelper getOptionHelper() { |
42260
2b4da2bf6660
8169676: boolean result of Option.process is often ignored
jjg
parents:
41990
diff
changeset
|
981 |
return new GrumpyHelper(messager) { |
37393
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
982 |
@Override |
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
983 |
public String get(com.sun.tools.javac.main.Option option) { |
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
984 |
return compOpts.get(option); |
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
985 |
} |
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
986 |
|
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
987 |
@Override |
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
988 |
public void put(String name, String value) { |
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
989 |
compOpts.put(name, value); |
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
990 |
} |
41990
ffaf4e59538a
8166379: IAE while invoking javadoc with --patch-module
ksrini
parents:
41451
diff
changeset
|
991 |
|
ffaf4e59538a
8166379: IAE while invoking javadoc with --patch-module
ksrini
parents:
41451
diff
changeset
|
992 |
@Override |
ffaf4e59538a
8166379: IAE while invoking javadoc with --patch-module
ksrini
parents:
41451
diff
changeset
|
993 |
public void remove(String name) { |
ffaf4e59538a
8166379: IAE while invoking javadoc with --patch-module
ksrini
parents:
41451
diff
changeset
|
994 |
compOpts.remove(name); |
ffaf4e59538a
8166379: IAE while invoking javadoc with --patch-module
ksrini
parents:
41451
diff
changeset
|
995 |
} |
ffaf4e59538a
8166379: IAE while invoking javadoc with --patch-module
ksrini
parents:
41451
diff
changeset
|
996 |
|
ffaf4e59538a
8166379: IAE while invoking javadoc with --patch-module
ksrini
parents:
41451
diff
changeset
|
997 |
@Override |
ffaf4e59538a
8166379: IAE while invoking javadoc with --patch-module
ksrini
parents:
41451
diff
changeset
|
998 |
public boolean handleFileManagerOption(com.sun.tools.javac.main.Option option, String value) { |
ffaf4e59538a
8166379: IAE while invoking javadoc with --patch-module
ksrini
parents:
41451
diff
changeset
|
999 |
fileManagerOpts.put(option, value); |
ffaf4e59538a
8166379: IAE while invoking javadoc with --patch-module
ksrini
parents:
41451
diff
changeset
|
1000 |
return true; |
ffaf4e59538a
8166379: IAE while invoking javadoc with --patch-module
ksrini
parents:
41451
diff
changeset
|
1001 |
} |
37393
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
1002 |
}; |
a9ba8bd6697b
8152818: Javadoc must support module options supported by javac.
ksrini
parents:
36526
diff
changeset
|
1003 |
} |
41451 | 1004 |
|
1005 |
@Override |
|
1006 |
String getLocalizedMessage(String msg, Object... args) { |
|
1007 |
return messager.getText(msg, args); |
|
1008 |
} |
|
10 | 1009 |
} |