Skip to content

Commit

Permalink
8263621: Convert jdk.compiler to use Stream.toList()
Browse files Browse the repository at this point in the history
Reviewed-by: mcimadamore, vromero
  • Loading branch information
Ian Graves authored and mcimadamore committed Apr 22, 2021
1 parent 7df0c10 commit 33a86b9
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
Expand Up @@ -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) {
Expand Down
Expand Up @@ -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;
}
Expand Down
Expand Up @@ -953,7 +953,7 @@ private Collection<Path> systemClasses() 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();
}
}

Expand Down
Expand Up @@ -123,7 +123,7 @@ public List<Type> directSupertypes(TypeMirror t) {
Type ty = (Type)t;
return types.directSupertypes(ty).stream()
.map(Type::stripMetadataIfNeeded)
.collect(Collectors.toList());
.toList();
}

@DefinedBy(Api.LANGUAGE_MODEL)
Expand Down
Expand Up @@ -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());
Expand Down
Expand Up @@ -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);
}

Expand Down
Expand Up @@ -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() {
Expand Down
Expand Up @@ -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:
Expand Down
Expand Up @@ -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;
Expand Down

1 comment on commit 33a86b9

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.