Skip to content
Permalink
Browse files
8263621: Convert jdk.compiler to use Stream.toList()
Reviewed-by: mcimadamore, vromero
  • Loading branch information
Ian Graves authored and mcimadamore committed Apr 22, 2021
1 parent 7df0c10 commit 33a86b9e407499d18db84cf0cf1ba03caeb4dfbb
@@ -204,7 +204,7 @@ public void initPlugins(Set<List<String>> pluginOpts) {
java.util.List<String> options =
pluginDesc.getOptions().entrySet().stream()
.map(e -> e.getKey() + "=" + e.getValue())
.collect(Collectors.toList());
.toList();
try {
initPlugin(pluginDesc.getPlugin(), options.toArray(new String[options.size()]));
} catch (RuntimeException ex) {
@@ -491,7 +491,7 @@ public void list(Path userPath,

java.util.List<Path> files;
try (Stream<Path> s = Files.list(d)) {
files = (sortFiles == null ? s : s.sorted(sortFiles)).collect(Collectors.toList());
files = (sortFiles == null ? s : s.sorted(sortFiles)).toList();
} catch (IOException ignore) {
return;
}
@@ -953,7 +953,7 @@ SearchPath computePath() throws IOException {
Path modules = javaHome.resolve("modules");
if (Files.isDirectory(modules.resolve("java.base"))) {
try (Stream<Path> listedModules = Files.list(modules)) {
return listedModules.collect(Collectors.toList());
return listedModules.toList();
}
}

@@ -123,7 +123,7 @@ public boolean isSubsignature(ExecutableType m1, ExecutableType m2) {
Type ty = (Type)t;
return types.directSupertypes(ty).stream()
.map(Type::stripMetadataIfNeeded)
.collect(Collectors.toList());
.toList();
}

@DefinedBy(Api.LANGUAGE_MODEL)
@@ -343,7 +343,7 @@ private void initProcessorIterator(Iterable<? extends Processor> processors) {
platformProcessors = platformProvider.getAnnotationProcessors()
.stream()
.map(PluginInfo::getPlugin)
.collect(Collectors.toList());
.toList();
}
List<Iterator<? extends Processor>> iterators = List.of(processorIterator,
platformProcessors.iterator());
@@ -280,7 +280,7 @@ public PrintingElementVisitor visitType(TypeElement e, Boolean p) {
e.getEnclosedElements()
.stream()
.filter(elt -> elementUtils.getOrigin(elt) == Elements.Origin.EXPLICIT )
.collect(Collectors.toList()) ) )
.toList() ) )
this.visit(element);
}

@@ -152,20 +152,20 @@ public Void visitExecutable(ExecutableElement e, Void p) {
private List<PubApiTypeParam> getTypeParameters(List<? extends TypeParameterElement> elements) {
return elements.stream()
.map(e -> new PubApiTypeParam(e.getSimpleName().toString(), getTypeDescs(e.getBounds())))
.collect(Collectors.toList());
.toList();
}

private List<TypeMirror> getParamTypes(ExecutableElement e) {
return e.getParameters()
.stream()
.map(VariableElement::asType)
.collect(Collectors.toList());
.toList();
}

private List<TypeDesc> getTypeDescs(List<? extends TypeMirror> list) {
return list.stream()
.map(TypeDesc::fromType)
.collect(Collectors.toList());
.toList();
}

public PubApi getCollectedPubApi() {
@@ -272,11 +272,11 @@ public void addPubMethod(PubMethod m) {
private static List<TypeDesc> parseTypeDescs(List<String> strs) {
return strs.stream()
.map(TypeDesc::decodeString)
.collect(Collectors.toList());
.toList();
}

private static List<PubApiTypeParam> parseTypeParams(List<String> strs) {
return strs.stream().map(PubApi::parseTypeParam).collect(Collectors.toList());
return strs.stream().map(PubApi::parseTypeParam).toList();
}

// Parse a type parameter string. Example input:
@@ -284,12 +284,12 @@ public Void visitDocComment(DocCommentTree node, Void p) {
executableElement.getParameters()
.stream()
.map(param -> param.getSimpleName().toString())
.collect(Collectors.toList());
.toList();
List<String> throwsList =
executableElement.getThrownTypes()
.stream()
.map(TypeMirror::toString)
.collect(Collectors.toList());
.toList();
Set<String> missingParams = new HashSet<>(parameters);
Set<String> missingThrows = new HashSet<>(throwsList);
boolean hasReturn = false;

1 comment on commit 33a86b9

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 33a86b9 Apr 22, 2021

Please sign in to comment.