mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 18:28:55 +07:00
[java-inspections] IDEA-373515 Fix 'Collapse loop with stream forEach()' breaking when static star import is used
Thanks for help, Bas! Co-authored-by: Bas Leijdekkers <bas.leijdekkers@jetbrains.com> GitOrigin-RevId: 1ab70d08fe4a1ea0c050d725bc0ec5149d019b7c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
07634e6b2d
commit
79ad940ac3
@@ -457,7 +457,7 @@ final class TerminalBlock {
|
||||
if (myStatements.length == 1) {
|
||||
return myStatements[0];
|
||||
}
|
||||
PsiCodeBlock block = factory.createCodeBlock();
|
||||
PsiCodeBlock block = factory.createCodeBlockFromText("{}", myVariable);
|
||||
for (PsiStatement statement : myStatements) {
|
||||
block.add(ct.markUnchanged(statement));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// "Collapse loop with stream 'forEach()'" "true-preview"
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class Test {
|
||||
void collectNames() {
|
||||
int[] arr1 = {1, 2, 3};
|
||||
int[] arr2 = {1, 2, 3};
|
||||
deepEquals(arr1, arr2);
|
||||
IntStream.range(0, arr1.length).forEach(i -> {
|
||||
int a = arr1[i];
|
||||
int b = arr2[i];
|
||||
boolean result = Objects.deepEquals(a, b);
|
||||
System.out.println("result is " + result);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// "Collapse loop with stream 'forEach()'" "true-preview"
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class Test {
|
||||
void collectNames() {
|
||||
int[] arr1 = {1, 2, 3};
|
||||
int[] arr2 = {1, 2, 3};
|
||||
deepEquals(arr1, arr2);
|
||||
IntStream.range(0, arr1.length).forEach(i -> {
|
||||
int a = arr1[i];
|
||||
int b = arr2[i];
|
||||
boolean result = Objects.deepEquals(a, b);
|
||||
System.out.println("result is " + result);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// "Collapse loop with stream 'forEach()'" "true-preview"
|
||||
|
||||
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static java.util.Objects.*;
|
||||
|
||||
public class Test {
|
||||
void collectNames() {
|
||||
int[] arr1 = {1, 2, 3};
|
||||
int[] arr2 = {1, 2, 3};
|
||||
deepEquals(arr1, arr2);
|
||||
IntStream.range(0, arr1.length).forEach(i -> {
|
||||
int a = arr1[i];
|
||||
int b = arr2[i];
|
||||
boolean result = deepEquals(a, b);
|
||||
System.out.println("result is " + result);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Collapse loop with stream 'forEach()'" "true-preview"
|
||||
|
||||
public class Test {
|
||||
void collectNames() {
|
||||
int[] arr1 = {1, 2, 3};
|
||||
int[] arr2 = {1, 2, 3};
|
||||
deepEquals(arr1, arr2);
|
||||
for <caret>(int i = 0; i < arr1.length; i++) {
|
||||
int a = arr1[i];
|
||||
int b = arr2[i];
|
||||
boolean result = java.util.Objects.deepEquals(a, b);
|
||||
System.out.println("result is " + result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// "Collapse loop with stream 'forEach()'" "true-preview"
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Test {
|
||||
void collectNames() {
|
||||
int[] arr1 = {1, 2, 3};
|
||||
int[] arr2 = {1, 2, 3};
|
||||
deepEquals(arr1, arr2);
|
||||
for <caret>(int i = 0; i < arr1.length; i++) {
|
||||
int a = arr1[i];
|
||||
int b = arr2[i];
|
||||
boolean result = Objects.deepEquals(a, b);
|
||||
System.out.println("result is " + result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// "Collapse loop with stream 'forEach()'" "true-preview"
|
||||
|
||||
|
||||
import static java.util.Objects.*;
|
||||
|
||||
public class Test {
|
||||
void collectNames() {
|
||||
int[] arr1 = {1, 2, 3};
|
||||
int[] arr2 = {1, 2, 3};
|
||||
deepEquals(arr1, arr2);
|
||||
for <caret>(int i = 0; i < arr1.length; i++) {
|
||||
int a = arr1[i];
|
||||
int b = arr2[i];
|
||||
boolean result = deepEquals(a, b);
|
||||
System.out.println("result is " + result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user