mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-25 14:25:04 +07:00
StreamToLoopInspection: preserve comments; CommentTracker: now possible to delete element first and only after that register unchanged parts.
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ import java.util.stream.IntStream;
|
||||
public class Main {
|
||||
private static IntSummaryStatistics test() {
|
||||
IntSummaryStatistics stat = new IntSummaryStatistics();
|
||||
for (int i : new int[]{1, 2, 3}) {
|
||||
for (int i : new int[]{1,/*two*/2,/*three*/3}) {
|
||||
stat.accept(i);
|
||||
}
|
||||
return stat;
|
||||
|
||||
+2
-1
@@ -7,9 +7,10 @@ import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public static List<String> test() {
|
||||
/*limit*/
|
||||
List<String> list = new ArrayList<>();
|
||||
long limit = 20;
|
||||
for (String x = ""; ; x = x + "a") {
|
||||
for (String x = ""; ; x = x /* add "a" */ + "a") {
|
||||
if (limit-- == 0) break;
|
||||
list.add(x);
|
||||
}
|
||||
|
||||
+1
@@ -11,6 +11,7 @@ public class Main {
|
||||
for (Map.Entry<String, List<String>> e : strings.entrySet()) {
|
||||
if (!e.getKey().isEmpty()) {
|
||||
long count = e.getValue().stream().filter(new Predicate<String>() {
|
||||
// we're inside anonymous class
|
||||
@Override
|
||||
public boolean test(String s) {
|
||||
return e.getKey().equals(s);
|
||||
|
||||
+3
-2
@@ -6,12 +6,13 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public static void test(List<String> strings) {
|
||||
// and collect
|
||||
Map<Boolean, Map<String, Integer>> map = new HashMap<>();
|
||||
map.put(false, new HashMap<>());
|
||||
map.put(true, new HashMap<>());
|
||||
for (String string : strings) {
|
||||
String s = string.trim();
|
||||
if (map.get(s.length() > 2).put(((UnaryOperator<String>) x -> x).apply(s), s.length()) != null) {
|
||||
String s = string/*trimming*/.trim();
|
||||
if (map.get(s.length() /*too big!*/ > 2).put(((UnaryOperator<String>) /* cast is necessary here */ x -> x).apply(s), s.length()) != null) {
|
||||
throw new IllegalStateException("Duplicate key");
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -5,9 +5,10 @@ import java.util.function.LongSupplier;
|
||||
|
||||
public class Main {
|
||||
private static void test(List<String> list) {
|
||||
// and filter!
|
||||
long count1 = 0;
|
||||
for (String s : list) {
|
||||
if (!s.isEmpty()) {
|
||||
if (!s/* comment */.isEmpty()) {
|
||||
count1++;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import java.util.stream.Stream;
|
||||
public class Main {
|
||||
private static IntSummaryStatistics test() {
|
||||
IntSummaryStatistics stat = new IntSummaryStatistics();
|
||||
for (Integer i : new Integer[]{1, 2, 3}) {
|
||||
for (Integer i : new Integer[] /*create array*/{1, 2, 3}) {
|
||||
int i1 = i;
|
||||
stat.accept(i1);
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import java.util.stream.Stream;
|
||||
public class Main {
|
||||
private static IntSummaryStatistics test() {
|
||||
IntSummaryStatistics stat = new IntSummaryStatistics();
|
||||
for (Supplier<Integer> sup : Arrays.<Supplier<Integer>>asList(() -> 1, () -> 2, () -> 3)) {
|
||||
for (Supplier<Integer> sup : Arrays.<Supplier<Integer>>asList(() -> 1, /*between*/ () /*supply 2*/ -> 2, () -> 3)) {
|
||||
int i = sup.get();
|
||||
stat.accept(i);
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.IntStream;
|
||||
|
||||
public class Main {
|
||||
private static IntSummaryStatistics test() {
|
||||
return IntStream.of(1,2,3).summaryStatist<caret>ics();
|
||||
return IntStream.of(1,/*two*/2,/*three*/3).summaryStatist<caret>ics();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public static List<String> test() {
|
||||
return Stream.iterate("", x -> x + "a").limit(20).co<caret>llect(Collectors.toList());
|
||||
return Stream.iterate("", x -> x /* add "a" */ + "a").limit(/*limit*/20).co<caret>llect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
+1
@@ -8,6 +8,7 @@ public class Main {
|
||||
|
||||
private static long test(Map<String, List<String>> strings) {
|
||||
return strings.entrySet().stream().filter(s -> !s.getKey().isEmpty()).mapToLong(e -> e.getValue().stream().filter(new Predicate<String>() {
|
||||
// we're inside anonymous class
|
||||
@Override
|
||||
public boolean test(String s) {
|
||||
return e.getKey().equals(s);
|
||||
|
||||
+4
-2
@@ -8,8 +8,10 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public static void test(List<String> strings) {
|
||||
System.out.println(strings.stream().map(x -> x.trim()).colle<caret>ct(Collectors.partitioningBy(s -> s.length() > 2,
|
||||
Collectors.toMap(s -> ((UnaryOperator<String>) x -> x).apply(s), String::length))));
|
||||
System.out.println(strings.stream().map(x -> x/*trimming*/.trim()) // and collect
|
||||
.colle<caret>ct(Collectors.partitioningBy(s -> s.length() /*too big!*/ > 2,
|
||||
Collectors.toMap(s -> ((UnaryOperator<String>) /* cast is necessary here */ x -> x).apply(s),
|
||||
String::length))));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
+2
-1
@@ -5,7 +5,8 @@ import java.util.function.LongSupplier;
|
||||
|
||||
public class Main {
|
||||
private static void test(List<String> list) {
|
||||
long count = list.stream().filter(s -> !s.isEmpty()).co<caret>unt();
|
||||
long count = list.stream(). // and filter!
|
||||
filter(s -> !s/* comment */.isEmpty()).co<caret>unt();
|
||||
if(count > 10) {
|
||||
LongSupplier sup = () -> count*2;
|
||||
long result = sup.get();
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.stream.Stream;
|
||||
|
||||
public class Main {
|
||||
private static IntSummaryStatistics test() {
|
||||
return Stream.of(new Integer[] {1,2,3}).mapToInt(i -> i).summaryStatisti<caret>cs();
|
||||
return Stream.of(new Integer[] /*create array*/{1,2,3}).mapToInt(i -> i).summaryStatisti<caret>cs();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import java.util.stream.Stream;
|
||||
|
||||
public class Main {
|
||||
private static IntSummaryStatistics test() {
|
||||
return Stream.<Supplier<Integer>>of(() -> 1, () -> 2, () -> 3).mapToInt(sup -> sup.get()).summar<caret>yStatistics();
|
||||
return Stream.<Supplier<Integer>>of(() -> 1, /*between*/ () /*supply 2*/ -> 2, () -> 3).mapToInt(sup -> sup.get()).summar<caret>yStatistics();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Reference in New Issue
Block a user