IDEA-170032 Replace with foreach is not proposed in alt-enter

Now both options (when unchecked) only disable warning and batch-mode replacement, but the action is still available as an intention.
This commit is contained in:
Tagir Valeev
2017-03-30 13:07:18 +07:00
parent 18299adb7f
commit 478cae19bf
15 changed files with 106 additions and 48 deletions

View File

@@ -0,0 +1,11 @@
// "Replace with forEach" "INFORMATION"
import java.util.*;
class A {
void fun(List<String>... lists) {
Arrays.stream(lists).forEach(list -> list.add(""));
}
}

View File

@@ -0,0 +1,13 @@
// "Replace with forEach" "INFORMATION"
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;
class A {
public void foo(final Set<String> strings) throws FileNotFoundException {
strings.forEach(s -> new FileInputStream());
}
}

View File

@@ -0,0 +1,20 @@
// "Replace with forEach" "INFORMATION"
import java.util.*;
class A {
public static void main(String[] args) {
List<String> names = Arrays.asList("Bob", "Alice", "Bob", "Carol");
Set<String> uniqNames = new HashSet<>(names.size());
names.forEach(name -> uniqNames.add(makeNameUnique(name, uniqNames)));
uniqNames.forEach(System.out::println);
}
private static String makeNameUnique(final String name, final Set<String> uniqNames) {
if (uniqNames.contains(name)) {
return name + "1";
}
return name;
}
}

View File

@@ -1,4 +1,4 @@
// "Replace with forEach" "false"
// "Replace with forEach" "INFORMATION"
import java.util.*;
class A {

View File

@@ -1,4 +1,4 @@
// "Replace with forEach" "false"
// "Replace with forEach" "INFORMATION"
import java.io.FileInputStream;
import java.io.FileNotFoundException;

View File

@@ -1,4 +1,4 @@
// "Replace with forEach" "false"
// "Replace with forEach" "INFORMATION"
import java.util.*;
class A {