Closed
Description
Overview
When there is a only a single argument in a function call it seems unnecessary to place it onto a new line. This misaligns with how other prettier languages work, like in Javascript:
A single argument taking a lambda
When there are multiple arguments, e.g. two lambdas
Steps to reproduce
Prettier-Java 0.8.0
Stream methods (map, filter, etc)
Input:
final List<Integer> values = Stream.of(1, 2)
.map(n -> {
// testing method
return n * 2;
})
.collect(Collectors.toList());
Output:
final List<Integer> values = Stream
.of(1, 2)
.map(
n -> {
// testing method
return n * 2;
}
)
.collect(Collectors.toList());
Expected behavior:
final List<Integer> values = Stream
.of(1, 2)
.map(n -> {
// testing method
return n * 2;
})
.collect(Collectors.toList());
Completable Futures (single argument)
Input:
CompletableFuture.supplyAsync(() -> {
// some processing
return 2;
});
Output:
CompletableFuture.supplyAsync(
() -> {
// some processing
return 2;
}
);
Expected behavior:
CompletableFuture.supplyAsync(() -> {
// some processing
return 2;
});
Completable Future (Multiple Arguments)
Input:
CompletableFuture.supplyAsync(() -> {
// some processing
return 2;
}, executor);
Output:
CompletableFuture.supplyAsync(
() -> {
// some processing
return 2;
},
executor
);
Expected behavior:
CompletableFuture.supplyAsync(
() -> {
// some processing
return 2;
},
executor
);
Function arguments that exceed width
Input:
myFunction((one, two, three, four, five, six) -> {
// some processing
return 2;
});
Output:
myFunction(
(one, two, three, four, five, six) -> {
// some processing
return 2;
}
);
Expected behavior:
myFunction(
(one, two, three, four, five, six) -> {
// some processing
return 2;
}
);