8261168: Convert javadoc tool to use Stream.toList()
Reviewed-by: prappo
This commit is contained in:
parent
8559a53056
commit
fb8f0c5dd8
@ -374,7 +374,7 @@ public class HtmlConfiguration extends BaseConfiguration {
|
||||
return options.additionalStylesheets().stream()
|
||||
.map(ssf -> DocFile.createFileForInput(this, ssf))
|
||||
.map(file -> DocPath.create(file.getName()))
|
||||
.collect(Collectors.toList());
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -367,7 +367,7 @@ public class IndexWriter extends HtmlDocletWriter {
|
||||
.sorted((i1,i2)-> utils.compareStrings(i1.getLabel(), i2.getLabel()))
|
||||
.map(i -> links.createLink(pathToRoot.resolve(i.getUrl()),
|
||||
contents.getNonBreakString(i.getLabel())))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
contentTree.add(contents.join(getVerticalSeparator(), pageLinks));
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ public class Signatures {
|
||||
List<? extends TypeMirror> permits = typeElement.getPermittedSubclasses();
|
||||
List<? extends TypeMirror> linkablePermits = permits.stream()
|
||||
.filter(t -> utils.isLinkable(utils.asTypeElement(t)))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
if (!linkablePermits.isEmpty()) {
|
||||
Content permitsSpan = new HtmlTree(TagName.SPAN).setStyle(HtmlStyle.permits);
|
||||
boolean isFirst = true;
|
||||
|
@ -43,14 +43,12 @@ import jdk.javadoc.internal.doclets.toolkit.util.IndexItem;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import static java.util.stream.Collectors.groupingBy;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Generates the file with the summary of all the system properties.
|
||||
@ -148,7 +146,7 @@ public class SystemPropertiesWriter extends HtmlDocletWriter {
|
||||
|
||||
private Map<String, List<IndexItem>> groupSystemProperties() {
|
||||
return configuration.mainIndex.getItems(DocTree.Kind.SYSTEM_PROPERTY).stream()
|
||||
.collect(groupingBy(IndexItem::getLabel, TreeMap::new, toList()));
|
||||
.collect(groupingBy(IndexItem::getLabel, TreeMap::new, Collectors.toCollection(ArrayList::new)));
|
||||
}
|
||||
|
||||
private Content createLink(IndexItem i) {
|
||||
|
@ -69,7 +69,7 @@ public class TableHeader extends Content {
|
||||
public TableHeader(Contents contents, String... colHeaderKeys) {
|
||||
this.cellContents = Arrays.stream(colHeaderKeys)
|
||||
.map(contents::getContent)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -413,9 +413,10 @@ public abstract class MemberSummaryBuilder extends AbstractMemberBuilder {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<Element> members = inheritedMembersFromMap.stream()
|
||||
List<? extends Element> members = inheritedMembersFromMap.stream()
|
||||
.filter(e -> utils.getEnclosingTypeElement(e) == inheritedClass)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
if (!members.isEmpty()) {
|
||||
SortedSet<Element> inheritedMembers = new TreeSet<>(comparator);
|
||||
inheritedMembers.addAll(members);
|
||||
|
@ -349,6 +349,6 @@ public class PackageSummaryBuilder extends AbstractBuilder {
|
||||
private List<PackageElement> filterPackages(Predicate<? super PackageElement> filter) {
|
||||
return configuration.packages.stream()
|
||||
.filter(p -> p != packageElement && filter.test(p))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ public class ThrowsTaglet extends BaseTaglet
|
||||
}
|
||||
List<? extends ThrowsTree> inheritedTags = inheritedDoc.tagList.stream()
|
||||
.map(t -> (ThrowsTree) t)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
declaredExceptionTags.put(inheritedTags, (ExecutableElement) inheritedDoc.holder);
|
||||
}
|
||||
}
|
||||
|
@ -2097,21 +2097,21 @@ public class Utils {
|
||||
public List<TypeElement> getOrdinaryClasses(Element e) {
|
||||
return getClasses(e).stream()
|
||||
.filter(te -> (!isException(te) && !isError(te)))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
public List<TypeElement> getErrors(Element e) {
|
||||
return getClasses(e)
|
||||
.stream()
|
||||
.filter(this::isError)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
public List<TypeElement> getExceptions(Element e) {
|
||||
return getClasses(e)
|
||||
.stream()
|
||||
.filter(this::isException)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
@SuppressWarnings("preview")
|
||||
@ -2601,7 +2601,7 @@ public class Utils {
|
||||
return getBlockTags(element).stream()
|
||||
.filter(t -> t.getKind() != ERRONEOUS)
|
||||
.filter(filter)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
public <T extends DocTree> List<? extends T> getBlockTags(Element element, Predicate<DocTree> filter, Class<T> tClass) {
|
||||
@ -2609,7 +2609,7 @@ public class Utils {
|
||||
.filter(t -> t.getKind() != ERRONEOUS)
|
||||
.filter(filter)
|
||||
.map(t -> tClass.cast(t))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
public List<? extends DocTree> getBlockTags(Element element, DocTree.Kind kind) {
|
||||
@ -3027,7 +3027,7 @@ public class Utils {
|
||||
usedInDeclaration.addAll(types2Classes(List.of(te.getSuperclass())));
|
||||
usedInDeclaration.addAll(types2Classes(te.getInterfaces()));
|
||||
usedInDeclaration.addAll(types2Classes(te.getPermittedSubclasses()));
|
||||
usedInDeclaration.addAll(types2Classes(te.getRecordComponents().stream().map(c -> c.asType()).collect(Collectors.toList()))); //TODO: annotations on record components???
|
||||
usedInDeclaration.addAll(types2Classes(te.getRecordComponents().stream().map(c -> c.asType()).toList())); //TODO: annotations on record components???
|
||||
}
|
||||
case CONSTRUCTOR, METHOD -> {
|
||||
ExecutableElement ee = (ExecutableElement) el;
|
||||
@ -3037,7 +3037,7 @@ public class Utils {
|
||||
usedInDeclaration.addAll(types2Classes(List.of(ee.getReturnType())));
|
||||
usedInDeclaration.addAll(types2Classes(List.of(ee.getReceiverType())));
|
||||
usedInDeclaration.addAll(types2Classes(ee.getThrownTypes()));
|
||||
usedInDeclaration.addAll(types2Classes(ee.getParameters().stream().map(p -> p.asType()).collect(Collectors.toList())));
|
||||
usedInDeclaration.addAll(types2Classes(ee.getParameters().stream().map(p -> p.asType()).toList()));
|
||||
usedInDeclaration.addAll(annotationValue2Classes(ee.getDefaultValue()));
|
||||
}
|
||||
case FIELD, ENUM_CONSTANT, RECORD_COMPONENT -> {
|
||||
|
@ -54,6 +54,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
|
||||
import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
|
||||
@ -199,7 +200,7 @@ public class VisibleMemberTable {
|
||||
|
||||
return visibleMembers.getOrDefault(kind, Collections.emptyList()).stream()
|
||||
.filter(p)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -408,8 +409,8 @@ public class VisibleMemberTable {
|
||||
default:
|
||||
List<Element> list = lmt.getOrderedMembers(kind).stream()
|
||||
.filter(this::mustDocument)
|
||||
.collect(Collectors.toList());
|
||||
visibleMembers.put(kind, Collections.unmodifiableList(list));
|
||||
.toList();
|
||||
visibleMembers.put(kind, list);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -454,19 +455,16 @@ 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());
|
||||
|
||||
// Prefix local results first
|
||||
list.addAll(0, lmt.getOrderedMembers(kind));
|
||||
Stream<Element> inheritedStream = result.stream()
|
||||
.filter(e -> allowInheritedMembers(e, kind, lmt));
|
||||
|
||||
// Filter out elements that should not be documented
|
||||
list = list.stream()
|
||||
.filter(this::mustDocument)
|
||||
.collect(Collectors.toList());
|
||||
// Prefix local results first
|
||||
List<Element> list = Stream.concat(lmt.getOrderedMembers(kind).stream(), inheritedStream)
|
||||
.filter(this::mustDocument)
|
||||
.toList();
|
||||
|
||||
visibleMembers.put(kind, Collections.unmodifiableList(list));
|
||||
visibleMembers.put(kind, list);
|
||||
}
|
||||
|
||||
private void computeVisibleMethods(LocalMemberTable lmt) {
|
||||
@ -490,9 +488,12 @@ public class VisibleMemberTable {
|
||||
// b. are overridden and should not be visible in this type
|
||||
// c. are hidden in the type being considered
|
||||
// see allowInheritedMethod, which performs the above actions
|
||||
List<Element> list = inheritedMethods.stream()
|
||||
// nb. This statement has side effects that can initialize
|
||||
// members of the overridenMethodTable field, so it must be
|
||||
// evaluated eagerly with toList().
|
||||
List<Element> inheritedMethodsList = inheritedMethods.stream()
|
||||
.filter(e -> allowInheritedMethod((ExecutableElement) e, overriddenByTable, lmt))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
// Filter out the local methods, that do not override or simply
|
||||
// overrides a super method, or those methods that should not
|
||||
@ -501,21 +502,19 @@ public class VisibleMemberTable {
|
||||
OverriddenMethodInfo p = overriddenMethodTable.getOrDefault(m, null);
|
||||
return p == null || !p.simpleOverride;
|
||||
};
|
||||
List<Element> localList = lmt.getOrderedMembers(Kind.METHODS)
|
||||
|
||||
Stream<ExecutableElement> localStream = lmt.getOrderedMembers(Kind.METHODS)
|
||||
.stream()
|
||||
.map(m -> (ExecutableElement)m)
|
||||
.filter(isVisible)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// Merge the above lists, making sure the local methods precede the others
|
||||
list.addAll(0, localList);
|
||||
.filter(isVisible);
|
||||
|
||||
// Merge the above list and stream, making sure the local methods precede the others
|
||||
// Final filtration of elements
|
||||
list = list.stream()
|
||||
List<Element> list = Stream.concat(localStream,inheritedMethodsList.stream())
|
||||
.filter(this::mustDocument)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
visibleMembers.put(Kind.METHODS, Collections.unmodifiableList(list));
|
||||
visibleMembers.put(Kind.METHODS, list);
|
||||
|
||||
// Copy over overridden tables from the lineage, and finish up.
|
||||
for (VisibleMemberTable pvmt : parents) {
|
||||
@ -795,7 +794,7 @@ public class VisibleMemberTable {
|
||||
List<Element> getPropertyMethods(String methodName, int argcount) {
|
||||
return getMembers(methodName + ":" + argcount, Kind.METHODS).stream()
|
||||
.filter(m -> (utils.isPublic(m) || utils.isProtected(m)))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@ -857,17 +856,17 @@ public class VisibleMemberTable {
|
||||
return;
|
||||
|
||||
PropertyUtils pUtils = config.propertyUtils;
|
||||
List<ExecutableElement> list = visibleMembers.getOrDefault(Kind.METHODS, Collections.emptyList())
|
||||
List<Element> list = visibleMembers.getOrDefault(Kind.METHODS, Collections.emptyList())
|
||||
.stream()
|
||||
.map(m -> (ExecutableElement)m)
|
||||
.filter(pUtils::isPropertyMethod)
|
||||
.collect(Collectors.toList());
|
||||
.filter(e -> pUtils.isPropertyMethod((ExecutableElement) e))
|
||||
.toList();
|
||||
|
||||
visibleMembers.put(Kind.PROPERTIES, Collections.unmodifiableList(list));
|
||||
visibleMembers.put(Kind.PROPERTIES, list);
|
||||
|
||||
List<ExecutableElement> propertyMethods = list.stream()
|
||||
.map(e -> (ExecutableElement) e)
|
||||
.filter(e -> utils.getEnclosingTypeElement(e) == te)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
// Compute additional properties related sundries.
|
||||
for (ExecutableElement propertyMethod : propertyMethods) {
|
||||
@ -931,7 +930,7 @@ public class VisibleMemberTable {
|
||||
ImplementedMethods imf = getImplementedMethodsFinder(method);
|
||||
return imf.getImplementedMethods().stream()
|
||||
.filter(m -> getSimplyOverriddenMethod(m) == null)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
public TypeMirror getImplementedMethodHolder(ExecutableElement method,
|
||||
|
Loading…
Reference in New Issue
Block a user