set SPACE_BEFORE_COLON_IN_FOREACH true by default, fix tests

This commit is contained in:
Roman.Ivanov
2018-06-25 15:57:08 +07:00
parent c59f936afc
commit 5076e08145
110 changed files with 304 additions and 304 deletions

View File

@@ -104,7 +104,7 @@ public class JavaCodeStyleSettings extends CustomCodeStyleSettings implements Im
public static final int SHORTEN_NAMES_ALWAYS_AND_ADD_IMPORT = 3;
public int CLASS_NAMES_IN_JAVADOC = FULLY_QUALIFY_NAMES_IF_NOT_IMPORTED;
public boolean SPACE_BEFORE_COLON_IN_FOREACH = false;
public boolean SPACE_BEFORE_COLON_IN_FOREACH = true;
public boolean useFqNamesInJavadocAlways() {
return CLASS_NAMES_IN_JAVADOC == FULLY_QUALIFY_NAMES_ALWAYS;

View File

@@ -1,7 +1,7 @@
class Foo {
{
List list;
for (String s: list) {
for (String s : list) {
<caret>
}
}

View File

@@ -3,7 +3,7 @@ class Test2 {
void foo(final List<PatchLogger> loggers) {
final PatchLogger logger = logger1 -> {
for (PatchLogger logger2: loggers) {
for (PatchLogger logger2 : loggers) {
logger2.logOperation(logger1);
}
};

View File

@@ -3,7 +3,7 @@ class Test2 {
void foo(final List<PatchLogger> loggers) {
final PatchLogger logger = s -> {
for (PatchLogger logger1: loggers) {
for (PatchLogger logger1 : loggers) {
logger1.logOperation(s);
}
};

View File

@@ -3,7 +3,7 @@ import java.lang.annotation.Annotation;
// "Iterate" "true"
class Test {
void foo() {
for (Annotation annotation: getClass().getAnnotations()) {
for (Annotation annotation : getClass().getAnnotations()) {
}

View File

@@ -3,7 +3,7 @@ import java.lang.annotation.Annotation;
// "Iterate" "true"
class Test {
void foo() {
for (Annotation annotation: getClass().getAnnotations()) {
for (Annotation annotation : getClass().getAnnotations()) {
}

View File

@@ -7,7 +7,7 @@ public class Main {
public void test(Map<String, String[]> map) {
List<String> result = new ArrayList<>();
map.entrySet().stream().filter(entry -> entry.getKey().startsWith("x")).map(Map.Entry::getValue).forEach(arr -> {
for (String str: arr) {
for (String str : arr) {
result.add(str.trim() + arr.length);
}
});

View File

@@ -6,9 +6,9 @@ import static java.util.Arrays.asList;
public class Main {
public static boolean test(List<List<String>> list) {
for (List<String> x: list) {
for (List<String> x : list) {
if (x != null) {
for (String s: x) {
for (String s : x) {
if (!s.startsWith("a")) {
return false;
}
@@ -19,7 +19,7 @@ public class Main {
}
private static boolean testEqEq(List<String> list) {
for (String s: list) {
for (String s : list) {
if (s.trim() != s.toLowerCase()) {
return false;
}
@@ -30,9 +30,9 @@ public class Main {
public static void testIf(List<List<String>> list) {
boolean b = true;
OUTER:
for (List<String> x: list) {
for (List<String> x : list) {
if (x != null) {
for (String s: x) {
for (String s : x) {
if (!s.startsWith("a")) {
b = false;
break OUTER;
@@ -46,7 +46,7 @@ public class Main {
}
boolean testNot(String... strings) {
for (String s: strings) {
for (String s : strings) {
if (s != null) {
if (!s.startsWith("xyz")) {
return true;
@@ -58,7 +58,7 @@ public class Main {
public void testVar(List<Integer> list) {
boolean x = false;
for (Integer i: list) {
for (Integer i : list) {
if (i <= 2) {
x = true;
break;

View File

@@ -6,9 +6,9 @@ import static java.util.Arrays.asList;
public class Main {
public static boolean test(List<List<String>> list) {
for (List<String> x: list) {
for (List<String> x : list) {
if (x != null) {
for (String s: x) {
for (String s : x) {
if (s.startsWith("a")) {
return true;
}
@@ -19,7 +19,7 @@ public class Main {
}
String testTernary(String[] strings) {
for (String s: strings) {
for (String s : strings) {
if (s != null) {
if (!s.startsWith("xyz")) {
return "s";

View File

@@ -5,7 +5,7 @@ import java.util.List;
public class Main {
public boolean testCond(List<String> list) {
for (String s: list) {
for (String s : list) {
if (s.isEmpty()) {
return list.stream().anyMatch(Objects::isNull);
}

View File

@@ -6,7 +6,7 @@ import java.util.List;
public class Main {
public boolean testCond(List<String> list) {
boolean x = false;
for (String s: list) {
for (String s : list) {
if (s.isEmpty()) {
x = list.stream().anyMatch(Objects::isNull);
break;

View File

@@ -6,7 +6,7 @@ import java.util.List;
public class Main {
public boolean testCond(List<String> list) {
boolean b = true;
for (String s: list) {
for (String s : list) {
if (s.isEmpty()) {
b = false;
break;

View File

@@ -5,7 +5,7 @@ import java.util.List;
public class Main {
public boolean testCond(List<String> list) {
for (String s: list) {
for (String s : list) {
if (s.isEmpty()) {
return false;
}

View File

@@ -9,7 +9,7 @@ public class Main {
long count = 0L;
Set<Integer> uniqueValues = new HashSet<>();
boolean first = true;
for (Integer integer: new Integer[]{1, 2, 3, 2, 3}) {
for (Integer integer : new Integer[]{1, 2, 3, 2, 3}) {
if (first) {
first = false;
continue;

View File

@@ -7,7 +7,7 @@ public class Main {
private static OptionalDouble testDouble(long... numbers) {
double sum = 0;
long count = 0;
for (long x: numbers) {
for (long x : numbers) {
if (x > 0) {
double v = x;
sum += v;
@@ -20,7 +20,7 @@ public class Main {
private static OptionalDouble testInt(int... numbers) {
long sum = 0;
long count = 0;
for (int x: numbers) {
for (int x : numbers) {
if (x > 0) {
sum += x;
count++;
@@ -32,7 +32,7 @@ public class Main {
private static OptionalDouble testLong(long... numbers) {
long sum = 0;
long count = 0;
for (long x: numbers) {
for (long x : numbers) {
if (x > 0) {
sum += x;
count++;

View File

@@ -12,7 +12,7 @@ import java.util.stream.Stream;
public class Main {
public static void main(String[] args) {
List<String> list = Arrays.asList("a", "b", "c", "d");
for (String o: list) {
for (String o : list) {
if (!o.isEmpty()) {
System.out.println("Peek: " + o);
System.out.println("Peek2: " + o);
@@ -33,7 +33,7 @@ public class Main {
}
}
for (String s: list) {
for (String s : list) {
if ("b".equals(s)) {
System.out.println("Found:");
System.out.println(s);
@@ -41,7 +41,7 @@ public class Main {
}
}
Optional<String> found = Optional.empty();
for (String qq: list) {
for (String qq : list) {
if ("b".equals(qq)) {
found = Optional.of(qq);
break;
@@ -54,7 +54,7 @@ public class Main {
});
StringBuilder res = new StringBuilder();
for (String str: list) {
for (String str : list) {
if (str != null) {
str = "[" + str + "]";
res.append(str);
@@ -63,7 +63,7 @@ public class Main {
System.out.println(res);
long count = 0L;
for (String n: list) {
for (String n : list) {
if (!"a".equals(n)) {
for (int i = 0; i < 3; i++) {
System.out.println("In flatmap idx: " + i);
@@ -76,7 +76,7 @@ public class Main {
}
void test(List<String> list) {
for (String x: list) {
for (String x : list) {
if (x.isEmpty()) continue;
System.out.println(x);
}

View File

@@ -8,7 +8,7 @@ import java.util.stream.Collectors;
public class Main {
private static List<Integer> test(int[] numbers) {
List<Integer> list = new ArrayList<>();
for (int number: numbers) {
for (int number : numbers) {
Integer integer = number;
list.add(integer);
}

View File

@@ -14,7 +14,7 @@ public class Main {
public static OptionalInt min(IndexSet<?> set) {
boolean seen = false;
int best = 0;
for (Index index: set.asList()) {
for (Index index : set.asList()) {
int asInteger = index.asInteger();
if (!seen || asInteger < best) {
seen = true;

View File

@@ -7,7 +7,7 @@ import java.util.Objects;
public class Main {
private static void test(List<String> list) {
StringBuilder sb = new StringBuilder();
for (String str: list) {
for (String str : list) {
if (str != null) {
sb.append(str);
}

View File

@@ -19,7 +19,7 @@ public class Main {
private void collect() {
List<CharSequence> list = new ArrayList<>();
for (CharSequence charSequence: getListExtends()) {
for (CharSequence charSequence : getListExtends()) {
if (charSequence != null) {
list.add(charSequence);
}
@@ -30,7 +30,7 @@ public class Main {
private void collect2() {
List<List<? extends CharSequence>> list = new ArrayList<>();
for (CharSequence charSequence: getListExtends()) {
for (CharSequence charSequence : getListExtends()) {
List<? extends CharSequence> charSequences = asList(charSequence);
list.add(charSequences);
}
@@ -44,7 +44,7 @@ public class Main {
private void collectCustomList() {
MyList<? extends List<? extends CharSequence>> res2 =
new MyList<>();
for (CharSequence charSequence: getListExtends()) {
for (CharSequence charSequence : getListExtends()) {
List<? extends CharSequence> charSequences = asList(charSequence);
res2.add(charSequences);
}
@@ -60,7 +60,7 @@ public class Main {
private void collectGroupingByCustomList() {
Map<Integer, MyList2<? extends Number, CharSequence>> result = new HashMap<>();
for (CharSequence x: getList()) {
for (CharSequence x : getList()) {
result.computeIfAbsent(x.length(), k -> createMyList2()).add(x);
}
Map<Integer, ? extends MyList2<? extends Number, ? extends CharSequence>> map =
@@ -70,7 +70,7 @@ public class Main {
private void collectToMap() {
Map<CharSequence, List<? extends CharSequence>> result = new HashMap<>();
for (CharSequence charSequence: getList()) {
for (CharSequence charSequence : getList()) {
if (charSequence != null) {
if (result.put(charSequence, asList(charSequence)) != null) {
throw new IllegalStateException("Duplicate key");

View File

@@ -8,7 +8,7 @@ public class Main {
public void testAveragingDouble(String... list) {
double sum = 0;
long count = 0;
for (String s: list) {
for (String s : list) {
if (s != null) {
sum += 1.0 / s.length();
count++;
@@ -20,7 +20,7 @@ public class Main {
public void testAveragingInt(String... list) {
long sum = 0;
long count = 0;
for (String s: list) {
for (String s : list) {
if (s != null) {
sum += s.length();
count++;
@@ -31,7 +31,7 @@ public class Main {
public static long testCounting(List<String> strings) {
long count = 0L;
for (String s: strings) {
for (String s : strings) {
if (!s.isEmpty()) {
count++;
}
@@ -42,7 +42,7 @@ public class Main {
public static Optional<String> testMaxBy(List<String> strings) {
boolean seen = false;
String best = null;
for (String s: strings) {
for (String s : strings) {
if (!s.isEmpty()) {
if (!seen || s.compareTo(best) > 0) {
seen = true;
@@ -56,7 +56,7 @@ public class Main {
public static Optional<String> testReducing1(List<String> list) {
boolean seen = false;
String acc = null;
for (String s: list) {
for (String s : list) {
if (!seen) {
seen = true;
acc = s;
@@ -69,7 +69,7 @@ public class Main {
public static String testReducing2(List<String> list) {
String acc = "";
for (String s: list) {
for (String s : list) {
acc = acc + s;
}
return acc;
@@ -77,7 +77,7 @@ public class Main {
static Integer testReducing3() {
Integer totalLength = 0;
for (String s: Arrays.asList("a", "bb", "ccc")) {
for (String s : Arrays.asList("a", "bb", "ccc")) {
Integer length = s.length();
totalLength = totalLength + length;
}
@@ -86,7 +86,7 @@ public class Main {
public static DoubleSummaryStatistics testSummarizingDouble(List<String> strings) {
DoubleSummaryStatistics stat = new DoubleSummaryStatistics();
for (String str: strings) {
for (String str : strings) {
if (str != null) {
stat.accept(str.length() / 2.0);
}
@@ -96,7 +96,7 @@ public class Main {
public static Double testSummingDouble(List<String> strings) {
double sum = 0.0;
for (String string: strings) {
for (String string : strings) {
if (string != null) {
sum += string.length();
}
@@ -106,7 +106,7 @@ public class Main {
private static TreeSet<Integer> testToCollection() {
TreeSet<Integer> integers = new TreeSet<>();
for (int i: new int[]{4, 2, 1}) {
for (int i : new int[]{4, 2, 1}) {
Integer integer = i;
integers.add(integer);
}
@@ -116,7 +116,7 @@ public class Main {
// Unresolved reference
void f(Collection<? extends Foo> c) {
R treeSet = new TreeSet();
for (Foo foo: c) {
for (Foo foo : c) {
treeSet.add(foo);
}
Set<Foo> uniqueDescriptors = treeSet;

View File

@@ -9,7 +9,7 @@ public class Main {
public void test(List<String> list) {
List<String> result = new ArrayList<>();
Function<? super String, ? extends String> function = list.size() < 10 ? String::trim : Function.identity();
for (String s: list) {
for (String s : list) {
String s1 = function.apply(s);
result.add(s1);
}

View File

@@ -5,7 +5,7 @@ import java.util.List;
public class Main {
public long test(List<String> list) {
long count = 0L;
for (String s: list) {
for (String s : list) {
count++;
}
return count;
@@ -13,7 +13,7 @@ public class Main {
public void testAssign(List<String> list) {
long x = 0L;
for (String s: list) {
for (String s : list) {
x++;
}
System.out.println(x);
@@ -24,7 +24,7 @@ public class Main {
public long testNameConflict(List<Count> count) {
long result = 0L;
for (Count count1: count) {
for (Count count1 : count) {
result++;
}
return result;
@@ -33,7 +33,7 @@ public class Main {
public long testNoBlock(List<String> list) {
if(!list.isEmpty()) {
long count = 0L;
for (String s: list) {
for (String s : list) {
count++;
}
return count;

View File

@@ -10,7 +10,7 @@ public class Main {
public long testCount(List<String> list) {
long count = 0L;
Set<String> uniqueValues = new HashSet<>();
for (String s: list) {
for (String s : list) {
if (uniqueValues.add(s)) {
count++;
}
@@ -21,7 +21,7 @@ public class Main {
private static List<Object> testToList(List<? extends Number> numbers) {
List<Object> list = new ArrayList<>();
Set<Number> uniqueValues = new HashSet<>();
for (Number number: numbers) {
for (Number number : numbers) {
if (uniqueValues.add(number)) {
list.add(number);
}

View File

@@ -8,7 +8,7 @@ public class Main {
static {
List<String> list = new ArrayList<>();
for (String s: Arrays.asList("foo", "bar", "baz")) {
for (String s : Arrays.asList("foo", "bar", "baz")) {
String toUpperCase = s.toUpperCase();
list.add(toUpperCase);
}
@@ -19,7 +19,7 @@ public class Main {
{
StringJoiner joiner = new StringJoiner(",");
for (String s: STR) {
for (String s : STR) {
if (!s.isEmpty()) {
joiner.add(s);
}
@@ -35,7 +35,7 @@ public class Main {
{
long result = 0L;
for (Integer i: Arrays.asList(1, 2, 3, 4)) {
for (Integer i : Arrays.asList(1, 2, 3, 4)) {
if (i % 2 == 0) {
result++;
}
@@ -52,7 +52,7 @@ public class Main {
{
long result = 0L;
for (Integer i: Arrays.asList(1, 2, 3, 4)) {
for (Integer i : Arrays.asList(1, 2, 3, 4)) {
if (i % 2 == 0) {
result++;
}

View File

@@ -5,7 +5,7 @@ import java.util.Arrays;
public class Main {
private static long countInRange(int... input) {
long count = 0L;
for (int x: input) {
for (int x : input) {
if (x > 0) {
if (x < 10) {
count++;
@@ -18,7 +18,7 @@ public class Main {
private static long countInRange1(int... input) {
int x = 1;
long count = 0L;
for (int y: input) {
for (int y : input) {
if (y > 0) {
if (y < 10) {
count++;
@@ -32,7 +32,7 @@ public class Main {
int x = 1;
int y = 2;
long count = 0L;
for (int i: input) {
for (int i : input) {
if (i > 0) {
if (i < 10) {
count++;
@@ -47,7 +47,7 @@ public class Main {
int y = 2;
int i = 3;
long count = 0L;
for (int x1: input) {
for (int x1 : input) {
if (x1 > 0) {
if (x1 < 10) {
count++;
@@ -61,7 +61,7 @@ public class Main {
int x = 1;
int i = 3;
long result = 0L;
for (int count: input) {
for (int count : input) {
if (count > 0) {
if (count < 10) {
result++;

View File

@@ -7,9 +7,9 @@ import java.util.LongSummaryStatistics;
public class Main {
public static LongSummaryStatistics test(List<List<String>> list) {
LongSummaryStatistics stat = new LongSummaryStatistics();
for (List<String> a: list) {
for (List<String> a : list) {
if (a != null) {
for (String s: a) {
for (String s : a) {
long length = s.length();
stat.accept(length);
}

View File

@@ -6,7 +6,7 @@ import java.util.Optional;
public class Main {
private static test(List<String> packages) {
for (String s: packages) {
for (String s : packages) {
if (s.startsWith("xyz")) {
return Optional.of(s).filter(pkg -> pkg.endsWith("abc")).isPresent();
}

View File

@@ -8,7 +8,7 @@ import java.util.stream.Collectors;
public class Main {
private static List<Integer> getPositiveDoubled(int... input) {
List<Integer> list = new ArrayList<>();
for (int x: input) {
for (int x : input) {
if (x > 0) {
Integer integer = x * 2;
list.add(integer);

View File

@@ -8,7 +8,7 @@ interface Role {}
class FooRole {
public Role[] getRoles(Predicate<Object> p, List<Role> roles) {
List<Role> list = new ArrayList<>();
for (Role role: roles) {
for (Role role : roles) {
if (p.test(role)) {
list.add(role);
}

View File

@@ -7,7 +7,7 @@ import static java.util.Arrays.asList;
public class Main {
public static Optional<String> testSimple(List<String> list) {
for (String s: list) {
for (String s : list) {
return Optional.of(s);
}
return Optional.empty();
@@ -15,7 +15,7 @@ public class Main {
public void testAssign(List<String> list) {
String res = "";
for (String s: list) {
for (String s : list) {
String trim = s.trim();
if (!trim.isEmpty()) {
res = trim;
@@ -27,7 +27,7 @@ public class Main {
public void testAssignFinal(List<String> list) {
String res = "";
for (String s: list) {
for (String s : list) {
String trim = s.trim();
if (!trim.isEmpty()) {
res = trim;
@@ -38,9 +38,9 @@ public class Main {
}
public static Optional<String> testFlatMap(List<List<String>> list) {
for (List<String> x: list) {
for (List<String> x : list) {
if (x != null) {
for (String s: x) {
for (String s : x) {
return Optional.of(s);
}
}
@@ -54,9 +54,9 @@ public class Main {
for(int i=0; i<10; i++) {
String found = "";
OUTER1:
for (List<String> x: list) {
for (List<String> x : list) {
if (x != null) {
for (String s: x) {
for (String s : x) {
found = s;
break OUTER1;
}

View File

@@ -11,12 +11,12 @@ import static java.util.Arrays.asList;
public class Main {
private static long testChain(List<? extends String> list) {
long count = 0L;
for (Object o: Arrays.asList(0, null, "1", list)) {
for (Object o1: Arrays.asList(o)) {
for (Object o2: Arrays.asList(o1)) {
for (Object o3: Arrays.asList(o2)) {
for (Object o4: Arrays.asList(o3)) {
for (Object o5: Arrays.asList(o4)) {
for (Object o : Arrays.asList(0, null, "1", list)) {
for (Object o1 : Arrays.asList(o)) {
for (Object o2 : Arrays.asList(o1)) {
for (Object o3 : Arrays.asList(o2)) {
for (Object o4 : Arrays.asList(o3)) {
for (Object o5 : Arrays.asList(o4)) {
count++;
}
}
@@ -29,7 +29,7 @@ public class Main {
public static void testComplexFilter(List<String> list) {
List<Integer> result = new ArrayList<>();
for (String x: list) {
for (String x : list) {
if (x != null) {
Predicate<Integer> predicate = Predicate.isEqual(x.length());
for (int i = 0; i < 10; i++) {
@@ -44,9 +44,9 @@ public class Main {
}
public void testConditional(List<List<String>> list) {
for (List<String> lst: list) {
for (List<String> lst : list) {
if (lst != null) {
for (String s: lst) {
for (String s : lst) {
System.out.println(s);
}
}
@@ -55,9 +55,9 @@ public class Main {
private static long testDistinctUnpluralize(List<List<String>> nested) {
long count = 0L;
for (List<String> names: nested) {
for (List<String> names : nested) {
Set<String> uniqueValues = new HashSet<>();
for (String name: names) {
for (String name : names) {
if (uniqueValues.add(name)) {
count++;
}
@@ -129,8 +129,8 @@ public class Main {
private static List<String> testMethodRef(List<List<String>> list) {
List<String> result = new ArrayList<>();
for (List<String> strings: list) {
for (String string: strings) {
for (List<String> strings : list) {
for (String string : strings) {
result.add(string);
}
}
@@ -139,8 +139,8 @@ public class Main {
private static List<String> testMethodRef2(List<String[]> list) {
List<String> result = new ArrayList<>();
for (String[] strings: list) {
for (String t: strings) {
for (String[] strings : list) {
for (String t : strings) {
result.add(t);
}
}
@@ -149,8 +149,8 @@ public class Main {
private static List<List<String>> testMethodRef3(List<List<List<String>>> list) {
List<List<String>> result = new ArrayList<>();
for (List<List<String>> lists: list) {
for (List<String> strings: lists) {
for (List<List<String>> lists : list) {
for (List<String> strings : lists) {
result.add(strings);
}
}
@@ -159,10 +159,10 @@ public class Main {
private static long testBoundRename(Map<String, List<String>> strings) {
long count = 0L;
for (Map.Entry<String, List<String>> e: strings.entrySet()) {
for (Map.Entry<String, List<String>> e : strings.entrySet()) {
if (!e.getKey().isEmpty()) {
String sInner = e.getKey();
for (String s: e.getValue()) {
for (String s : e.getValue()) {
if (sInner.equals(s)) {
count++;
}
@@ -174,11 +174,11 @@ public class Main {
public static IntSummaryStatistics testNestedFlatMap(List<List<List<String>>> list) {
IntSummaryStatistics stat = new IntSummaryStatistics();
for (List<List<String>> l: list) {
for (List<List<String>> l : list) {
if (l != null) {
for (List<String> lst: l) {
for (List<String> lst : l) {
if (lst != null) {
for (String str: lst) {
for (String str : lst) {
int length = str.length();
stat.accept(length);
}
@@ -191,9 +191,9 @@ public class Main {
public static LongSummaryStatistics testNestedMap(List<List<String>> list) {
LongSummaryStatistics stat = new LongSummaryStatistics();
for (List<String> a: list) {
for (List<String> a : list) {
if (a != null) {
for (String s: a) {
for (String s : a) {
long length = s.length();
stat.accept(length);
}
@@ -205,7 +205,7 @@ public class Main {
public static IntSummaryStatistics testNestedSkip(int... values) {
IntSummaryStatistics stat = new IntSummaryStatistics();
long toSkipOuter = 2;
for (int x: values) {
for (int x : values) {
if (toSkipOuter > 0) {
toSkipOuter--;
continue;
@@ -227,7 +227,7 @@ public class Main {
public static IntSummaryStatistics testNestedSkip2(int... values) {
IntSummaryStatistics stat = new IntSummaryStatistics();
long toSkip = 2;
for (int x: values) {
for (int x : values) {
if (x > 0) {
long toSkipInner = x;
for (int i = 0; i < 100; i++) {
@@ -247,15 +247,15 @@ public class Main {
}
public String testSorted(List<List<String>> list) {
for (List<String> lst: list) {
for (List<String> lst : list) {
List<String> toSort = new ArrayList<>();
for (String x: lst) {
for (String x : lst) {
if (x != null) {
toSort.add(x);
}
}
toSort.sort(null);
for (String x: toSort) {
for (String x : toSort) {
if (x.length() < 5) {
return x;
}

View File

@@ -5,7 +5,7 @@ import java.util.List;
public class Main {
private static void test(List<String> list) {
for (String x: list) {
for (String x : list) {
if (x != null) {
System.out.println(x);
}

View File

@@ -12,7 +12,7 @@ public class Main {
private static long testFunctionInField(List<String> strings) {
long count = 0L;
for (String string: strings) {
for (String string : strings) {
if (nonEmpty.test(string)) {
count++;
}
@@ -23,7 +23,7 @@ public class Main {
private Set<Identifier> test(Set<Identifier> identifiers) {
Set<Identifier> set = new HashSet<>();
Predicate<? super Identifier> predicate = isReady(identifiers);
for (Identifier identifier: identifiers) {
for (Identifier identifier : identifiers) {
if (predicate.test(identifier)) {
set.add(identifier);
}
@@ -40,9 +40,9 @@ public class Main {
private static long testStreamOfFunctions(List<Predicate<String>> predicates, List<String> strings) {
long count = 0L;
for (Predicate<String> pred: predicates) {
for (Predicate<String> pred : predicates) {
if (pred != null) {
for (String string: strings) {
for (String string : strings) {
if (pred.test(string)) {
count++;
}

View File

@@ -7,7 +7,7 @@ import java.util.stream.Collectors;
public class Main {
public static Map<Integer, List<String>> testSimple(List<String> strings) {
Map<Integer, List<String>> map = new HashMap<>();
for (String str: strings) {
for (String str : strings) {
map.computeIfAbsent(str.length(), k -> new ArrayList<>()).add(str);
}
return map;
@@ -15,7 +15,7 @@ public class Main {
public static Map<Integer, List<String>> testVarConflict(List<String> strings, int k) {
Map<Integer, List<String>> map = new HashMap<>();
for (String string: strings) {
for (String string : strings) {
map.computeIfAbsent(string.length(), key -> new ArrayList<>()).add(string);
}
return map;
@@ -23,7 +23,7 @@ public class Main {
static void testCounting(List<String> list) {
Map<Integer, Long> map = new HashMap<>();
for (String s: list) {
for (String s : list) {
map.merge(s.length(), 1L, Long::sum);
}
System.out.println(map);
@@ -31,7 +31,7 @@ public class Main {
private static TreeMap<Integer, LinkedHashSet<String>> testCustomMap(List<String> strings) {
TreeMap<Integer, LinkedHashSet<String>> map = new TreeMap<>(Comparator.reverseOrder());
for (String string: strings) {
for (String string : strings) {
map.computeIfAbsent(string.length(), k -> new LinkedHashSet<>()).add(string);
}
return map;
@@ -39,7 +39,7 @@ public class Main {
static void testSummingDouble(List<String> list) {
Map<Integer, Double> map4 = new HashMap<>();
for (String s: list) {
for (String s : list) {
map4.merge(s.length(), (double) s.length(), Double::sum);
}
System.out.println(map4);
@@ -47,7 +47,7 @@ public class Main {
static void testMappingSummingInt(List<String> list) {
Map<Integer, Integer> map3 = new HashMap<>();
for (String s: list) {
for (String s : list) {
String trim = s.trim();
map3.merge(s.length(), trim.length(), Integer::sum);
}
@@ -56,7 +56,7 @@ public class Main {
public static void testGroupingGroupingToSet(List<String> strings) {
Map<Integer, Map<Character, Set<String>>> map = new HashMap<>();
for (String s: strings) {
for (String s : strings) {
map.computeIfAbsent(s.length(), key -> new HashMap<>()).computeIfAbsent(s.charAt(0), k -> new HashSet<>()).add(s);
}
System.out.println(map);
@@ -64,7 +64,7 @@ public class Main {
private static TreeMap<Integer, List<Integer>> testMappingToList(List<String> strings) {
TreeMap<Integer, List<Integer>> map = new TreeMap<>(Comparator.reverseOrder());
for (String string: strings) {
for (String string : strings) {
Integer len = string.length();
Integer integer = len * 2;
map.computeIfAbsent(string.length(), k -> new ArrayList<>()).add(integer);
@@ -74,7 +74,7 @@ public class Main {
public static void testSummarizingDouble(List<String> strings) {
Map<Integer, DoubleSummaryStatistics> map = new HashMap<>();
for (String string: strings) {
for (String string : strings) {
if (string != null) {
map.computeIfAbsent(string.length(), k -> new DoubleSummaryStatistics()).accept(string.length());
}
@@ -84,7 +84,7 @@ public class Main {
public static void testToMap(List<String> strings) {
Map<Integer, Map<Character, String>> map = new HashMap<>();
for (String s: strings) {
for (String s : strings) {
if (map.computeIfAbsent(s.length(), k -> new HashMap<>()).put(s.charAt(0), s) != null) {
throw new IllegalStateException("Duplicate key");
}
@@ -94,7 +94,7 @@ public class Main {
public static void testToSet(List<String> strings) {
Map<Integer, Set<String>> map = new HashMap<>();
for (String string: strings) {
for (String string : strings) {
if (string != null) {
map.computeIfAbsent(string.length(), k -> new HashSet<>()).add(string);
}

View File

@@ -5,7 +5,7 @@ import java.util.List;
public class Main {
private static void test(List<String> list) {
for (String x: list) {
for (String x : list) {
if (x != null) {
if (x.startsWith("x")) {
System.out.println("Ok!");

View File

@@ -6,7 +6,7 @@ import java.util.stream.*;
public class Main {
private static void test(List<String> test) {
StringBuilder sb = new StringBuilder();
for (String s: test) {
for (String s : test) {
sb.append(s);
}
System.out.println("x"+ sb.toString() +"y");

View File

@@ -8,18 +8,18 @@ import java.util.stream.Stream;
public class InExactVariable {
public void testMap() {
HashMap<String, String> map = new HashMap<>();
for (Integer integer2: Arrays.asList(1, 2, 3, 4)) {
for (Integer integer2 : Arrays.asList(1, 2, 3, 4)) {
String of = String.valueOf(integer2);
map.putIfAbsent(of.trim(), of);
}
Object map1 = map;
HashMap<String, String> map2 = new HashMap<>();
for (Integer integer1: Arrays.asList(1, 2, 3, 4)) {
for (Integer integer1 : Arrays.asList(1, 2, 3, 4)) {
String valueOf = String.valueOf(integer1);
map2.putIfAbsent(valueOf.trim(), valueOf);
}
Map<String, String> map3 = new HashMap<>();
for (Integer integer: Arrays.asList(1, 2, 3, 4)) {
for (Integer integer : Arrays.asList(1, 2, 3, 4)) {
String s = String.valueOf(integer);
map3.putIfAbsent(s.trim(), s);
}
@@ -27,34 +27,34 @@ public class InExactVariable {
public void testList() {
List<String> result1 = new ArrayList<>();
for (Integer integer5: Arrays.asList(1, 2, 3, 4)) {
for (Integer integer5 : Arrays.asList(1, 2, 3, 4)) {
String valueOf1 = String.valueOf(integer5);
result1.add(valueOf1);
}
Object list1 = result1;
List<String> result = new ArrayList<>();
for (Integer integer4: Arrays.asList(1, 2, 3, 4)) {
for (Integer integer4 : Arrays.asList(1, 2, 3, 4)) {
String s1 = String.valueOf(integer4);
result.add(s1);
}
Iterable<String> list2 = result;
Collection<String> list3 = new ArrayList<>();
for (Integer integer3: Arrays.asList(1, 2, 3, 4)) {
for (Integer integer3 : Arrays.asList(1, 2, 3, 4)) {
String value = String.valueOf(integer3);
list3.add(value);
}
List<String> list4 = new ArrayList<>();
for (Integer integer2: Arrays.asList(1, 2, 3, 4)) {
for (Integer integer2 : Arrays.asList(1, 2, 3, 4)) {
String of = String.valueOf(integer2);
list4.add(of);
}
Collection<Object> list5 = new ArrayList<>();
for (Integer integer1: Arrays.asList(1, 2, 3, 4)) {
for (Integer integer1 : Arrays.asList(1, 2, 3, 4)) {
String valueOf = String.valueOf(integer1);
list5.add(valueOf);
}
List<String> list = new ArrayList<>();
for (Integer integer: Arrays.asList(1, 2, 3, 4)) {
for (Integer integer : Arrays.asList(1, 2, 3, 4)) {
String s = String.valueOf(integer);
list.add(s);
}
@@ -65,7 +65,7 @@ public class InExactVariable {
Map<Boolean, List<String>> map = new HashMap<>();
map.put(false, new ArrayList<>());
map.put(true, new ArrayList<>());
for (Integer integer1: Arrays.asList(1, 2, 3, 4)) {
for (Integer integer1 : Arrays.asList(1, 2, 3, 4)) {
String s = String.valueOf(integer1);
map.get(s.length() > 1).add(s);
}
@@ -73,7 +73,7 @@ public class InExactVariable {
Map<Boolean, List<String>> map2 = new HashMap<>();
map2.put(false, new ArrayList<>());
map2.put(true, new ArrayList<>());
for (Integer integer: Arrays.asList(1, 2, 3, 4)) {
for (Integer integer : Arrays.asList(1, 2, 3, 4)) {
String x = String.valueOf(integer);
map2.get(x.length() > 1).add(x);
}
@@ -81,28 +81,28 @@ public class InExactVariable {
public void testGroupingBy() {
TreeMap<Integer, Set<String>> result = new TreeMap<>();
for (Integer integer4: Arrays.asList(1, 2, 3, 4)) {
for (Integer integer4 : Arrays.asList(1, 2, 3, 4)) {
String s1 = String.valueOf(integer4);
result.computeIfAbsent(s1.length(), k2 -> new HashSet<>()).add(s1);
}
Object map1 = result;
TreeMap<Integer, Set<String>> map2 = new TreeMap<>();
for (Integer integer3: Arrays.asList(1, 2, 3, 4)) {
for (Integer integer3 : Arrays.asList(1, 2, 3, 4)) {
String value = String.valueOf(integer3);
map2.computeIfAbsent(value.length(), key1 -> new HashSet<>()).add(value);
}
NavigableMap<Integer, Set<String>> map3 = new TreeMap<>();
for (Integer integer2: Arrays.asList(1, 2, 3, 4)) {
for (Integer integer2 : Arrays.asList(1, 2, 3, 4)) {
String of = String.valueOf(integer2);
map3.computeIfAbsent(of.length(), k1 -> new HashSet<>()).add(of);
}
SortedMap<Integer, Set<String>> map4 = new TreeMap<>();
for (Integer integer1: Arrays.asList(1, 2, 3, 4)) {
for (Integer integer1 : Arrays.asList(1, 2, 3, 4)) {
String valueOf = String.valueOf(integer1);
map4.computeIfAbsent(valueOf.length(), key -> new HashSet<>()).add(valueOf);
}
TreeMap<Integer, Set<String>> map = new TreeMap<>();
for (Integer integer: Arrays.asList(1, 2, 3, 4)) {
for (Integer integer : Arrays.asList(1, 2, 3, 4)) {
String s = String.valueOf(integer);
map.computeIfAbsent(s.length(), k -> new HashSet<>()).add(s);
}

View File

@@ -10,7 +10,7 @@ public class Main {
DoubleSupplier s = () -> {
long sum = 0;
long count = 0;
for (String s1: list) {
for (String s1 : list) {
if (s1 != null) {
sum += s1.length();
count++;

View File

@@ -6,7 +6,7 @@ import java.util.stream.Stream;
public class Main {
public void test(String... list) {
Runnable s = () -> {
for (String s1: list) {
for (String s1 : list) {
if (s1 != null) {
System.out.println(s1);
}

View File

@@ -6,7 +6,7 @@ public class Main {
private static Optional<String> max(List<?> list) {
boolean seen = false;
String best = null;
for (Object o: list) {
for (Object o : list) {
if (o instanceof String[]) {
String[] x = (String[]) o;
String s = x[0];

View File

@@ -6,27 +6,27 @@ import java.util.stream.Stream;
public class Main {
public void testCast(Object obj, List<Object> list) {
for (Number n: ((Iterable<Number>) obj)) {
for (Number n : ((Iterable<Number>) obj)) {
list.add(n);
}
}
public static void main(String[] args) {
List<String> list = Arrays.asList("a", "b");
for (String s: list) {
for (String s : list) {
System.out.println(s);
}
}
public static <T extends Collection<?>> T test(T collection) {
for (Object o: collection) {
for (Object o : collection) {
System.out.println(o);
}
return collection;
}
void testRawTypeSupport(List<List> list) {
for (List l: list) {
for (List l : list) {
System.out.println(l.size());
}
}
@@ -36,7 +36,7 @@ public class Main {
Set<? extends SomeInterface> nodes();
default void accept(Visitor visitor) {
for (SomeInterface child: new LinkedHashSet<>(this.nodes())) {
for (SomeInterface child : new LinkedHashSet<>(this.nodes())) {
child.accept(visitor);
}
}

View File

@@ -14,7 +14,7 @@ class Collectors {
class MyFile {
public static List<String> testList(String[] args) {
List<String> result = new ArrayList<>();
for (String arg: args) {
for (String arg : args) {
if (arg != null) {
result.add(arg);
}
@@ -25,7 +25,7 @@ class MyFile {
public static Set<String> testSet(String[] args) {
Set<String> set = new HashSet<>();
for (String arg: args) {
for (String arg : args) {
if (arg != null) {
set.add(arg);
}
@@ -35,7 +35,7 @@ class MyFile {
public static Map<String, String> testMap(String[] args) {
Map<String, String> map = new HashMap<>();
for (String arg: args) {
for (String arg : args) {
if (arg != null) {
if (map.put(arg.trim(), arg) != null) {
throw new IllegalStateException("Duplicate key");

View File

@@ -6,7 +6,7 @@ import java.util.List;
public class Main {
private static long countNonEmpty(List<String> input) {
long count = 0L;
for (String str: input) {
for (String str : input) {
String trim = str.trim();
if (!trim.isEmpty()) {
count++;

View File

@@ -5,7 +5,7 @@ import java.util.function.BiConsumer;
public class Main {
void test(Map<String, Integer> map) {
for (Map.Entry<String, Integer> entry: map.entrySet()) {
for (Map.Entry<String, Integer> entry : map.entrySet()) {
String k = entry.getKey();
Integer v = entry.getValue();
if (k.isEmpty()) continue;
@@ -15,7 +15,7 @@ public class Main {
void test(Map<String, Integer> map, BiConsumer<String, Integer> consumer) {
int entry = 1;
for (Map.Entry<String, Integer> e: map.entrySet()) {
for (Map.Entry<String, Integer> e : map.entrySet()) {
String key = e.getKey();
Integer value = e.getValue();
consumer.accept(key, value);
@@ -24,7 +24,7 @@ public class Main {
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()) {
for (Map.Entry<String, Integer> mapEntry : map.entrySet()) {
String k = mapEntry.getKey();
Integer v = mapEntry.getValue();
otherMap.putIfAbsent(k, v);

View File

@@ -6,7 +6,7 @@ import java.util.stream.Collectors;
public class Main {
private static void getMap(List<String> strings) {
List<Integer> list = new ArrayList<>();
for (String string: strings) {
for (String string : strings) {
Integer len = string.length();
Integer integer = len * 2;
list.add(integer);

View File

@@ -6,7 +6,7 @@ import java.util.Objects;
public class Main {
private static void test(List<String> names) {
for (String name: names) {
for (String name : names) {
if (name != null) {
System.out.println(name);
}
@@ -19,7 +19,7 @@ public class Main {
private static boolean testBound(List<String> strings) {
String s = getString();
for (String string: strings) {
for (String string : strings) {
if (s.equals(string)) {
return true;
}

View File

@@ -8,7 +8,7 @@ public class Main {
boolean seen = false;
String best = null;
Comparator<String> comparator = Comparator.comparing(String::length);
for (String string: strings) {
for (String string : strings) {
if (!seen || comparator.compare(string, best) > 0) {
seen = true;
best = string;
@@ -20,7 +20,7 @@ public class Main {
public static OptionalDouble testMaxDouble(List<String> strings) {
boolean seen = false;
double best = 0;
for (String string: strings) {
for (String string : strings) {
double length = string.length();
if (!seen || Double.compare(length, best) > 0) {
seen = true;
@@ -33,7 +33,7 @@ public class Main {
private static Optional<String> testMaxLambda(Map<String, List<String>> dependencies, String fruits, Map<String, Integer> weights) {
boolean seen = false;
String best = null;
for (String s: dependencies.get(fruits)) {
for (String s : dependencies.get(fruits)) {
if (!seen || weights.get(s) - weights.get(best) > 0) {
seen = true;
best = s;
@@ -45,7 +45,7 @@ public class Main {
private static Optional<String> testMaxLambdaTernary(Map<String, List<String>> dependencies, String fruits, Map<String, String> weights) {
boolean seen = false;
String best = null;
for (String s: dependencies.get(fruits)) {
for (String s : dependencies.get(fruits)) {
if (!seen || (s.compareTo(best) < 0 ? -1 : s.compareTo(best) > 0 ? 1 : 0) > 0) {
seen = true;
best = s;
@@ -57,7 +57,7 @@ public class Main {
private static Optional<String> testMaxReverseOrder(Map<String, List<String>> dependencies, String fruits, Map<String, String> weights) {
boolean seen = false;
String best = null;
for (String s: dependencies.get(fruits)) {
for (String s : dependencies.get(fruits)) {
if (!seen || best.compareTo(s) > 0) {
seen = true;
best = s;
@@ -69,7 +69,7 @@ public class Main {
public static String testMinPassedComparator(List<String> strings, Comparator<String> cmp) {
boolean seen = false;
String best = null;
for (String string: strings) {
for (String string : strings) {
if (!seen || cmp.compare(string, best) < 0) {
seen = true;
best = string;
@@ -82,7 +82,7 @@ public class Main {
boolean seen = false;
String best = null;
Comparator<CharSequence> comparator1 = comparator.reversed();
for (String string: strings) {
for (String string : strings) {
if (!seen || comparator1.compare(string, best) < 0) {
seen = true;
best = string;
@@ -94,7 +94,7 @@ public class Main {
public static int testMinInt(List<String> strings, IntSupplier supplier) {
boolean seen = false;
int best = 0;
for (String string: strings) {
for (String string : strings) {
int length = string.length();
if (!seen || length < best) {
seen = true;
@@ -106,7 +106,7 @@ public class Main {
public static int testMinMaxValue(List<String> strings) {
int best = Integer.MAX_VALUE;
for (String string: strings) {
for (String string : strings) {
int length = string.length();
if (length < best)
best = length;
@@ -116,7 +116,7 @@ public class Main {
public static long testMaxMinValue(List<String> strings) {
long max = Long.MIN_VALUE;
for (String string: strings) {
for (String string : strings) {
long length = string.length();
if (length > max)
max = length;

View File

@@ -10,7 +10,7 @@ import static java.util.Arrays.asList;
public class Main {
public static long testNestedScope(List<String> list) {
long count = 0L;
for (String l: list) {
for (String l : list) {
if (l != null) {
(new Consumer<String>() {
String lst = "hello";
@@ -27,7 +27,7 @@ public class Main {
public static long testNestedScope2(List<String> list) {
long count = 0L;
for (String l: list) {
for (String l : list) {
if (l != null) {
(new Consumer<String>() {
String list = "hello";
@@ -44,7 +44,7 @@ public class Main {
private static long testAnonymousConflictingVar(Map<String, List<String>> strings) {
long sum = 0L;
for (Map.Entry<String, List<String>> e: strings.entrySet()) {
for (Map.Entry<String, List<String>> e : strings.entrySet()) {
if (!e.getKey().isEmpty()) {
long count = e.getValue().stream().filter(new Predicate<>() {
// we're inside anonymous class
@@ -61,7 +61,7 @@ public class Main {
private static long testLambdaConflictingVar(Map<String, List<String>> strings) {
long sum = 0L;
for (Map.Entry<String, List<String>> e: strings.entrySet()) {
for (Map.Entry<String, List<String>> e : strings.entrySet()) {
if (!e.getKey().isEmpty()) {
long count = count(e.getValue(), s -> e.getKey().equals(s));
sum += count;
@@ -72,7 +72,7 @@ public class Main {
private static long testLambdaNotConflictingVar(Map<String, List<String>> strings) {
long sum = 0L;
for (Map.Entry<String, List<String>> s: strings.entrySet()) {
for (Map.Entry<String, List<String>> s : strings.entrySet()) {
if (!s.getKey().isEmpty()) {
long count = count(s.getValue(), sx -> s.getKey().equals(sx));
sum += count;

View File

@@ -6,9 +6,9 @@ import static java.util.Arrays.asList;
public class Main {
public static boolean test(List<List<String>> list) {
for (List<String> x: list) {
for (List<String> x : list) {
if (x != null) {
for (String str: x) {
for (String str : x) {
if (str.startsWith("a")) {
return false;
}

View File

@@ -6,7 +6,7 @@ public class Main {
private static String testOrElse(List<String> list) {
if (list == null) return null;
else {
for (String str: list) {
for (String str : list) {
if (str.contains("x")) {
return str;
}
@@ -18,7 +18,7 @@ public class Main {
private static String testOrElseGet(List<String> list) {
if (list == null) return null;
else {
for (String str: list) {
for (String str : list) {
if (str.contains("x")) {
return str;
}
@@ -28,7 +28,7 @@ public class Main {
}
private static void testIfPresent(List<String> list) {
for (String str: list) {
for (String str : list) {
if (str.contains("x")) {
System.out.println(str);
break;
@@ -37,9 +37,9 @@ public class Main {
}
public static boolean testIsPresent(List<List<String>> list) {
for (List<String> strings: list) {
for (List<String> strings : list) {
if (strings != null) {
for (String string: strings) {
for (String string : strings) {
return true;
}
}
@@ -48,9 +48,9 @@ public class Main {
}
static String testIsPresentNotTernary(List<List<String>> strings) {
for (List<String> string: strings) {
for (List<String> string : strings) {
if (string != null) {
for (String s: string) {
for (String s : string) {
return "abc";
}
}

View File

@@ -8,7 +8,7 @@ public class Test extends ArrayList<String> {
@Override
public void run() {
int sum = 0;
for (String s: Test.this) {
for (String s : Test.this) {
int length = s.length();
sum += length;
}

View File

@@ -9,7 +9,7 @@ public class Main {
Map<Boolean, List<String>> map = new HashMap<>();
map.put(false, new ArrayList<>());
map.put(true, new ArrayList<>());
for (String s: strings) {
for (String s : strings) {
if (!s.isEmpty()) {
map.get(s.length() > 1).add(s);
}
@@ -21,7 +21,7 @@ public class Main {
Map<Boolean, Long> map2 = new HashMap<>();
map2.put(false, 0L);
map2.put(true, 0L);
for (String s: list) {
for (String s : list) {
map2.merge(s.isEmpty(), 1L, Long::sum);
}
System.out.println(map2);
@@ -31,7 +31,7 @@ public class Main {
Map<Boolean, Double> map1 = new HashMap<>();
map1.put(false, 0.0);
map1.put(true, 0.0);
for (String s: list) {
for (String s : list) {
map1.merge(s.isEmpty(), (double) s.length(), Double::sum);
}
System.out.println(map1);
@@ -42,7 +42,7 @@ public class Main {
new HashMap<>();
nestedMap.put(false, new HashMap<>());
nestedMap.put(true, new HashMap<>());
for (String s: strings) {
for (String s : strings) {
nestedMap.get(s.length() > 2).computeIfAbsent(s.charAt(0), k -> new HashSet<>()).add(s);
}
System.out.println(nestedMap);
@@ -52,7 +52,7 @@ public class Main {
Map<Boolean, LinkedHashSet<String>> map = new HashMap<>();
map.put(false, new LinkedHashSet<>());
map.put(true, new LinkedHashSet<>());
for (String s: strings) {
for (String s : strings) {
map.get(s.length() > 2).add(s);
}
System.out.println(map);
@@ -63,7 +63,7 @@ public class Main {
Map<Boolean, Map<String, Integer>> map = new HashMap<>();
map.put(false, new HashMap<>());
map.put(true, new HashMap<>());
for (String string: strings) {
for (String string : strings) {
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");

View File

@@ -7,7 +7,7 @@ import java.util.LongSummaryStatistics;
public class Main {
public static int test(List<String> list) {
int sum = 0;
for (String s: list) {
for (String s : list) {
System.out.println(s);
int length = s.length();
sum += length;
@@ -17,7 +17,7 @@ public class Main {
public static LongSummaryStatistics testSummaryStatistics(List<String> list) {
LongSummaryStatistics stat = new LongSummaryStatistics();
for (String s: list) {
for (String s : list) {
System.out.println(s);
long length = s.length();
stat.accept(length);

View File

@@ -11,7 +11,7 @@ import static java.util.Arrays.asList;
public class Main {
public static String testReduce2(List<String> list) {
String acc = "";
for (String s: list) {
for (String s : list) {
acc = acc + s;
}
return acc;
@@ -19,7 +19,7 @@ public class Main {
public static int testReduce3(List<String> list) {
Integer acc = 0;
for (String s: list) {
for (String s : list) {
acc = acc + s.length();
}
return acc;
@@ -27,7 +27,7 @@ public class Main {
private static Integer testReduceMethodRef(List<Integer> numbers) {
Integer acc = 0;
for (Integer number: numbers) {
for (Integer number : numbers) {
acc = Math.max(acc, number);
}
return acc;
@@ -36,7 +36,7 @@ public class Main {
private static OptionalInt testReduceOptionalInt() {
boolean seen = false;
int acc = 0;
for (int i: new int[]{}) {
for (int i : new int[]{}) {
if (!seen) {
seen = true;
acc = i;
@@ -50,7 +50,7 @@ public class Main {
private static Optional<Integer> testReduceOptionalInteger(Integer... numbers) {
boolean seen = false;
Integer acc = null;
for (Integer number: numbers) {
for (Integer number : numbers) {
if (!seen) {
seen = true;
acc = number;

View File

@@ -7,7 +7,7 @@ public class Main {
private static void test(List<String> list) {
// and filter!
long count1 = 0L;
for (String s: list) {
for (String s : list) {
if (!s/* comment */.isEmpty()) {
count1++;
}

View File

@@ -7,7 +7,7 @@ public class Main {
long count = 0L;
Set<Object> uniqueValues = new HashSet<>();
long toSkip = list.size() / 2;
for (Object o: list) {
for (Object o : list) {
if (toSkip > 0) {
toSkip--;
continue;

View File

@@ -8,7 +8,7 @@ public class Main {
StringBuilder sb = new StringBuilder();
Set<CharSequence> uniqueValues = new HashSet<>();
boolean first = true;
for (CharSequence charSequence: list) {
for (CharSequence charSequence : list) {
if (first) {
first = false;
continue;
@@ -25,7 +25,7 @@ public class Main {
long toSkip = 2;
Set<CharSequence> uniqueValues = new HashSet<>();
boolean first = true;
for (CharSequence charSequence: list) {
for (CharSequence charSequence : list) {
if (first) {
first = false;
continue;
@@ -45,7 +45,7 @@ public class Main {
StringJoiner joiner = new StringJoiner(delimiter, "<", ">");
Set<CharSequence> uniqueValues = new HashSet<>();
boolean first = true;
for (CharSequence charSequence: list) {
for (CharSequence charSequence : list) {
if (first) {
first = false;
continue;

View File

@@ -6,7 +6,7 @@ import java.util.stream.*;
public class Main {
public List<String> testSorted(List<String> list) {
List<String> toSort = new ArrayList<>();
for (String s: list) {
for (String s : list) {
if (s != null) {
toSort.add(s);
}
@@ -14,7 +14,7 @@ public class Main {
toSort.sort(null);
List<String> result = new ArrayList<>();
Set<String> uniqueValues = new HashSet<>();
for (String s: toSort) {
for (String s : toSort) {
String trim = s.trim();
if (uniqueValues.add(trim)) {
result.add(trim);
@@ -25,7 +25,7 @@ public class Main {
public List<String> testSortedComparator(List<String> list) {
List<String> result = new ArrayList<>();
for (String s: list) {
for (String s : list) {
result.add(s);
}
result.sort(String.CASE_INSENSITIVE_ORDER);
@@ -34,7 +34,7 @@ public class Main {
public List<String> testSortedToArray(List<String> list) {
List<String> result = new ArrayList<>();
for (String s: list) {
for (String s : list) {
result.add(s);
}
result.sort(null);

View File

@@ -8,7 +8,7 @@ public class Main {
public void test(List<String> list) {
long i = 0L;
for (String s: list) {
for (String s : list) {
if (s.isEmpty()) {
i++;
}
@@ -21,7 +21,7 @@ public class Main {
{
long j = 0L;
for (String s: list) {
for (String s : list) {
if (s.isEmpty()) {
j++;
}
@@ -36,7 +36,7 @@ public class Main {
System.out.println(j);
StringJoiner joiner = new StringJoiner(",");
for (String s1: list) {
for (String s1 : list) {
joiner.add(s1);
}
for(String s = joiner.toString(); !s.isEmpty(); s = s.substring(1)) {

View File

@@ -9,7 +9,7 @@ import java.util.stream.Stream;
public class Main {
private static IntSummaryStatistics testOfArray() {
IntSummaryStatistics stat = new IntSummaryStatistics();
for (Integer i: new Integer[] /*create array*/{1, 2, 3}) {
for (Integer i : new Integer[] /*create array*/{1, 2, 3}) {
int i1 = i;
stat.accept(i1);
}
@@ -18,7 +18,7 @@ public class Main {
private static IntSummaryStatistics testOfArrayAsElement() {
IntSummaryStatistics stat = new IntSummaryStatistics();
for (Number[] nums: Arrays.<Number[]>asList(new Integer[]{1, 2, 3})) {
for (Number[] nums : Arrays.<Number[]>asList(new Integer[]{1, 2, 3})) {
int num = (int) nums[0];
stat.accept(num);
}
@@ -27,7 +27,7 @@ public class Main {
private static IntSummaryStatistics testOfSupplier() {
IntSummaryStatistics stat = new IntSummaryStatistics();
for (Supplier<Integer> sup: Arrays.<Supplier<Integer>>asList(() -> 1, /*between*/ () /*supply 2*/ -> 2, () -> 3)) {
for (Supplier<Integer> sup : Arrays.<Supplier<Integer>>asList(() -> 1, /*between*/ () /*supply 2*/ -> 2, () -> 3)) {
int i = sup.get();
stat.accept(i);
}
@@ -36,7 +36,7 @@ public class Main {
private static IntSummaryStatistics testIntStreamOf() {
IntSummaryStatistics stat = new IntSummaryStatistics();
for (int i: new int[]{1,/*two*/2,/*three*/3}) {
for (int i : new int[]{1,/*two*/2,/*three*/3}) {
stat.accept(i);
}
return stat;
@@ -44,7 +44,7 @@ public class Main {
private static IntSummaryStatistics testIntStreamOfArray() {
IntSummaryStatistics stat = new IntSummaryStatistics();
for (int i: new int[]{1, 2, 3}) {
for (int i : new int[]{1, 2, 3}) {
stat.accept(i);
}
return stat;

View File

@@ -14,7 +14,7 @@ public class Main {
Child() {
super(false);
boolean b = false;
for (String s: Arrays.asList("a", "b", "c")) {
for (String s : Arrays.asList("a", "b", "c")) {
if (s != null) {
b = true;
break;

View File

@@ -26,8 +26,8 @@ public class Test {
List<String> xyz = new ArrayList<>();
boolean dropping = true;
OUTER:
for (String s: data) {
for (String s1: Arrays.asList(s, s + s)) {
for (String s : data) {
for (String s1 : Arrays.asList(s, s + s)) {
if (s1.isEmpty()) {
break OUTER;
}

View File

@@ -7,7 +7,7 @@ import java.util.stream.Stream;
public class Main {
private static Object[] test(int[] numbers) {
List<Integer> list = new ArrayList<>();
for (int number: numbers) {
for (int number : numbers) {
Integer integer = number;
list.add(integer);
}
@@ -16,7 +16,7 @@ public class Main {
private static Integer[][] test2d(int[] numbers) {
List<Integer[]> list = new ArrayList<>();
for (int number: numbers) {
for (int number : numbers) {
Integer n = number;
Integer[] integers = new Integer[]{n};
list.add(integers);
@@ -26,7 +26,7 @@ public class Main {
private static Number[] testCovariant(int[] numbers) {
List<Integer> list = new ArrayList<>();
for (int number: numbers) {
for (int number : numbers) {
Integer integer = number;
list.add(integer);
}
@@ -35,7 +35,7 @@ public class Main {
private static Number[] testCovariantLambda(int[] numbers) {
List<Integer> list = new ArrayList<>();
for (int number: numbers) {
for (int number : numbers) {
Integer integer = number;
list.add(integer);
}
@@ -44,7 +44,7 @@ public class Main {
private static <A> A[] toArraySkippingNulls(List<?> list, IntFunction<A[]> generator) {
List<Object> result = new ArrayList<>();
for (Object o: list) {
for (Object o : list) {
if (o != null) {
result.add(o);
}
@@ -54,7 +54,7 @@ public class Main {
private static List<?>[] testGeneric(int[] numbers) {
List<List<Integer>> list = new ArrayList<>();
for (int number: numbers) {
for (int number : numbers) {
Integer n = number;
List<Integer> integers = Collections.singletonList(n);
list.add(integers);
@@ -64,7 +64,7 @@ public class Main {
private static Number[] testTypeMismatch(Object[] objects) {
List<Object> list = new ArrayList<>();
for (Object object: objects) {
for (Object object : objects) {
if (object instanceof Number) {
list.add(object);
}
@@ -76,7 +76,7 @@ public class Main {
private static Class<?>[] resolver(String list) {
// convert to loop
List<Class<?>> result = new ArrayList<>();
for (String s: list.split(",")) {
for (String s : list.split(",")) {
Class<?> aClass = loadType(s);
result.add(aClass);
}

View File

@@ -7,7 +7,7 @@ import java.util.stream.Collectors;
public class Main {
public static Map<Integer, String> test(List<String> strings) {
Map<Integer, String> mapping = new HashMap<>();
for (String str: strings) {
for (String str : strings) {
if (mapping.put(str.length(), str) != null) {
throw new IllegalStateException("Duplicate key");
}
@@ -17,7 +17,7 @@ public class Main {
public static Map<Integer, String> testMerge(List<String> strings) {
Map<Integer, String> map = new HashMap<>();
for (String s: strings) {
for (String s : strings) {
if (!s.isEmpty()) {
map.merge(s.length(), s, String::concat);
}
@@ -27,7 +27,7 @@ public class Main {
public static TreeMap<Integer, String> testPut(List<String> strings) {
TreeMap<Integer, String> map = new TreeMap<>();
for (String s1: strings) {
for (String s1 : strings) {
if (!s1.isEmpty()) {
map.put(s1.length(), s1.trim());
}
@@ -37,7 +37,7 @@ public class Main {
public static TreeMap<Integer, String> testSupplier(List<String> strings) {
TreeMap<Integer, String> map = new TreeMap<>();
for (String s1: strings) {
for (String s1 : strings) {
if (!s1.isEmpty()) {
map.putIfAbsent(s1.length(), s1);
}

View File

@@ -19,13 +19,13 @@ public class Main {
public int[] testPrimitive(List<String> list) {
List<String> toSort = new ArrayList<>();
for (String s: list) {
for (String s : list) {
toSort.add(s);
}
toSort.sort(null);
int[] ints = new int[10];
int count = 0;
for (String s: toSort) {
for (String s : toSort) {
int length = s.length();
if (ints.length == count) ints = Arrays.copyOf(ints, count * 2);
ints[count++] = length;

View File

@@ -13,7 +13,7 @@ public class Test {
public static void main(String[] args) {
List<String> list = new ArrayList<>();
for (String s: Arrays.asList("a", "b", "c")) {
for (String s : Arrays.asList("a", "b", "c")) {
String doProcess = doProcess(s);
list.add(doProcess);
}

View File

@@ -5,7 +5,7 @@ class Main2 {
public static void main(String[] args) {
List<Process> processList = null;
if (processList != null) {
for (Process process: processList) {
for (Process process : processList) {
System.out.println("process = " + process);
}
}

View File

@@ -4,7 +4,7 @@ import java.util.Map;
class Foo {
void foo(Map<File, Object> files, File file, Object filx) {
for (File file1: file.) {
for (File file1 : file.) {
}
}

View File

@@ -5,7 +5,7 @@ class BarGoo {}
class Foo {
{
List<BarGoo> goos;
for (BarGoo goo: goos) {
for (BarGoo goo : goos) {
}
}

View File

@@ -6,7 +6,7 @@ public class C {
}
void foo(List<Inner> inners) {
for (Inner inner: inners) {
for (Inner inner : inners) {
}
}

View File

@@ -4,7 +4,7 @@ public class LiveTemplateTest {
void one() {
List<A.B<String>> list;
for (A.B<String> stringB: list) {
for (A.B<String> stringB : list) {
}
}

View File

@@ -4,7 +4,7 @@ class Foo {
<T> void method1(final T[] val) {
class Inner {
void method2() {
for (T t: val) {
for (T t : val) {
}
}

View File

@@ -1,7 +1,7 @@
public class Foo {
void m() {
int[] xs = {1, 2, 3};
for (int x: xs) {
for (int x : xs) {
}
xs = new int[0];

View File

@@ -1,7 +1,7 @@
public class Foo {
void m() {
Object[] xs = new Object[]{1, 2, 3};
for (final Object x: xs) {
for (final Object x : xs) {
}
}

View File

@@ -3,7 +3,7 @@ class Example {
new Runnable() {
@Override
public void run() {
for (T t: foo) {
for (T t : foo) {
}
}

View File

@@ -1,7 +1,7 @@
public class Foo {
void m() {
int[] xs = {1, 2, 3};
for (int x: xs) {
for (int x : xs) {
}
}

View File

@@ -3,7 +3,7 @@ import java.util.ArrayList;
class Test {
public static void main(String[] args) {
ArrayList<Object> list = new ArrayList<Object>();
for (Object o: list) {
for (Object o : list) {
}
}

View File

@@ -1,6 +1,6 @@
class C {
{
for (String s: collection) {
for (String s : collection) {
}
}
}

View File

@@ -220,7 +220,7 @@ public class PaymentManager {
private double payCredits(List<CashOutDebitInfo> freeDebits, UserCashOut userCashOut, Session ses) {
double unpaidAmount = 0;
for (CashOutDebitInfo info: freeDebits) {
for (CashOutDebitInfo info : freeDebits) {
try {
String trackId = "Tr" + info.credit.getId();
PayConRequest creditRequest = PayConPaymentSystem.getInstance().createReversalRequest(userCashOut.getPlayer().getCurrency().getId(), trackId, -info.credit.getAmount(), new Long(info.debit.getExternalId()));
@@ -266,7 +266,7 @@ public class PaymentManager {
private double createCredits(double amount, Player player, List<CashOutDebitInfo> freeDebits, UserCashOut userCashOut, Session ses) {
double checkAmount = amount;
int i = 0;
for (CashOutDebitInfo debitInfo: freeDebits) {
for (CashOutDebitInfo debitInfo : freeDebits) {
Transaction credit = new Transaction();
if (checkAmount > debitInfo.remainder) {
credit.setAmount(-debitInfo.remainder);
@@ -311,10 +311,10 @@ public class PaymentManager {
//query.setInteger("status", TransactionStatus.COMPLETED.getId());
List<Transaction> transactions = query.list();
List<CashOutDebitInfo> freeDebits = new ArrayList<CashOutDebitInfo>();
for (Transaction transaction: transactions) {
for (Transaction transaction : transactions) {
Set<Transaction> credits = transaction.getCreditTransactions();
double sum = 0;
for (Transaction credit: credits) {
for (Transaction credit : credits) {
sum += credit.getAmount();
}
CashOutDebitInfo info = new CashOutDebitInfo();

View File

@@ -3,7 +3,7 @@ class Test {
new Object() {
private void InnerClass(int i, int[] j) {
if (i == 0) {
for (int idx: j) {
for (int idx : j) {
}
}

View File

@@ -72,7 +72,7 @@ import java.util.*;
public class Main {
List<String> getStringList(int i){
List<String> ints = null;
for (String item: getStringList(<caret>)) {
for (String item : getStringList(<caret>)) {
;
}
return new ArrayList<>(i);
@@ -94,7 +94,7 @@ public class Main {
}
'''
final TemplateManager manager = TemplateManager.getInstance(getProject())
final Template template = manager.createTemplate("for", "user", 'for ($ELEMENT_TYPE$ $VAR$: $ITERABLE_TYPE$) {\n' +
final Template template = manager.createTemplate("for", "user", 'for ($ELEMENT_TYPE$ $VAR$ : $ITERABLE_TYPE$) {\n' +
'$END$;\n' +
'}')
template.addVariable('ITERABLE_TYPE', new MacroCallNode(new CompleteSmartMacro()), new EmptyNode(), true)
@@ -108,7 +108,7 @@ import java.util.*;
public class Main {
List<String> getStringList(int i){
List<String> ints = null;
for (String <selection>item</selection>: ints) {
for (String <selection>item</selection> : ints) {
;
}
return new ArrayList<>(i);
@@ -478,7 +478,7 @@ java.util.List<? extends Integer> list;
myFixture.type('\tgetCreatedTags()\n')
myFixture.checkResult '''class A { Iterable<String> getCreatedTags() { }
{
for (String createdTag: getCreatedTags()) {
for (String createdTag : getCreatedTags()) {
}
}}'''

View File

@@ -571,7 +571,7 @@ class A {{
myFixture.configureByText "a.java", "class A { public void B() { I<caret> } }"
myFixture.type('\t')
myFixture.checkResult("class A { public void B() {\n" +
" for (Object o:) {\n" +
" for (Object o :) {\n" +
" \n" +
" }\n" +
"} }")
@@ -805,7 +805,7 @@ class Foo {{
LightPlatformCodeInsightTestCase.delete(myFixture.editor, myFixture.project)
myFixture.checkResult """
class Foo {{
for (Object o: <caret> {
for (Object o : <caret> {
}
}}

View File

@@ -131,25 +131,25 @@ public class JavaCodeBlockBracesPlacementTest extends AbstractJavaFormatterTest
}
public void testForEachStatement() {
String before = "for (String arg: args) {\n" +
String before = "for (String arg : args) {\n" +
" System.out.println(\"AAA!\");\n" +
"}";
String endOfLine = "for (String arg: args) {\n" +
String endOfLine = "for (String arg : args) {\n" +
" System.out.println(\"AAA!\");\n" +
"}";
String nextLine = "for (String arg: args)\n" +
String nextLine = "for (String arg : args)\n" +
"{\n" +
" System.out.println(\"AAA!\");\n" +
"}";
String nextLineShifted = "for (String arg: args)\n" +
String nextLineShifted = "for (String arg : args)\n" +
" {\n" +
" System.out.println(\"AAA!\");\n" +
" }";
String nextLineShiftedEach = "for (String arg: args)\n" +
String nextLineShiftedEach = "for (String arg : args)\n" +
" {\n" +
" System.out.println(\"AAA!\");\n" +
" }";
@@ -163,8 +163,8 @@ public class JavaCodeBlockBracesPlacementTest extends AbstractJavaFormatterTest
public void testSimpleForEachStatement() {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
String before = "for (String arg: args) { System.out.println(\"AAA!\"); }";
String after = "for (String arg: args) { System.out.println(\"AAA!\"); }";
String before = "for (String arg : args) { System.out.println(\"AAA!\"); }";
String after = "for (String arg : args) { System.out.println(\"AAA!\"); }";
checkFormatterWithDifferentBraceStyles(before, after, after, after, after);
}

View File

@@ -686,7 +686,7 @@ public class JavaFormatterSpaceTest extends AbstractJavaFormatterTest {
}
public void testSpacingAroundVarKeyword() {
doMethodTest("for ( var path: paths) ;", "for (var path: paths) ;");
doMethodTest("for ( var path : paths) ;", "for (var path : paths) ;");
doMethodTest("try ( @A var r = open()) { }", "try (@A var r = open()) {\n}");
}

View File

@@ -1497,14 +1497,14 @@ class JavaFormatterTest : AbstractJavaFormatterTest() {
doTextTest("class Foo {\n" +
" void foo() {\n" +
" for (Object i: collection)\n" +
" for (Object i : collection)\n" +
" {\n" +
" return false;\n" +
" }" +
" }\n" +
"}", "class Foo {\n" +
" void foo() {\n" +
" for (Object i: collection) {\n" +
" for (Object i : collection) {\n" +
" return false;\n" +
" }\n" +
" }\n" +
@@ -1685,7 +1685,7 @@ class JavaFormatterTest : AbstractJavaFormatterTest() {
"\n" +
" //comment in declaration\n" +
" public static void main(String[] args) {\n" +
" for (String arg: args) {\n" +
" for (String arg : args) {\n" +
" \n" +
" // a first system out\n" +
" System.out.println(\"\");\n" +
@@ -1697,7 +1697,7 @@ class JavaFormatterTest : AbstractJavaFormatterTest() {
"}", "public class ReformatProblem {\n" +
" //comment in declaration\n" +
" public static void main(String[] args) {\n" +
" for (String arg: args) {\n" +
" for (String arg : args) {\n" +
"\n" +
" // a first system out\n" +
" System.out.println(\"\");\n" +
@@ -1716,7 +1716,7 @@ class JavaFormatterTest : AbstractJavaFormatterTest() {
"\n" +
" //comment in declaration\n" +
" public static void main(String[] args) {\n" +
" for (String arg: args) {\n" +
" for (String arg : args) {\n" +
" \n" +
" // a first system out\n" +
" System.out.println(\"\");\n" +
@@ -1729,7 +1729,7 @@ class JavaFormatterTest : AbstractJavaFormatterTest() {
"\n" +
" //comment in declaration\n" +
" public static void main(String[] args) {\n" +
" for (String arg: args) {\n" +
" for (String arg : args) {\n" +
" // a first system out\n" +
" System.out.println(\"\");\n" +
" // another system out\n" +
@@ -2428,13 +2428,13 @@ enum Foo {
AbstractJavaFormatterTest.getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE
doTextTest("class Foo{\n" +
" void foo() {\n" +
" for (Object o: localizations) {\n" +
" for (Object o : localizations) {\n" +
" //do something \n" +
" }\n" +
" }\n" +
"}", "class Foo {\n" +
" void foo() {\n" +
" for (Object o: localizations)\n" +
" for (Object o : localizations)\n" +
" {\n" +
" //do something \n" +
" }\n" +
@@ -2709,8 +2709,8 @@ enum Foo {
"}")
doTextTest("class Foo {\n" + " void foo() {\n" + " for (int var: vars) foo();\n" + " }\n" + "}",
"class Foo {\n" + " void foo() {\n" + " for (int var: vars)\n" + " foo();\n" + " }\n" + "}")
doTextTest("class Foo {\n" + " void foo() {\n" + " for (int var : vars) foo();\n" + " }\n" + "}",
"class Foo {\n" + " void foo() {\n" + " for (int var : vars)\n" + " foo();\n" + " }\n" + "}")
doTextTest("class Foo {\n" + " void foo() {\n" + " do foo(); while (true);\n" + " }\n" + "}", "class Foo {\n" +
@@ -2735,8 +2735,8 @@ enum Foo {
"class Foo {\n" + " void foo() {\n" + " for (int i = 0; i < 10; i++) foo();\n" + " }\n" + "}")
doTextTest("class Foo {\n" + " void foo() {\n" + " for (int var: vars) foo();\n" + " }\n" + "}",
"class Foo {\n" + " void foo() {\n" + " for (int var: vars) foo();\n" + " }\n" + "}")
doTextTest("class Foo {\n" + " void foo() {\n" + " for (int var : vars) foo();\n" + " }\n" + "}",
"class Foo {\n" + " void foo() {\n" + " for (int var : vars) foo();\n" + " }\n" + "}")
doTextTest("class Foo {\n" + " void foo() {\n" + " do foo(); while (true);\n" + " }\n" + "}",
@@ -2769,8 +2769,8 @@ enum Foo {
"}")
AbstractJavaFormatterTest.getSettings().RIGHT_MARGIN = 32
doTextTest("class Foo {\n" + " void foo() {\n" + " for (int var: vars) foo();\n" + " }\n" + "}",
"class Foo {\n" + " void foo() {\n" + " for (int var: vars)\n" + " foo();\n" + " }\n" + "}")
doTextTest("class Foo {\n" + " void foo() {\n" + " for (int var : vars) foo();\n" + " }\n" + "}",
"class Foo {\n" + " void foo() {\n" + " for (int var : vars)\n" + " foo();\n" + " }\n" + "}")
AbstractJavaFormatterTest.getSettings().RIGHT_MARGIN = 12
@@ -3425,12 +3425,12 @@ enum Foo {
fun testFormatCStyleCommentWithAsterisks() {
doMethodTest(
" for (Object o: new Object[]{}) {\n" +
" for (Object o : new Object[]{}) {\n" +
"/*\n" +
" *\n" +
" \t\t\t\t\t */\n" +
" }\n",
"for (Object o: new Object[]{}) {\n" +
"for (Object o : new Object[]{}) {\n" +
" /*\n" +
" *\n" +
" */\n" +
@@ -3527,7 +3527,7 @@ class Test {
);
// IDEA-98552
for (
String s: list
String s : list
) {
System.out.println(s);
}

View File

@@ -22,7 +22,7 @@ public class Test extends ArrayList<String> {
new Runnable() {
@Override
public void run() {
for (String s: Test.this) {
for (String s : Test.this) {
System.out.println(s);
}
}

View File

@@ -22,7 +22,7 @@ public class Test extends ArrayList<String> {
new Runnable() {
@Override
public void run() {
for (String s: Test.this) {
for (String s : Test.this) {
System.out.println(s);
}
}

View File

@@ -21,7 +21,7 @@ public class Test {
private String[] fields = null;
void test() {
for (String field: this.fields) {
for (String field : this.fields) {
}
}
}

View File

@@ -19,7 +19,7 @@ import java.util.*;
public class Test extends ArrayList<String> {
public void print() {
for (String s: this) {
for (String s : this) {
System.out.println(s);
}
}

View File

@@ -3,7 +3,7 @@ import java.util.*;
class InstanceofAndWhitespace {
void foo(List<Object> os) {
for (Object o: os) {
for (Object o : os) {
if (o instanceof String) {
}

View File

@@ -3,7 +3,7 @@ import java.util.*;
class NoQualifier {
List<String> values = new ArrayList<>();
void foo() {
for (String value: values) {
for (String value : values) {
}
}
}

View File

@@ -3,7 +3,7 @@ import java.util.List;
class Test {
void foo(List<String> files) {
for (String file: files) {
for (String file : files) {
new File(file);
}
}

View File

@@ -4,7 +4,7 @@ class QualifyWithThis1 {
int size = values.length;
String[] values = new String[10]); // Let's hide filed "values" with local variable
for (String value: this.values) {
for (String value : this.values) {
}
}
}

View File

@@ -6,7 +6,7 @@ class QualifyWithThis2 {
int size = values.size();
List<String> values = new ArrayList<>(); // Let's hide filed "values" with local variable
for (String value: this.values) {
for (String value : this.values) {
}
}
}

View File

@@ -24,7 +24,7 @@ public class Test {
public void run() {
int size = values.size();
int values = 5;
for (String value: Test.this.values) {
for (String value : Test.this.values) {
System.out.println(value);
}
}

View File

@@ -5,7 +5,7 @@ import java.util.List;
class Cast {
void m(List ss) {
for (String s: (Iterable<String>) ss) {
for (String s : (Iterable<String>) ss) {
System.out.println(s);
}
}

View File

@@ -7,7 +7,7 @@ class NakedNext implements Iterable {
void m(List<String> ss) {
int count = 0;
for (String s: ss) {
for (String s : ss) {
count++;
}
}

View File

@@ -6,7 +6,7 @@ import java.util.List;
class This implements Iterable {
void m() {
for (Object o: this) {
for (Object o : this) {
System.out.println(o);
}
}

View File

@@ -5,7 +5,7 @@ public class UnboundWildcard {
void m(Collection<?> c) {
for (Object aC: c) {
for (Object aC : c) {
final String s = (String) aC;
}
}

Some files were not shown because too many files have changed in this diff Show More