IDEA-182623 Replace with collect swallows comments

This commit is contained in:
Tagir Valeev
2017-11-27 15:22:26 +07:00
parent 5b8f3b2bfe
commit 5b36191d2c
29 changed files with 306 additions and 263 deletions
@@ -6,8 +6,8 @@ import java.util.List;
public class Main {
public static String find(List<List<String>> list) {
/*
Block comment
*/
Block comment
*/
return list.stream().flatMap(Collection::stream).filter(string -> string.startsWith("ABC")).findFirst().map(string -> string.substring(3)).orElse("");
}
}
@@ -6,8 +6,8 @@ import java.util.List;
public class Main {
public static boolean find(List<List<String>> list) {
/*
Block comment
*/
Block comment
*/
return list.stream().flatMap(Collection::stream).filter(string -> string.startsWith("ABC")).findFirst().filter(string -> string.substring(3).equals("xyz")).isPresent();
}
}
@@ -8,6 +8,7 @@ import java.util.Optional;
public class Main {
private static String test(List<String> list) {
Optional<String> found = list.stream().filter(Objects::nonNull).findFirst();
// optional!
return found.orElse(null);
}
@@ -4,6 +4,7 @@ import java.util.List;
public class Main {
public int testPrimitiveMap(List<String> data) {
return data.stream().filter(str -> str.startsWith("xyz")).mapToInt(String::length).filter(len -> len > 10).findFirst().orElse(0);
/*ten*/
return data.stream().filter(str -> str.startsWith("xyz")).mapToInt(String::length).filter(len -> len /*bigger*/ > 10).findFirst().orElse(0);
}
}
@@ -5,10 +5,10 @@ import java.util.Map;
public class Main {
public void testMap(Map<String, List<String>> map) throws Exception {
int bigSize = 0;
int bigSize = 0; // initial
for(List<String> list : map.valu<caret>es()) {
int size = list.size();
if(size > 10) {
int size = list.size(); // size
if(size/*bigger*/ > 10) {
bigSize = size*2;
break;
}
@@ -10,7 +10,7 @@ public class Main {
Optional<String> found = Optional.empty();
for (String s : li<caret>st) {
if (Objects.nonNull(s)) {
found = Optional.of(s);
found = Optional.of(s); // optional!
break;
}
}
@@ -7,7 +7,7 @@ public class Main {
for(String str : dat<caret>a) {
if(str.startsWith("xyz")) {
int len = str.length();
if(len > 10) {
if(len /*bigger*/> 10 /*ten*/) {
return len;
}
}