8238969: Miscellaneous cleanup
Reviewed-by: jjg
This commit is contained in:
parent
36cd7bdb7f
commit
56282f7119
src/jdk.javadoc/share/classes/jdk/javadoc/internal
api
doclets
formats/html
AbstractExecutableMemberWriter.javaAbstractMemberWriter.javaAbstractTreeWriter.javaAnnotationTypeFieldWriterImpl.javaClassWriterImpl.javaHtmlConfiguration.javaHtmlDocletWriter.javaLinkFactoryImpl.javaModuleWriterImpl.javaSerializedFormWriterImpl.javaSourceToHTMLConverter.javaSubWriterHolderWriter.javaTagletWriterImpl.java
markup
toolkit
tool
@ -29,7 +29,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.tools.DocumentationTool.DocumentationTask;
|
||||
@ -54,14 +53,17 @@ public class JavadocTaskImpl implements DocumentationTask {
|
||||
private final AtomicBoolean used = new AtomicBoolean();
|
||||
|
||||
private final Context context;
|
||||
private Class<?> docletClass;
|
||||
private Iterable<String> options;
|
||||
private Iterable<? extends JavaFileObject> fileObjects;
|
||||
private final Class<?> docletClass;
|
||||
private final Iterable<String> options;
|
||||
private final Iterable<? extends JavaFileObject> fileObjects;
|
||||
private Locale locale;
|
||||
private List<String> addModules = new ArrayList<>();
|
||||
private final List<String> addModules = new ArrayList<>();
|
||||
|
||||
public JavadocTaskImpl(Context context, Class<?> docletClass,
|
||||
Iterable<String> options, Iterable<? extends JavaFileObject> fileObjects) {
|
||||
public JavadocTaskImpl(Context context,
|
||||
Class<?> docletClass,
|
||||
Iterable<String> options,
|
||||
Iterable<? extends JavaFileObject> fileObjects)
|
||||
{
|
||||
this.context = context;
|
||||
this.docletClass = docletClass;
|
||||
|
||||
@ -74,16 +76,18 @@ public class JavadocTaskImpl implements DocumentationTask {
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
if (used.get())
|
||||
if (used.get()) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addModules(Iterable<String> moduleNames) {
|
||||
nullCheck(moduleNames);
|
||||
if (used.get())
|
||||
if (used.get()) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
for (String name : moduleNames) {
|
||||
addModules.add(name);
|
||||
}
|
||||
@ -91,17 +95,16 @@ public class JavadocTaskImpl implements DocumentationTask {
|
||||
|
||||
@Override
|
||||
public Boolean call() {
|
||||
if (!used.getAndSet(true)) {
|
||||
initContext();
|
||||
Start jdoc = new Start(context);
|
||||
try {
|
||||
return jdoc.begin(docletClass, options, fileObjects);
|
||||
} catch (ClientCodeException e) {
|
||||
throw new RuntimeException(e.getCause());
|
||||
}
|
||||
} else {
|
||||
if (used.getAndSet(true)) {
|
||||
throw new IllegalStateException("multiple calls to method 'call'");
|
||||
}
|
||||
initContext();
|
||||
Start jdoc = new Start(context);
|
||||
try {
|
||||
return jdoc.begin(docletClass, options, fileObjects);
|
||||
} catch (ClientCodeException e) {
|
||||
throw new RuntimeException(e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
private void initContext() {
|
||||
@ -116,7 +119,7 @@ public class JavadocTaskImpl implements DocumentationTask {
|
||||
}
|
||||
|
||||
private static <T> Iterable<T> nullCheck(Iterable<T> items) {
|
||||
for (T item: items) {
|
||||
for (T item : items) {
|
||||
if (item == null)
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
@ -75,7 +75,8 @@ public class JavadocTool implements DocumentationTool {
|
||||
DiagnosticListener<? super JavaFileObject> diagnosticListener,
|
||||
Class<?> docletClass,
|
||||
Iterable<String> options,
|
||||
Iterable<? extends JavaFileObject> compilationUnits) {
|
||||
Iterable<? extends JavaFileObject> compilationUnits)
|
||||
{
|
||||
Context context = new Context();
|
||||
return getTask(out, fileManager, diagnosticListener,
|
||||
docletClass, options, compilationUnits, context);
|
||||
|
@ -257,7 +257,7 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite
|
||||
if (!exceptions.isEmpty()) {
|
||||
Content link = writer.getLink(new LinkInfoImpl(configuration, MEMBER, exceptions.get(0)));
|
||||
htmltree.add(link);
|
||||
for(int i = 1; i < exceptions.size(); i++) {
|
||||
for (int i = 1; i < exceptions.size(); i++) {
|
||||
htmltree.add(",");
|
||||
htmltree.add(DocletConstants.NL);
|
||||
Content exceptionLink = writer.getLink(new LinkInfoImpl(configuration, MEMBER,
|
||||
|
15
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java
15
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java
@ -140,8 +140,6 @@ public abstract class AbstractMemberWriter implements MemberSummaryWriter {
|
||||
*/
|
||||
protected abstract Table createSummaryTable();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add inherited summary label for the member.
|
||||
*
|
||||
@ -198,17 +196,6 @@ public abstract class AbstractMemberWriter implements MemberSummaryWriter {
|
||||
*/
|
||||
protected abstract Content getDeprecatedLink(Element member);
|
||||
|
||||
protected CharSequence makeSpace(int len) {
|
||||
if (len <= 0) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(len);
|
||||
for (int i = 0; i < len; i++) {
|
||||
sb.append(' ');
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the modifier and type for the member in the member summary.
|
||||
*
|
||||
@ -704,7 +691,7 @@ public abstract class AbstractMemberWriter implements MemberSummaryWriter {
|
||||
|
||||
// Exceptions
|
||||
if (exceptions != null && !exceptions.isEmpty()) {
|
||||
CharSequence indent = makeSpace(indentSize + 1 - 7);
|
||||
CharSequence indent = " ".repeat(Math.max(0, indentSize + 1 - 7));
|
||||
htmltree.add(DocletConstants.NL);
|
||||
htmltree.add(indent);
|
||||
htmltree.add("throws ");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -131,12 +131,12 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter {
|
||||
* @param typeElement the TypeElement under consideration
|
||||
* @param contentTree the content tree to which the information will be added
|
||||
*/
|
||||
protected void addExtendsImplements(TypeElement parent, TypeElement typeElement,
|
||||
Content contentTree) {
|
||||
protected void addExtendsImplements(TypeElement parent,
|
||||
TypeElement typeElement,
|
||||
Content contentTree)
|
||||
{
|
||||
SortedSet<TypeElement> interfaces = new TreeSet<>(utils.makeGeneralPurposeComparator());
|
||||
typeElement.getInterfaces().stream().forEach((t) -> {
|
||||
interfaces.add(utils.asTypeElement(t));
|
||||
});
|
||||
typeElement.getInterfaces().forEach(t -> interfaces.add(utils.asTypeElement(t)));
|
||||
if (interfaces.size() > (utils.isInterface(typeElement) ? 1 : 0)) {
|
||||
boolean isFirst = true;
|
||||
for (TypeElement intf : interfaces) {
|
||||
|
@ -64,7 +64,7 @@ public class AnnotationTypeFieldWriterImpl extends AbstractMemberWriter
|
||||
|
||||
@Override
|
||||
public Content getMemberSummaryHeader(TypeElement typeElement,
|
||||
Content memberSummaryTree) {
|
||||
Content memberSummaryTree) {
|
||||
memberSummaryTree.add(
|
||||
MarkerComments.START_OF_ANNOTATION_TYPE_FIELD_SUMMARY);
|
||||
Content memberTree = new ContentBuilder();
|
||||
|
@ -80,10 +80,10 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite
|
||||
"org.omg.CORBA.Object");
|
||||
|
||||
private static final Set<String> suppressImplementingSet
|
||||
= Set.of( "java.lang.Cloneable",
|
||||
"java.lang.constant.Constable",
|
||||
"java.lang.constant.ConstantDesc",
|
||||
"java.io.Serializable");
|
||||
= Set.of("java.lang.Cloneable",
|
||||
"java.lang.constant.Constable",
|
||||
"java.lang.constant.ConstantDesc",
|
||||
"java.io.Serializable");
|
||||
|
||||
protected final TypeElement typeElement;
|
||||
|
||||
@ -257,7 +257,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite
|
||||
String sep = "";
|
||||
for (RecordComponentElement e : typeElement.getRecordComponents()) {
|
||||
content.add(sep);
|
||||
getAnnotations(e.getAnnotationMirrors(), false).stream()
|
||||
getAnnotations(e.getAnnotationMirrors(), false)
|
||||
.forEach(a -> { content.add(a); content.add(" "); });
|
||||
Content link = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.RECORD_COMPONENT,
|
||||
e.asType()));
|
||||
|
@ -101,7 +101,7 @@ public class HtmlConfiguration extends BaseConfiguration {
|
||||
|
||||
protected SortedSet<SearchIndexItem> typeSearchIndex;
|
||||
|
||||
protected Map<Character,List<SearchIndexItem>> tagSearchIndexMap = new HashMap<>();
|
||||
protected Map<Character, List<SearchIndexItem>> tagSearchIndexMap = new HashMap<>();
|
||||
|
||||
protected Set<Character> tagSearchIndexKeys;
|
||||
|
||||
@ -329,7 +329,8 @@ public class HtmlConfiguration extends BaseConfiguration {
|
||||
|
||||
public List<DocPath> getAdditionalStylesheets() {
|
||||
return options.additionalStylesheets().stream()
|
||||
.map(ssf -> DocFile.createFileForInput(this, ssf)).map(file -> DocPath.create(file.getName()))
|
||||
.map(ssf -> DocFile.createFileForInput(this, ssf))
|
||||
.map(file -> DocPath.create(file.getName()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ public class HtmlDocletWriter {
|
||||
Map<String, Integer> indexAnchorTable = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Constructor to construct the HtmlStandardWriter object.
|
||||
* Creates an {@code HtmlDocletWriter}.
|
||||
*
|
||||
* @param configuration the configuration for this doclet
|
||||
* @param path the file to be generated.
|
||||
@ -1324,8 +1324,11 @@ public class HtmlDocletWriter {
|
||||
* @param isFirstSentence true if text is first sentence
|
||||
* @return a Content object
|
||||
*/
|
||||
public Content commentTagsToContent(DocTree holderTag, Element element,
|
||||
List<? extends DocTree> tags, boolean isFirstSentence) {
|
||||
public Content commentTagsToContent(DocTree holderTag,
|
||||
Element element,
|
||||
List<? extends DocTree> tags,
|
||||
boolean isFirstSentence)
|
||||
{
|
||||
return commentTagsToContent(holderTag, element, tags, isFirstSentence, false);
|
||||
}
|
||||
|
||||
@ -1343,9 +1346,12 @@ public class HtmlDocletWriter {
|
||||
* @param inSummary if the comment tags are added into the summary section
|
||||
* @return a Content object
|
||||
*/
|
||||
public Content commentTagsToContent(DocTree holderTag, Element element,
|
||||
List<? extends DocTree> trees, boolean isFirstSentence, boolean inSummary) {
|
||||
|
||||
public Content commentTagsToContent(DocTree holderTag,
|
||||
Element element,
|
||||
List<? extends DocTree> trees,
|
||||
boolean isFirstSentence,
|
||||
boolean inSummary)
|
||||
{
|
||||
final Content result = new ContentBuilder() {
|
||||
@Override
|
||||
public void add(CharSequence text) {
|
||||
@ -1409,7 +1415,7 @@ public class HtmlDocletWriter {
|
||||
quote = "\"";
|
||||
break;
|
||||
case SINGLE:
|
||||
quote = "\'";
|
||||
quote = "'";
|
||||
break;
|
||||
default:
|
||||
quote = "";
|
||||
|
@ -131,17 +131,13 @@ public class LinkFactoryImpl extends LinkFactory {
|
||||
? utils.getComponentType(linkInfo.type)
|
||||
: null;
|
||||
if (linkInfo.executableElement != null) {
|
||||
linkInfo.executableElement.getTypeParameters().stream().forEach((t) -> {
|
||||
vars.add(t.asType());
|
||||
});
|
||||
linkInfo.executableElement.getTypeParameters().forEach(t -> vars.add(t.asType()));
|
||||
} else if (linkInfo.type != null && utils.isDeclaredType(linkInfo.type)) {
|
||||
((DeclaredType)linkInfo.type).getTypeArguments().stream().forEach(vars::add);
|
||||
vars.addAll(((DeclaredType) linkInfo.type).getTypeArguments());
|
||||
} else if (ctype != null && utils.isDeclaredType(ctype)) {
|
||||
((DeclaredType)ctype).getTypeArguments().stream().forEach(vars::add);
|
||||
vars.addAll(((DeclaredType) ctype).getTypeArguments());
|
||||
} else if (linkInfo.typeElement != null) {
|
||||
linkInfo.typeElement.getTypeParameters().stream().forEach((t) -> {
|
||||
vars.add(t.asType());
|
||||
});
|
||||
linkInfo.typeElement.getTypeParameters().forEach(t -> vars.add(t.asType()));
|
||||
} else {
|
||||
// Nothing to document.
|
||||
return links;
|
||||
|
@ -258,18 +258,18 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
|
||||
indirectModules.put(module, new StringContent(mod));
|
||||
}
|
||||
});
|
||||
(ElementFilter.requiresIn(mdle.getDirectives())).forEach((directive) -> {
|
||||
ElementFilter.requiresIn(mdle.getDirectives()).forEach(directive -> {
|
||||
ModuleElement m = directive.getDependency();
|
||||
if (shouldDocument(m)) {
|
||||
if (moduleMode == ModuleMode.ALL || directive.isTransitive()) {
|
||||
requires.put(m, new StringContent(utils.getModifiers(directive)));
|
||||
} else {
|
||||
} else {
|
||||
// For api mode, just keep the public requires in dependentModules for display of
|
||||
// indirect packages in the "Packages" section.
|
||||
dependentModules.remove(m);
|
||||
}
|
||||
indirectModules.remove(m);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Get all packages if module is open or if displaying concealed modules
|
||||
@ -321,50 +321,50 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
|
||||
// Get all the exported and opened packages, for the transitive closure of the module, to be displayed in
|
||||
// the indirect packages tables.
|
||||
dependentModules.forEach((module, mod) -> {
|
||||
SortedSet<PackageElement> exportPkgList = new TreeSet<>(utils.makePackageComparator());
|
||||
(ElementFilter.exportsIn(module.getDirectives())).forEach((directive) -> {
|
||||
SortedSet<PackageElement> exportedPackages = new TreeSet<>(utils.makePackageComparator());
|
||||
ElementFilter.exportsIn(module.getDirectives()).forEach(directive -> {
|
||||
PackageElement pkg = directive.getPackage();
|
||||
if (shouldDocument(pkg)) {
|
||||
// Qualified exports are not displayed in API mode
|
||||
if (moduleMode == ModuleMode.ALL || directive.getTargetModules() == null) {
|
||||
exportPkgList.add(pkg);
|
||||
exportedPackages.add(pkg);
|
||||
}
|
||||
}
|
||||
});
|
||||
// If none of the indirect modules have exported packages to be displayed, we should not be
|
||||
// displaying the table and so it should not be added to the map.
|
||||
if (!exportPkgList.isEmpty()) {
|
||||
indirectPackages.put(module, exportPkgList);
|
||||
if (!exportedPackages.isEmpty()) {
|
||||
indirectPackages.put(module, exportedPackages);
|
||||
}
|
||||
SortedSet<PackageElement> openPkgList = new TreeSet<>(utils.makePackageComparator());
|
||||
SortedSet<PackageElement> openPackages = new TreeSet<>(utils.makePackageComparator());
|
||||
if (module.isOpen()) {
|
||||
openPkgList.addAll(utils.getModulePackageMap().getOrDefault(module, Collections.emptySet()));
|
||||
openPackages.addAll(utils.getModulePackageMap().getOrDefault(module, Collections.emptySet()));
|
||||
} else {
|
||||
(ElementFilter.opensIn(module.getDirectives())).forEach((directive) -> {
|
||||
ElementFilter.opensIn(module.getDirectives()).forEach(directive -> {
|
||||
PackageElement pkg = directive.getPackage();
|
||||
if (shouldDocument(pkg)) {
|
||||
// Qualified opens are not displayed in API mode
|
||||
if (moduleMode == ModuleMode.ALL || directive.getTargetModules() == null) {
|
||||
openPkgList.add(pkg);
|
||||
openPackages.add(pkg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// If none of the indirect modules have opened packages to be displayed, we should not be
|
||||
// displaying the table and so it should not be added to the map.
|
||||
if (!openPkgList.isEmpty()) {
|
||||
indirectOpenPackages.put(module, openPkgList);
|
||||
if (!openPackages.isEmpty()) {
|
||||
indirectOpenPackages.put(module, openPackages);
|
||||
}
|
||||
});
|
||||
// Get all the services listed as uses directive.
|
||||
(ElementFilter.usesIn(mdle.getDirectives())).forEach((directive) -> {
|
||||
ElementFilter.usesIn(mdle.getDirectives()).forEach(directive -> {
|
||||
TypeElement u = directive.getService();
|
||||
if (shouldDocument(u)) {
|
||||
uses.add(u);
|
||||
}
|
||||
});
|
||||
// Get all the services and implementations listed as provides directive.
|
||||
(ElementFilter.providesIn(mdle.getDirectives())).forEach((directive) -> {
|
||||
ElementFilter.providesIn(mdle.getDirectives()).forEach(directive -> {
|
||||
TypeElement u = directive.getService();
|
||||
if (shouldDocument(u)) {
|
||||
List<? extends TypeElement> implList = directive.getImplementations();
|
||||
@ -374,14 +374,14 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
|
||||
}
|
||||
});
|
||||
// Generate the map of all services listed using @provides, and the description.
|
||||
(utils.getBlockTags(mdle, DocTree.Kind.PROVIDES)).forEach((tree) -> {
|
||||
utils.getBlockTags(mdle, DocTree.Kind.PROVIDES).forEach(tree -> {
|
||||
TypeElement t = ch.getServiceType(tree);
|
||||
if (t != null) {
|
||||
providesTrees.put(t, commentTagsToContent(tree, mdle, ch.getDescription(tree), false, true));
|
||||
}
|
||||
});
|
||||
// Generate the map of all services listed using @uses, and the description.
|
||||
(utils.getBlockTags(mdle, DocTree.Kind.USES)).forEach((tree) -> {
|
||||
utils.getBlockTags(mdle, DocTree.Kind.USES).forEach(tree -> {
|
||||
TypeElement t = ch.getServiceType(tree);
|
||||
if (t != null) {
|
||||
usesTrees.put(t, commentTagsToContent(tree, mdle, ch.getDescription(tree), false, true));
|
||||
@ -426,7 +426,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW
|
||||
private boolean displayServices(Set<TypeElement> typeElements,
|
||||
Map<TypeElement, Content> tagsMap) {
|
||||
return typeElements != null &&
|
||||
typeElements.stream().anyMatch((v) -> displayServiceDirective(v, tagsMap));
|
||||
typeElements.stream().anyMatch(v -> displayServiceDirective(v, tagsMap));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -198,8 +198,10 @@ public class SerializedFormWriterImpl extends SubWriterHolderWriter
|
||||
* content will be added
|
||||
*/
|
||||
@Override
|
||||
public void addSerialUIDInfo(String header, String serialUID,
|
||||
Content serialUidTree) {
|
||||
public void addSerialUIDInfo(String header,
|
||||
String serialUID,
|
||||
Content serialUidTree)
|
||||
{
|
||||
Content headerContent = new StringContent(header);
|
||||
serialUidTree.add(HtmlTree.DT(headerContent));
|
||||
Content serialContent = new StringContent(serialUID);
|
||||
@ -232,7 +234,8 @@ public class SerializedFormWriterImpl extends SubWriterHolderWriter
|
||||
|
||||
@Override
|
||||
public void addPackageSerializedTree(Content serializedSummariesTree,
|
||||
Content packageSerializedTree) {
|
||||
Content packageSerializedTree)
|
||||
{
|
||||
serializedSummariesTree.add(HtmlTree.LI(HtmlStyle.blockList, packageSerializedTree));
|
||||
}
|
||||
|
||||
|
17
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java
17
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java
@ -273,16 +273,13 @@ public class SourceToHTMLConverter {
|
||||
}
|
||||
|
||||
protected void addStylesheets(Content tree) {
|
||||
List<String> stylesheets = options.additionalStylesheets();
|
||||
if (!stylesheets.isEmpty()) {
|
||||
stylesheets.forEach((ssheet) -> {
|
||||
DocFile file = DocFile.createFileForInput(configuration, ssheet);
|
||||
DocPath ssheetPath = DocPath.create(file.getName());
|
||||
HtmlTree slink = HtmlTree.LINK("stylesheet", "text/css", relativePath.resolve(ssheetPath).getPath(),
|
||||
"Style");
|
||||
tree.add(slink);
|
||||
});
|
||||
}
|
||||
options.additionalStylesheets().forEach(css -> {
|
||||
DocFile file = DocFile.createFileForInput(configuration, css);
|
||||
DocPath cssPath = DocPath.create(file.getName());
|
||||
HtmlTree slink = HtmlTree.LINK("stylesheet", "text/css", relativePath.resolve(cssPath).getPath(),
|
||||
"Style");
|
||||
tree.add(slink);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
11
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java
11
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -162,9 +162,12 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
|
||||
* @param isFirst true if its the first link being documented
|
||||
* @param linksTree the content tree to which the summary will be added
|
||||
*/
|
||||
public void addInheritedMemberSummary(AbstractMemberWriter mw, TypeElement typeElement,
|
||||
Element member, boolean isFirst, Content linksTree) {
|
||||
if (! isFirst) {
|
||||
public void addInheritedMemberSummary(AbstractMemberWriter mw,
|
||||
TypeElement typeElement,
|
||||
Element member,
|
||||
boolean isFirst,
|
||||
Content linksTree) {
|
||||
if (!isFirst) {
|
||||
linksTree.add(", ");
|
||||
}
|
||||
mw.addInheritedSummaryLink(typeElement, member, linksTree);
|
||||
|
@ -300,7 +300,7 @@ public class TagletWriterImpl extends TagletWriter {
|
||||
|
||||
@Override
|
||||
protected Content systemPropertyTagOutput(Element element, DocTree tag) {
|
||||
SystemPropertyTree itt = (SystemPropertyTree)tag;
|
||||
SystemPropertyTree itt = (SystemPropertyTree) tag;
|
||||
String tagText = itt.getPropertyName().toString();
|
||||
return HtmlTree.CODE(createAnchorAndSearchIndex(element, tagText,
|
||||
resources.getText("doclet.System_Property"), true));
|
||||
@ -369,7 +369,10 @@ public class TagletWriterImpl extends TagletWriter {
|
||||
|
||||
@Override
|
||||
public Content commentTagsToOutput(DocTree holderTag,
|
||||
Element holder, List<? extends DocTree> tags, boolean isFirstSentence) {
|
||||
Element holder,
|
||||
List<? extends DocTree> tags,
|
||||
boolean isFirstSentence)
|
||||
{
|
||||
return htmlWriter.commentTagsToContent(holderTag, holder,
|
||||
tags, isFirstSentence, inSummary);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -38,7 +38,6 @@ import java.util.function.Predicate;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
|
||||
import jdk.javadoc.internal.doclets.formats.html.Contents;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
|
||||
/**
|
||||
@ -468,7 +467,7 @@ public class Table {
|
||||
thead.add(header.toContent());
|
||||
tableContent.add(thead);
|
||||
Content tbody = new HtmlTree(HtmlTag.TBODY);
|
||||
bodyRows.forEach(row -> tbody.add(row));
|
||||
bodyRows.forEach(tbody::add);
|
||||
tableContent.add(tbody);
|
||||
return tableContent;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -64,7 +64,7 @@ public class TableHeader {
|
||||
*/
|
||||
public TableHeader(Contents contents, String... colHeaderKeys) {
|
||||
this.cellContents = Arrays.stream(colHeaderKeys)
|
||||
.map((key) -> contents.getContent(key))
|
||||
.map(contents::getContent)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
@ -363,7 +363,7 @@ public abstract class BaseConfiguration {
|
||||
}
|
||||
typeElementCatalog = new TypeElementCatalog(includedTypeElements, this);
|
||||
initTagletManager(options.customTagStrs());
|
||||
options.groupPairs().stream().forEach((grp) -> {
|
||||
options.groupPairs().forEach(grp -> {
|
||||
if (showModules) {
|
||||
group.checkModuleGroups(grp.first, grp.second);
|
||||
} else {
|
||||
|
@ -35,6 +35,7 @@ import javax.lang.model.element.PackageElement;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.tools.FileObject;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface DocletElement extends Element {
|
||||
@ -65,12 +66,12 @@ public interface DocletElement extends Element {
|
||||
}
|
||||
|
||||
@Override
|
||||
default java.util.List<? extends Element> getEnclosedElements() {
|
||||
default List<? extends Element> getEnclosedElements() {
|
||||
throw new UnsupportedOperationException("Unsupported method");
|
||||
}
|
||||
|
||||
@Override
|
||||
default java.util.List<? extends AnnotationMirror> getAnnotationMirrors() {
|
||||
default List<? extends AnnotationMirror> getAnnotationMirrors() {
|
||||
throw new UnsupportedOperationException("Unsupported method");
|
||||
}
|
||||
|
||||
@ -92,13 +93,14 @@ public interface DocletElement extends Element {
|
||||
/**
|
||||
* Returns the anchoring package element, in the case of a
|
||||
* module element, this is the module's unnamed package.
|
||||
*
|
||||
* @return the anchor element.
|
||||
*/
|
||||
PackageElement getPackageElement();
|
||||
|
||||
/**
|
||||
* Returns the file object associated with this special
|
||||
* element such as overview.html, doc-file/foo.html.
|
||||
* element such as {@code overview.html}, {@code doc-files/foo.html}.
|
||||
* @return the file object
|
||||
*/
|
||||
FileObject getFileObject();
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
package jdk.javadoc.internal.doclets.toolkit;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.PackageElement;
|
||||
import javax.tools.FileObject;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -485,15 +485,17 @@ public abstract class MemberSummaryBuilder extends AbstractMemberBuilder {
|
||||
* @param memberSummaryTree the content tree to which the documentation will be added
|
||||
*/
|
||||
private void addSummary(MemberSummaryWriter writer,
|
||||
VisibleMemberTable.Kind kind, boolean showInheritedSummary,
|
||||
Content memberSummaryTree) {
|
||||
VisibleMemberTable.Kind kind,
|
||||
boolean showInheritedSummary,
|
||||
Content memberSummaryTree)
|
||||
{
|
||||
LinkedList<Content> summaryTreeList = new LinkedList<>();
|
||||
buildSummary(writer, kind, summaryTreeList);
|
||||
if (showInheritedSummary)
|
||||
buildInheritedSummary(writer, kind, summaryTreeList);
|
||||
if (!summaryTreeList.isEmpty()) {
|
||||
Content memberTree = writer.getMemberSummaryHeader(typeElement, memberSummaryTree);
|
||||
summaryTreeList.stream().forEach(memberTree::add);
|
||||
summaryTreeList.forEach(memberTree::add);
|
||||
writer.addMemberTree(memberSummaryTree, memberTree);
|
||||
}
|
||||
}
|
||||
|
@ -30,10 +30,10 @@ import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
@ -98,12 +98,12 @@ public class TagletManager {
|
||||
public static final char SIMPLE_TAGLET_OPT_SEPARATOR = ':';
|
||||
|
||||
/**
|
||||
* The map of all taglets.
|
||||
* All taglets, keyed by their {@link Taglet#getName() name}.
|
||||
*/
|
||||
private final LinkedHashMap<String,Taglet> allTaglets;
|
||||
private final LinkedHashMap<String, Taglet> allTaglets;
|
||||
|
||||
/**
|
||||
* Block (non-inline) taglets, grouped by Location
|
||||
* Block (non-inline) taglets, grouped by {@link Location location}.
|
||||
*/
|
||||
private Map<Location, List<Taglet>> blockTagletsByLocation;
|
||||
|
||||
@ -181,7 +181,8 @@ public class TagletManager {
|
||||
private final String tagletPath;
|
||||
|
||||
/**
|
||||
* Construct a new {@code TagletManager}.
|
||||
* Constructs a new {@code TagletManager}.
|
||||
*
|
||||
* @param configuration the configuration for this taglet manager
|
||||
*/
|
||||
public TagletManager(BaseConfiguration configuration) {
|
||||
@ -274,13 +275,11 @@ public class TagletManager {
|
||||
* @throws IOException if an error occurs while getting the service loader.
|
||||
*/
|
||||
public void loadTaglets(JavaFileManager fileManager) throws IOException {
|
||||
Iterable<? extends File> location = ((StandardJavaFileManager)fileManager).getLocation(TAGLET_PATH);
|
||||
Iterable<? extends File> location = ((StandardJavaFileManager) fileManager).getLocation(TAGLET_PATH);
|
||||
if (location != null && location.iterator().hasNext()) {
|
||||
ServiceLoader<jdk.javadoc.doclet.Taglet> serviceLoader =
|
||||
fileManager.getServiceLoader(TAGLET_PATH, jdk.javadoc.doclet.Taglet.class);
|
||||
Iterator<jdk.javadoc.doclet.Taglet> iterator = serviceLoader.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
jdk.javadoc.doclet.Taglet taglet = iterator.next();
|
||||
for (jdk.javadoc.doclet.Taglet taglet : serviceLoader) {
|
||||
registerTaglet(taglet);
|
||||
}
|
||||
}
|
||||
@ -366,8 +365,8 @@ public class TagletManager {
|
||||
if (name == null) {
|
||||
continue;
|
||||
}
|
||||
if (name.length() > 0 && name.charAt(0) == '@') {
|
||||
name = name.substring(1, name.length());
|
||||
if (!name.isEmpty() && name.charAt(0) == '@') {
|
||||
name = name.substring(1);
|
||||
}
|
||||
if (! (standardTags.contains(name) || allTaglets.containsKey(name))) {
|
||||
if (standardTagsLowercase.contains(Utils.toLowerCase(name))) {
|
||||
@ -555,7 +554,7 @@ public class TagletManager {
|
||||
return blockTagletsByLocation.get(Location.PACKAGE);
|
||||
case OTHER:
|
||||
if (e instanceof DocletElement) {
|
||||
DocletElement de = (DocletElement)e;
|
||||
DocletElement de = (DocletElement) e;
|
||||
switch (de.getSubKind()) {
|
||||
case DOCFILE:
|
||||
return blockTagletsByLocation.get(Location.PACKAGE);
|
||||
@ -707,7 +706,7 @@ public class TagletManager {
|
||||
}
|
||||
|
||||
private void printReportHelper(String noticeKey, Set<String> names) {
|
||||
if (names.size() > 0) {
|
||||
if (!names.isEmpty()) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (String name : names) {
|
||||
result.append(result.length() == 0 ? " " : ", ");
|
||||
@ -731,7 +730,6 @@ public class TagletManager {
|
||||
} else {
|
||||
return allTaglets.get(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -740,7 +738,7 @@ public class TagletManager {
|
||||
* a need for a corresponding update to the spec.
|
||||
*/
|
||||
private void showTaglets(PrintStream out) {
|
||||
Set<Taglet> taglets = new TreeSet<>((o1, o2) -> o1.getName().compareTo(o2.getName()));
|
||||
Set<Taglet> taglets = new TreeSet<>(Comparator.comparing(Taglet::getName));
|
||||
taglets.addAll(allTaglets.values());
|
||||
|
||||
for (Taglet t : taglets) {
|
||||
@ -755,7 +753,7 @@ public class TagletManager {
|
||||
+ format(t.inMethod(), "method") + " "
|
||||
+ format(t.inField(), "field") + " "
|
||||
+ format(t.isInlineTag(), "inline")+ " "
|
||||
+ format((t instanceof SimpleTaglet) && !((SimpleTaglet)t).enabled, "disabled"));
|
||||
+ format((t instanceof SimpleTaglet) && !((SimpleTaglet) t).enabled, "disabled"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -74,7 +74,7 @@ public abstract class TagletWriter {
|
||||
protected abstract Content codeTagOutput(Element element, DocTree tag);
|
||||
|
||||
/**
|
||||
* Return the output for a {@index...} tag.
|
||||
* Return the output for a {@code {@index...}} tag.
|
||||
*
|
||||
* @param tag the tag.
|
||||
* @return the output of the taglet.
|
||||
@ -233,8 +233,12 @@ public abstract class TagletWriter {
|
||||
* @param writer the writer that will generate the output strings.
|
||||
* @param output the output buffer to store the output in.
|
||||
*/
|
||||
public static void genTagOutput(TagletManager tagletManager, Element element,
|
||||
List<Taglet> taglets, TagletWriter writer, Content output) {
|
||||
public static void genTagOutput(TagletManager tagletManager,
|
||||
Element element,
|
||||
List<Taglet> taglets,
|
||||
TagletWriter writer,
|
||||
Content output)
|
||||
{
|
||||
Utils utils = writer.configuration().utils;
|
||||
tagletManager.checkTags(element, utils.getBlockTags(element), false);
|
||||
tagletManager.checkTags(element, utils.getFullBody(element), true);
|
||||
@ -284,14 +288,18 @@ public abstract class TagletWriter {
|
||||
* Given an inline tag, return its output.
|
||||
* @param holder
|
||||
* @param tagletManager The taglet manager for the current doclet.
|
||||
* @param holderTag The tag this holds this inline tag. Null if there
|
||||
* is no tag that holds it.
|
||||
* @param holderTag The tag that holds this inline tag, or {@code null} if
|
||||
* there is no tag that holds it.
|
||||
* @param inlineTag The inline tag to be documented.
|
||||
* @param tagletWriter The taglet writer to write the output.
|
||||
* @return The output of the inline tag.
|
||||
*/
|
||||
public static Content getInlineTagOutput(Element holder, TagletManager tagletManager,
|
||||
DocTree holderTag, DocTree inlineTag, TagletWriter tagletWriter) {
|
||||
public static Content getInlineTagOutput(Element holder,
|
||||
TagletManager tagletManager,
|
||||
DocTree holderTag,
|
||||
DocTree inlineTag,
|
||||
TagletWriter tagletWriter)
|
||||
{
|
||||
List<Taglet> definedTags = tagletManager.getInlineTaglets();
|
||||
CommentHelper ch = tagletWriter.configuration().utils.getCommentHelper(holder);
|
||||
final String inlineTagName = ch.getTagName(inlineTag);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -127,9 +127,9 @@ public class CommentHelper {
|
||||
case UNKNOWN_BLOCK_TAG:
|
||||
case USES:
|
||||
case VERSION:
|
||||
return ((BlockTagTree)dtree).getTagName();
|
||||
return ((BlockTagTree) dtree).getTagName();
|
||||
case UNKNOWN_INLINE_TAG:
|
||||
return ((InlineTagTree)dtree).getTagName();
|
||||
return ((InlineTagTree) dtree).getTagName();
|
||||
case ERRONEOUS:
|
||||
return "erroneous";
|
||||
default:
|
||||
@ -266,7 +266,7 @@ public class CommentHelper {
|
||||
}
|
||||
|
||||
node.getReference().accept(this, null);
|
||||
node.getLabel().forEach(dt -> dt.accept(this, null) );
|
||||
node.getLabel().forEach(dt -> dt.accept(this, null));
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -305,7 +305,7 @@ public class CommentHelper {
|
||||
sb.append("<");
|
||||
sb.append(node.getName());
|
||||
node.getAttributes().forEach(dt -> dt.accept(this, null));
|
||||
sb.append((node.isSelfClosing() ? "/>" : ">"));
|
||||
sb.append(node.isSelfClosing() ? "/>" : ">");
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -673,7 +673,6 @@ public class CommentHelper {
|
||||
return overriddenElement;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For debugging purposes only. Do not rely on this for other things.
|
||||
* @return a string representation.
|
||||
|
@ -214,11 +214,10 @@ public class Utils {
|
||||
* documentation is getting generated.
|
||||
*/
|
||||
public List<Element> excludeDeprecatedMembers(List<? extends Element> members) {
|
||||
List<Element> excludeList = members.stream()
|
||||
.filter((member) -> (!isDeprecated(member)))
|
||||
.sorted(makeGeneralPurposeComparator())
|
||||
.collect(Collectors.<Element, List<Element>>toCollection(ArrayList::new));
|
||||
return excludeList;
|
||||
return members.stream()
|
||||
.filter(member -> !isDeprecated(member))
|
||||
.sorted(makeGeneralPurposeComparator())
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -230,8 +229,8 @@ public class Utils {
|
||||
*/
|
||||
public ExecutableElement findMethod(TypeElement te, ExecutableElement method) {
|
||||
for (Element m : getMethods(te)) {
|
||||
if (executableMembersEqual(method, (ExecutableElement)m)) {
|
||||
return (ExecutableElement)m;
|
||||
if (executableMembersEqual(method, (ExecutableElement) m)) {
|
||||
return (ExecutableElement) m;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -253,7 +252,6 @@ public class Utils {
|
||||
* @param e2 the second method to compare.
|
||||
* @return true if member1 overrides/hides or is overridden/hidden by member2.
|
||||
*/
|
||||
|
||||
public boolean executableMembersEqual(ExecutableElement e1, ExecutableElement e2) {
|
||||
// TODO: investigate if Elements.hides(..) will work here.
|
||||
if (isStatic(e1) && isStatic(e2)) {
|
||||
@ -273,7 +271,7 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
if (j == parameters1.size()) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -508,7 +506,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
void addModifiers(Set<Modifier> modifiers) {
|
||||
modifiers.stream().map(Modifier::toString).forEach(this::append);
|
||||
modifiers.stream().map(Modifier::toString).forEachOrdered(this::append);
|
||||
}
|
||||
|
||||
void append(String s) {
|
||||
@ -522,7 +520,7 @@ public class Utils {
|
||||
append(s);
|
||||
if (trailingSpace) {
|
||||
sb.append(" ");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@ -665,7 +663,7 @@ public class Utils {
|
||||
/**
|
||||
* Get the signature. It is the parameter list, type is qualified.
|
||||
* For instance, for a method {@code mymethod(String x, int y)},
|
||||
* it will return {@code(java.lang.String,int)}.
|
||||
* it will return {@code (java.lang.String,int)}.
|
||||
*
|
||||
* @param e
|
||||
* @return String
|
||||
@ -929,9 +927,7 @@ public class Utils {
|
||||
|
||||
public SortedSet<TypeElement> getTypeElementsAsSortedSet(Iterable<TypeElement> typeElements) {
|
||||
SortedSet<TypeElement> set = new TreeSet<>(makeGeneralPurposeComparator());
|
||||
for (TypeElement te : typeElements) {
|
||||
set.add(te);
|
||||
}
|
||||
typeElements.forEach(set::add);
|
||||
return set;
|
||||
}
|
||||
|
||||
@ -1247,7 +1243,7 @@ public class Utils {
|
||||
*/
|
||||
public String getDimension(TypeMirror t) {
|
||||
return new SimpleTypeVisitor9<String, Void>() {
|
||||
StringBuilder dimension = new StringBuilder("");
|
||||
StringBuilder dimension = new StringBuilder();
|
||||
@Override
|
||||
public String visitArray(ArrayType t, Void p) {
|
||||
dimension.append("[]");
|
||||
@ -1334,7 +1330,6 @@ public class Utils {
|
||||
* If false, the first letter of the name is capitalized.
|
||||
* @return
|
||||
*/
|
||||
|
||||
public String getTypeElementName(TypeElement te, boolean lowerCaseOnly) {
|
||||
String typeName = "";
|
||||
if (isInterface(te)) {
|
||||
@ -1802,6 +1797,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
private Comparator<Element> overrideUseComparator = null;
|
||||
|
||||
/**
|
||||
* Returns a Comparator for overrides and implements,
|
||||
* used primarily on methods, compares the name first,
|
||||
@ -2011,6 +2007,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
private Comparator<Element> classUseComparator = null;
|
||||
|
||||
/**
|
||||
* Comparator for ClassUse presentations, and sorts as follows:
|
||||
* 1. member names
|
||||
@ -2342,7 +2339,7 @@ public class Utils {
|
||||
if (modulePackageMap == null) {
|
||||
modulePackageMap = new HashMap<>();
|
||||
Set<PackageElement> pkgs = configuration.getIncludedPackageElements();
|
||||
pkgs.forEach((pkg) -> {
|
||||
pkgs.forEach(pkg -> {
|
||||
ModuleElement mod = elementUtils.getModuleOf(pkg);
|
||||
modulePackageMap.computeIfAbsent(mod, m -> new HashSet<>()).add(pkg);
|
||||
});
|
||||
@ -2383,7 +2380,7 @@ public class Utils {
|
||||
|
||||
public String getModifiers(RequiresDirective rd) {
|
||||
StringBuilder modifiers = new StringBuilder();
|
||||
String sep="";
|
||||
String sep = "";
|
||||
if (rd.isTransitive()) {
|
||||
modifiers.append("transitive");
|
||||
sep = " ";
|
||||
@ -3272,11 +3269,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
public List<? extends DocTree> getReturnTrees(Element element) {
|
||||
List<DocTree> out = new ArrayList<>();
|
||||
for (DocTree dt : getBlockTags(element, RETURN)) {
|
||||
out.add(dt);
|
||||
}
|
||||
return out;
|
||||
return new ArrayList<>(getBlockTags(element, RETURN));
|
||||
}
|
||||
|
||||
public List<? extends DocTree> getUsesTrees(Element element) {
|
||||
@ -3288,11 +3281,7 @@ public class Utils {
|
||||
if (dcTree == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<DocTree> out = new ArrayList<>();
|
||||
for (DocTree dt : dcTree.getFirstSentence()) {
|
||||
out.add(dt);
|
||||
}
|
||||
return out;
|
||||
return new ArrayList<>(dcTree.getFirstSentence());
|
||||
}
|
||||
|
||||
public ModuleElement containingModule(Element e) {
|
||||
@ -3361,9 +3350,10 @@ public class Utils {
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple pair container.
|
||||
* @param <K> first a value
|
||||
* @param <L> second another value
|
||||
* A container holding a pair of values (tuple).
|
||||
*
|
||||
* @param <K> the type of the first value
|
||||
* @param <L> the type of the second value
|
||||
*/
|
||||
public static class Pair<K, L> {
|
||||
public final K first;
|
||||
@ -3376,9 +3366,7 @@ public class Utils {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer out = new StringBuffer();
|
||||
out.append(first + ":" + second);
|
||||
return out.toString();
|
||||
return first + ":" + second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -391,9 +391,7 @@ public class VisibleMemberTable {
|
||||
if (utils.isUndocumentedEnclosure(te)) {
|
||||
list.addAll(lmt.getOrderedMembers(kind));
|
||||
}
|
||||
parents.forEach(pvmt -> {
|
||||
list.addAll(pvmt.getExtraMembers(kind));
|
||||
});
|
||||
parents.forEach(pvmt -> list.addAll(pvmt.getExtraMembers(kind)));
|
||||
extraMembers.put(kind, Collections.unmodifiableList(list));
|
||||
}
|
||||
|
||||
@ -462,7 +460,8 @@ public class VisibleMemberTable {
|
||||
// Filter out members in the inherited list that are hidden
|
||||
// by this type or should not be inherited at all.
|
||||
List<Element> list = result.stream()
|
||||
.filter(e -> allowInheritedMembers(e, kind, lmt)).collect(Collectors.toList());
|
||||
.filter(e -> allowInheritedMembers(e, kind, lmt))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// Prefix local results first
|
||||
list.addAll(0, lmt.getOrderedMembers(kind));
|
||||
@ -523,7 +522,7 @@ public class VisibleMemberTable {
|
||||
// c. are hidden in the type being considered
|
||||
// see allowInheritedMethods, which performs the above actions
|
||||
List<Element> list = inheritedMethods.stream()
|
||||
.filter(e -> allowInheritedMethods((ExecutableElement)e, overriddenByTable, lmt))
|
||||
.filter(e -> allowInheritedMethods((ExecutableElement) e, overriddenByTable, lmt))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// Filter out the local methods, that do not override or simply
|
||||
|
@ -173,7 +173,7 @@ public class ElementsTable {
|
||||
// specified elements
|
||||
private Set<ModuleElement> specifiedModuleElements = new LinkedHashSet<>();
|
||||
private Set<PackageElement> specifiedPackageElements = new LinkedHashSet<>();
|
||||
private Set<TypeElement> specifiedTypeElements =new LinkedHashSet<>();
|
||||
private Set<TypeElement> specifiedTypeElements = new LinkedHashSet<>();
|
||||
|
||||
// included elements
|
||||
private Set<ModuleElement> includedModuleElements = null;
|
||||
@ -421,20 +421,18 @@ public class ElementsTable {
|
||||
}
|
||||
mlist.add(m);
|
||||
ModuleSymbol msym = syms.enterModule(names.fromString(m));
|
||||
specifiedModuleElements.add((ModuleElement) msym);
|
||||
specifiedModuleElements.add(msym);
|
||||
}
|
||||
|
||||
// scan for modules with qualified packages
|
||||
cmdLinePackages.stream()
|
||||
.filter((mpkg) -> (mpkg.hasModule()))
|
||||
.forEachOrdered((mpkg) -> {
|
||||
mlist.add(mpkg.moduleName);
|
||||
});
|
||||
.filter(ModulePackage::hasModule)
|
||||
.forEachOrdered(mpkg -> mlist.add(mpkg.moduleName));
|
||||
|
||||
// scan for modules with qualified subpackages
|
||||
options.subpackages().stream()
|
||||
.map(ModulePackage::new)
|
||||
.forEachOrdered((mpkg) -> {
|
||||
.forEachOrdered(mpkg -> {
|
||||
subPackages.add(mpkg);
|
||||
if (mpkg.hasModule()) {
|
||||
mlist.add(mpkg.moduleName);
|
||||
@ -481,7 +479,7 @@ public class ElementsTable {
|
||||
ElementsTable packages(Collection<String> packageNames) {
|
||||
packageNames.stream()
|
||||
.map(ModulePackage::new)
|
||||
.forEachOrdered((mpkg) -> cmdLinePackages.add(mpkg));
|
||||
.forEachOrdered(mpkg -> cmdLinePackages.add(mpkg));
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -502,11 +500,9 @@ public class ElementsTable {
|
||||
private void computeSubpackages() throws ToolException {
|
||||
options.excludes().stream()
|
||||
.map(ModulePackage::new)
|
||||
.forEachOrdered((mpkg) -> excludePackages.add(mpkg));
|
||||
.forEachOrdered(mpkg -> excludePackages.add(mpkg));
|
||||
|
||||
excludePackages.forEach((p) -> {
|
||||
getEntry(p).excluded = true;
|
||||
});
|
||||
excludePackages.forEach(p -> getEntry(p).excluded = true);
|
||||
|
||||
for (ModulePackage modpkg : subPackages) {
|
||||
List<Location> locs = getLocation(modpkg);
|
||||
@ -721,11 +717,9 @@ public class ElementsTable {
|
||||
// process types
|
||||
Set<TypeElement> iclasses = new LinkedHashSet<>();
|
||||
// add all types enclosed in expanded modules and packages
|
||||
ipackages.forEach((pkg) -> {
|
||||
addAllClasses(iclasses, pkg);
|
||||
});
|
||||
ipackages.forEach(pkg -> addAllClasses(iclasses, pkg));
|
||||
// add all types and its nested types
|
||||
specifiedTypeElements.forEach((klass) -> {
|
||||
specifiedTypeElements.forEach(klass -> {
|
||||
ModuleElement mdle = toolEnv.elements.getModuleOf(klass);
|
||||
if (mdle != null && !mdle.isUnnamed())
|
||||
imodules.add(mdle);
|
||||
@ -748,7 +742,7 @@ public class ElementsTable {
|
||||
computeSubpackages();
|
||||
|
||||
Set<PackageElement> packlist = new LinkedHashSet<>();
|
||||
cmdLinePackages.forEach((modpkg) -> {
|
||||
cmdLinePackages.forEach(modpkg -> {
|
||||
PackageElement pkg;
|
||||
if (modpkg.hasModule()) {
|
||||
ModuleElement mdle = toolEnv.elements.getModuleElement(modpkg.moduleName);
|
||||
@ -772,8 +766,8 @@ public class ElementsTable {
|
||||
*/
|
||||
private void computeSpecifiedTypes() throws ToolException {
|
||||
Set<TypeElement> classes = new LinkedHashSet<>();
|
||||
classDecList.forEach((def) -> {
|
||||
TypeElement te = (TypeElement) def.sym;
|
||||
classDecList.forEach(def -> {
|
||||
TypeElement te = def.sym;
|
||||
if (te != null) {
|
||||
addAllClasses(classes, te, true);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -29,7 +29,7 @@ import static jdk.javadoc.internal.tool.Main.Result.CMDERR;
|
||||
|
||||
/**
|
||||
* Provides a mechanism for the javadoc tool to indicate an option
|
||||
* decoding issue, arising from command line error.
|
||||
* decoding issue, arising from a command-line error.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -38,9 +38,9 @@ import java.io.PrintWriter;
|
||||
public class Main {
|
||||
|
||||
/**
|
||||
* Constructor should never be called.
|
||||
* This constructor should never be called.
|
||||
*/
|
||||
private Main() {}
|
||||
private Main() { throw new AssertionError(); }
|
||||
|
||||
/**
|
||||
* The main entry point called by the launcher. This will call
|
||||
@ -100,8 +100,6 @@ public class Main {
|
||||
/** Terminated abnormally */
|
||||
ABNORMAL(4);
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
Result(int exitCode) {
|
||||
this.exitCode = exitCode;
|
||||
}
|
||||
|
@ -98,7 +98,6 @@ public class Start {
|
||||
// used to determine the locale for the messager
|
||||
private Locale locale;
|
||||
|
||||
|
||||
/**
|
||||
* In API mode, exceptions thrown while calling the doclet are
|
||||
* propagated using ClientCodeException.
|
||||
@ -287,9 +286,9 @@ public class Start {
|
||||
// be similar to that of the java launcher: i.e. "java -help".
|
||||
|
||||
/** The indent for the option synopsis. */
|
||||
private static final String SMALL_INDENT = " ";
|
||||
private static final String SMALL_INDENT = " ".repeat(4);
|
||||
/** The automatic indent for the description. */
|
||||
private static final String LARGE_INDENT = " ";
|
||||
private static final String LARGE_INDENT = " ".repeat(18);
|
||||
/** The space allowed for the synopsis, if the description is to be shown on the same line. */
|
||||
private static final int DEFAULT_SYNOPSIS_WIDTH = 13;
|
||||
/** The nominal maximum line length, when seeing if text will fit on a line. */
|
||||
@ -339,17 +338,18 @@ public class Start {
|
||||
// Preprocess @file arguments
|
||||
try {
|
||||
argv = CommandLine.parse(argv);
|
||||
return begin(Arrays.asList(argv), Collections.emptySet());
|
||||
} catch (IOException e) {
|
||||
error("main.cant.read", e.getMessage());
|
||||
return ERROR;
|
||||
}
|
||||
return begin(Arrays.asList(argv), Collections.emptySet());
|
||||
}
|
||||
|
||||
// Called by 199 API.
|
||||
// Called by the JSR 199 API
|
||||
public boolean begin(Class<?> docletClass,
|
||||
Iterable<String> options,
|
||||
Iterable<? extends JavaFileObject> fileObjects) {
|
||||
Iterable<String> options,
|
||||
Iterable<? extends JavaFileObject> fileObjects)
|
||||
{
|
||||
this.docletClass = docletClass;
|
||||
List<String> opts = new ArrayList<>();
|
||||
for (String opt: options)
|
||||
@ -473,8 +473,9 @@ public class Start {
|
||||
* Main program - internal
|
||||
*/
|
||||
private Result parseAndExecute(List<String> argList, Iterable<? extends JavaFileObject> fileObjects)
|
||||
throws ToolException, OptionException, com.sun.tools.javac.main.Option.InvalidValueException {
|
||||
long tm = System.currentTimeMillis();
|
||||
throws ToolException, OptionException, com.sun.tools.javac.main.Option.InvalidValueException
|
||||
{
|
||||
final long startNanos = System.nanoTime();
|
||||
|
||||
List<String> javaNames = new ArrayList<>();
|
||||
|
||||
@ -549,8 +550,8 @@ public class Start {
|
||||
|
||||
// We're done.
|
||||
if (options.verbose()) {
|
||||
tm = System.currentTimeMillis() - tm;
|
||||
messager.notice("main.done_in", Long.toString(tm));
|
||||
long elapsedMillis = (System.nanoTime() - startNanos) / 1_000_000;
|
||||
messager.notice("main.done_in", Long.toString(elapsedMillis));
|
||||
}
|
||||
|
||||
return returnStatus;
|
||||
@ -645,7 +646,7 @@ public class Start {
|
||||
String userDocletName = null;
|
||||
|
||||
// Step 1: loop through the args, set locale early on, if found.
|
||||
for (int i = 0 ; i < argv.size() ; i++) {
|
||||
for (int i = 0; i < argv.size(); i++) {
|
||||
String arg = argv.get(i);
|
||||
if (arg.equals(ToolOptions.DUMP_ON_ERROR)) {
|
||||
// although this option is not needed in order to initialize the doclet,
|
||||
@ -765,7 +766,7 @@ public class Start {
|
||||
|
||||
private void parseArgs(List<String> args, List<String> javaNames) throws ToolException,
|
||||
OptionException, com.sun.tools.javac.main.Option.InvalidValueException {
|
||||
for (int i = 0 ; i < args.size() ; i++) {
|
||||
for (int i = 0; i < args.size(); i++) {
|
||||
String arg = args.get(i);
|
||||
ToolOption o = options.getOption(arg);
|
||||
if (o != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user