Skip to content
Permalink
Browse files

8238969: Miscellaneous cleanup

Reviewed-by: jjg
  • Loading branch information
pavelrappo committed Feb 18, 2020
1 parent 36cd7bd commit 56282f7119c1c1dce98b9687b0375c1e1adb841b
Showing with 212 additions and 225 deletions.
  1. +22 −19 src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTaskImpl.java
  2. +2 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTool.java
  3. +1 −1 ...vadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java
  4. +1 −14 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java
  5. +6 −6 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java
  6. +1 −1 ...avadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java
  7. +5 −5 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java
  8. +3 −2 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java
  9. +13 −7 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
  10. +4 −8 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java
  11. +19 −19 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java
  12. +6 −3 ...jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java
  13. +7 −10 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java
  14. +7 −4 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java
  15. +5 −2 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java
  16. +2 −3 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Table.java
  17. +2 −2 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/TableHeader.java
  18. +1 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseConfiguration.java
  19. +5 −3 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/DocletElement.java
  20. +0 −1 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/OverviewElement.java
  21. +6 −4 ...jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java
  22. +14 −16 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java
  23. +16 −8 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletWriter.java
  24. +5 −6 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java
  25. +23 −35 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java
  26. +4 −5 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberTable.java
  27. +13 −19 src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java
  28. +2 −2 src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/IllegalOptionValue.java
  29. +3 −5 src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Main.java
  30. +14 −13 src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java
@@ -29,7 +29,6 @@
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 @@
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,34 +76,35 @@ public JavadocTaskImpl(Context context, Class<?> docletClass,

@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);
}
}

@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 @@ private void initContext() {
}

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 DocumentationTask getTask(
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 @@ protected Content getExceptions(ExecutableElement member) {
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,
@@ -140,8 +140,6 @@ private Table getSummaryTable() {
*/
protected abstract Table createSummaryTable();



/**
* Add inherited summary label for the member.
*
@@ -198,17 +196,6 @@ protected abstract void addInheritedSummaryLink(TypeElement typeElement,
*/
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 @@ private void appendParametersAndExceptions(Content htmltree, int lastLineSeparat

// 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 @@ protected void addTree(SortedSet<TypeElement> sset, String heading,
* @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 AnnotationTypeFieldWriterImpl(SubWriterHolderWriter writer,

@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 @@
"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 @@ private Content getRecordComponents(TypeElement typeElem) {
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 @@

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 DocPath getMainStylesheet() {

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 @@
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 @@ boolean isAllWhiteSpace(String body) {
* @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 Content commentTagsToContent(DocTree holderTag, Element element,
* @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 Boolean visitAttribute(AttributeTree node, Content c) {
quote = "\"";
break;
case SINGLE:
quote = "\'";
quote = "'";
break;
default:
quote = "";
@@ -131,17 +131,13 @@ protected Content getTypeParameterLinks(LinkInfo linkInfo, boolean isClassLabel)
? 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;

0 comments on commit 56282f7

Please sign in to comment.