Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamToLoop/afterMapForEach.java
Vladimir Plyashkun 2d9369d983 CPP-16098 - Lags during inplace rename typing
- changed behaviour in safe way by introducing new method to check that particular expression does not depend
  on committed PSI

GitOrigin-RevId: f5ec732613cdafdcef8a1d48eb8d04135c634047
2019-05-03 01:39:50 +03:00

45 lines
1.3 KiB
Java

// "Fix all 'Stream API call chain can be replaced with loop' problems in file" "true"
import java.util.Map;
import java.util.function.BiConsumer;
public class Main {
void test(Map<String, Integer> map) {
for (Map.Entry<String, Integer> entry : map.entrySet()) {
String k = entry.getKey();
Integer v = entry.getValue();
if (k.isEmpty()) continue;
System.out.println("Key: " + k + "; value: " + v);
}
}
void test(Map<String, Integer> map, BiConsumer<String, Integer> consumer) {
int entry = 1;
for (Map.Entry<String, Integer> e : map.entrySet()) {
String key = e.getKey();
Integer value = e.getValue();
consumer.accept(key, value);
}
}
void test(Map<String, Integer> map, Map<String, Integer> otherMap) {
int entry = 1, e = 2, key = 3, value = 4;
for (Map.Entry<String, Integer> mapEntry : map.entrySet()) {
String k = mapEntry.getKey();
Integer v = mapEntry.getValue();
otherMap.putIfAbsent(k, v);
}
}
class X implements Map<String, String> {
class Y {
void test() {
for (Entry<String, String> entry : X.this.entrySet()) {
String k = entry.getKey();
String v = entry.getValue();
System.out.println(k + "-" + v);
}
}
}
}
}