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