27
28 import java.net.*;
29 import java.util.*;
30 import java.util.stream.Collectors;
31
32 import javax.lang.model.element.Element;
33 import javax.lang.model.element.PackageElement;
34 import javax.lang.model.element.TypeElement;
35 import javax.tools.JavaFileManager;
36 import javax.tools.JavaFileObject;
37 import javax.tools.StandardJavaFileManager;
38
39 import com.sun.source.util.DocTreePath;
40 import com.sun.tools.doclint.DocLint;
41
42 import jdk.javadoc.doclet.Doclet;
43 import jdk.javadoc.doclet.DocletEnvironment;
44 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
45 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
46 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlVersion;
47 import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
48 import jdk.javadoc.internal.doclets.toolkit.Content;
49 import jdk.javadoc.internal.doclets.toolkit.DocletException;
50 import jdk.javadoc.internal.doclets.toolkit.Messages;
51 import jdk.javadoc.internal.doclets.toolkit.Resources;
52 import jdk.javadoc.internal.doclets.toolkit.WriterFactory;
53 import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
54 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
55 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
56 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
57
58 import static javax.tools.Diagnostic.Kind.*;
59
60 /**
61 * Configure the output based on the command line options.
62 * <p>
63 * Also determine the length of the command line option. For example,
64 * for a option "-header" there will be a string argument associated, then the
65 * the length of option "-header" is two. But for option "-nohelp" no argument
66 * is needed so it's length is 1.
222
223 /**
224 * The TypeElement for the class file getting generated.
225 */
226 public TypeElement currentTypeElement = null; // Set this TypeElement in the ClassWriter.
227
228 protected List<SearchIndexItem> memberSearchIndex = new ArrayList<>();
229
230 protected List<SearchIndexItem> moduleSearchIndex = new ArrayList<>();
231
232 protected List<SearchIndexItem> packageSearchIndex = new ArrayList<>();
233
234 protected SortedSet<SearchIndexItem> tagSearchIndex = new TreeSet<>(makeSearchTagComparator());
235
236 protected List<SearchIndexItem> typeSearchIndex = new ArrayList<>();
237
238 protected Map<Character,List<SearchIndexItem>> tagSearchIndexMap = new HashMap<>();
239
240 protected Set<Character> tagSearchIndexKeys;
241
242 protected Contents contents;
243
244 protected Messages messages;
245
246 /**
247 * Constructor..
248 */
249 public HtmlConfiguration(Doclet doclet) {
250 super(doclet);
251 resources = new Resources(this,
252 BaseConfiguration.sharedResourceBundleName,
253 "jdk.javadoc.internal.doclets.formats.html.resources.standard");
254
255 messages = new Messages(this);
256 contents = new Contents(this);
257
258 String v;
259 try {
260 ResourceBundle rb = ResourceBundle.getBundle(versionBundleName, getLocale());
261 try {
262 v = rb.getString("release");
263 } catch (MissingResourceException e) {
264 v = defaultDocletVersion;
336
337 @Override
338 public boolean finishOptionSettings() {
339 if (!validateOptions()) {
340 return false;
341 }
342 if (!getSpecifiedTypeElements().isEmpty()) {
343 Map<String, PackageElement> map = new HashMap<>();
344 PackageElement pkg;
345 for (TypeElement aClass : getIncludedTypeElements()) {
346 pkg = utils.containingPackage(aClass);
347 if (!map.containsKey(utils.getPackageName(pkg))) {
348 map.put(utils.getPackageName(pkg), pkg);
349 }
350 }
351 }
352 setCreateOverview();
353 setTopFile(docEnv);
354 workArounds.initDocLint(doclintOpts.values(), tagletManager.getCustomTagNames(),
355 Utils.toLowerCase(htmlVersion.name()));
356 return true;
357 }
358
359 /**
360 * Return true if the generated output is HTML5.
361 */
362 public boolean isOutputHtml5() {
363 return htmlVersion == HtmlVersion.HTML5;
364 }
365
366 /**
367 * Return true if the tag is allowed for this specific version of HTML.
368 */
369 public boolean allowTag(HtmlTag htmlTag) {
370 return htmlTag.allowTag(this.htmlVersion);
371 }
372
373 public Comparator<SearchIndexItem> makeSearchTagComparator() {
374 return (SearchIndexItem sii1, SearchIndexItem sii2) -> {
375 int result = (sii1.getLabel()).compareTo(sii2.getLabel());
|
27
28 import java.net.*;
29 import java.util.*;
30 import java.util.stream.Collectors;
31
32 import javax.lang.model.element.Element;
33 import javax.lang.model.element.PackageElement;
34 import javax.lang.model.element.TypeElement;
35 import javax.tools.JavaFileManager;
36 import javax.tools.JavaFileObject;
37 import javax.tools.StandardJavaFileManager;
38
39 import com.sun.source.util.DocTreePath;
40 import com.sun.tools.doclint.DocLint;
41
42 import jdk.javadoc.doclet.Doclet;
43 import jdk.javadoc.doclet.DocletEnvironment;
44 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
45 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
46 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlVersion;
47 import jdk.javadoc.internal.doclets.formats.html.markup.Links;
48 import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
49 import jdk.javadoc.internal.doclets.toolkit.Content;
50 import jdk.javadoc.internal.doclets.toolkit.DocletException;
51 import jdk.javadoc.internal.doclets.toolkit.Messages;
52 import jdk.javadoc.internal.doclets.toolkit.Resources;
53 import jdk.javadoc.internal.doclets.toolkit.WriterFactory;
54 import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
55 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
56 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
57 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
58
59 import static javax.tools.Diagnostic.Kind.*;
60
61 /**
62 * Configure the output based on the command line options.
63 * <p>
64 * Also determine the length of the command line option. For example,
65 * for a option "-header" there will be a string argument associated, then the
66 * the length of option "-header" is two. But for option "-nohelp" no argument
67 * is needed so it's length is 1.
223
224 /**
225 * The TypeElement for the class file getting generated.
226 */
227 public TypeElement currentTypeElement = null; // Set this TypeElement in the ClassWriter.
228
229 protected List<SearchIndexItem> memberSearchIndex = new ArrayList<>();
230
231 protected List<SearchIndexItem> moduleSearchIndex = new ArrayList<>();
232
233 protected List<SearchIndexItem> packageSearchIndex = new ArrayList<>();
234
235 protected SortedSet<SearchIndexItem> tagSearchIndex = new TreeSet<>(makeSearchTagComparator());
236
237 protected List<SearchIndexItem> typeSearchIndex = new ArrayList<>();
238
239 protected Map<Character,List<SearchIndexItem>> tagSearchIndexMap = new HashMap<>();
240
241 protected Set<Character> tagSearchIndexKeys;
242
243 protected final Contents contents;
244
245 protected final Messages messages;
246
247 protected Links links;
248
249 /**
250 * Constructor..
251 */
252 public HtmlConfiguration(Doclet doclet) {
253 super(doclet);
254 resources = new Resources(this,
255 BaseConfiguration.sharedResourceBundleName,
256 "jdk.javadoc.internal.doclets.formats.html.resources.standard");
257
258 messages = new Messages(this);
259 contents = new Contents(this);
260
261 String v;
262 try {
263 ResourceBundle rb = ResourceBundle.getBundle(versionBundleName, getLocale());
264 try {
265 v = rb.getString("release");
266 } catch (MissingResourceException e) {
267 v = defaultDocletVersion;
339
340 @Override
341 public boolean finishOptionSettings() {
342 if (!validateOptions()) {
343 return false;
344 }
345 if (!getSpecifiedTypeElements().isEmpty()) {
346 Map<String, PackageElement> map = new HashMap<>();
347 PackageElement pkg;
348 for (TypeElement aClass : getIncludedTypeElements()) {
349 pkg = utils.containingPackage(aClass);
350 if (!map.containsKey(utils.getPackageName(pkg))) {
351 map.put(utils.getPackageName(pkg), pkg);
352 }
353 }
354 }
355 setCreateOverview();
356 setTopFile(docEnv);
357 workArounds.initDocLint(doclintOpts.values(), tagletManager.getCustomTagNames(),
358 Utils.toLowerCase(htmlVersion.name()));
359 links = new Links(htmlVersion);
360 return true;
361 }
362
363 /**
364 * Return true if the generated output is HTML5.
365 */
366 public boolean isOutputHtml5() {
367 return htmlVersion == HtmlVersion.HTML5;
368 }
369
370 /**
371 * Return true if the tag is allowed for this specific version of HTML.
372 */
373 public boolean allowTag(HtmlTag htmlTag) {
374 return htmlTag.allowTag(this.htmlVersion);
375 }
376
377 public Comparator<SearchIndexItem> makeSearchTagComparator() {
378 return (SearchIndexItem sii1, SearchIndexItem sii2) -> {
379 int result = (sii1.getLabel()).compareTo(sii2.getLabel());
|