mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 03:13:40 +07:00
extract simplify forEach inspection: IDEA-CR-24052
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
// "Extract intermediate operations" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> other = new ArrayList<>();
|
||||
other.stream().filter(s -> s.length() > 2).forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Extract intermediate operations" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> other = new ArrayList<>();
|
||||
// c1
|
||||
//c2
|
||||
other.stream().filter(s -> s.length() > 2).forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private void test(List<String> strs) {
|
||||
List<String> other = strs.stream().filter(s -> s.length() > 2).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> strs;
|
||||
List<String> other = new ArrayList<>();
|
||||
strs = other.stream().collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> strs;
|
||||
List<String> other = new ArrayList<>();
|
||||
strs = other.stream().filter(s -> s.length() > 2).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> other = new ArrayList<>();
|
||||
String[] arr = other.stream().filter(s -> s.length() > 2).sorted(String.CASE_INSENSITIVE_ORDER).toArray();
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> strs;
|
||||
List<String> other = new ArrayList<>();
|
||||
strs = other.stream().filter(s -> s.length() > 2).sorted(String::compareTo).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Extract intermediate operations" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> other = new ArrayList<>();
|
||||
other.stream().filter(s -> s.length() > 2).forEachOrdered(System.out::println);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private void test(List<String> other) {
|
||||
List<String> strs = other.stream().collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> strs;
|
||||
List<String> other = new ArrayList<>();
|
||||
strs = other.stream().collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with count()" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> strs = new ArrayList<>();
|
||||
int count = (int) strs.stream().count();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> strs = new ArrayList<>();
|
||||
String sb = strs.stream().collect(Collectors.joining());
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test(List<String> strs) {
|
||||
String[] arr = strs.toArray();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> other = new ArrayList<>();
|
||||
HashMap<Integer, String> map = other.stream().collect(Collectors.toMap(String::length, s -> s, (a, b) -> a, HashMap::new));
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Extract intermediate operations" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> other = new ArrayList<>();
|
||||
other.stream().forEach<caret>(s -> {
|
||||
if(s.length() > 2) System.out.println(s);
|
||||
});
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Extract intermediate operations" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> other = new ArrayList<>();
|
||||
other.stream().forEach<caret>(s -> { // c1
|
||||
if(s.length() > 2) System.out.println(s); //c2
|
||||
});
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test(List<String> strs) {
|
||||
List<String> other = new ArrayList<>();
|
||||
strs.stream().forEach<caret>(s -> {
|
||||
if(s.length() > 2) {
|
||||
other.add(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> strs = new ArrayList<>();
|
||||
List<String> other = new ArrayList<>();
|
||||
other.stream().forEach<caret>(s -> {strs.add(s)});
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> strs = new ArrayList<>();
|
||||
List<String> other = new ArrayList<>();
|
||||
other.stream().forEach<caret>(s -> {
|
||||
if(s.length() > 2) strs.add(s);
|
||||
});
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> strs = new ArrayList<>();
|
||||
List<String> other = new ArrayList<>();
|
||||
other.stream().forEach<caret>(s -> {
|
||||
if(s.length() > 2) {
|
||||
strs.add(s);
|
||||
}
|
||||
});
|
||||
String[] arr = strs.toArray();
|
||||
Arrays.sort(arr, String.CASE_INSENSITIVE_ORDER);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> strs = new ArrayList<>();
|
||||
List<String> other = new ArrayList<>();
|
||||
other.stream().forEach<caret>(s -> {
|
||||
if(s.length() > 2) {
|
||||
strs.add(s);
|
||||
}
|
||||
});
|
||||
strs.sort(String::compareTo);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Extract intermediate operations" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> other = new ArrayList<>();
|
||||
other.stream().forEachOrdered<caret>(s -> {if(s.length() > 2) System.out.println(s);});
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test(List<String> other) {
|
||||
List<String> strs = new ArrayList<>();
|
||||
other.stream().forEach<caret>(s -> {strs.add(s)});
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> strs = new ArrayList<>();
|
||||
List<String> other = new ArrayList<>();
|
||||
other.stream().forEach<caret>(s -> strs.add(s));
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with count()" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> strs = new ArrayList<>();
|
||||
int count = 0;
|
||||
strs.stream().forEach<caret>(x -> count++)
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> strs = new ArrayList<>();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
strs.stream().forEach<caret>(x -> sb.append(x));
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with toArray" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test(List<String> strs) {
|
||||
List<String> tmp = new ArrayList<>();
|
||||
strs.stream().forEach<caret>(x -> tmp.add(x));
|
||||
String[] arr = tmp.toArray();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
private void test() {
|
||||
List<String> other = new ArrayList<>();
|
||||
HashMap<Integer, String> map = new HashMap<Integer, String>();
|
||||
other.stream().forEach<caret>(s -> map.putIfAbsent(s.length(), s));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user