mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
IDEA-121658 Java 1.8: "Replace with forEach" quick fix is not suggested if for statement is not surrounded with braces
This commit is contained in:
+6
@@ -223,6 +223,12 @@ public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInsp
|
||||
else if (body instanceof PsiBlockStatement) {
|
||||
return extractMethodCallFromBlock(((PsiBlockStatement)body).getCodeBlock());
|
||||
}
|
||||
else if (body instanceof PsiExpressionStatement) {
|
||||
final PsiExpression expression = ((PsiExpressionStatement)body).getExpression();
|
||||
if (expression instanceof PsiCallExpression) {
|
||||
methodCall = (PsiCallExpression)expression;
|
||||
}
|
||||
}
|
||||
return methodCall;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -111,10 +111,10 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
|
||||
if (effectivelyFinal[0]) {
|
||||
if (isCollectCall(body)) {
|
||||
holder.registerProblem(iteratedValue, "Can be replaced with collect call",
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new ReplaceWithCollectCallFix());
|
||||
ProblemHighlightType.LIKE_UNUSED_SYMBOL, new ReplaceWithCollectCallFix());
|
||||
} else if (!isTrivial(body, statement.getIterationParameter(), iteratedValueType)) {
|
||||
holder.registerProblem(iteratedValue, "Can be replaced with foreach call",
|
||||
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new ReplaceWithForeachCallFix());
|
||||
ProblemHighlightType.LIKE_UNUSED_SYMBOL, new ReplaceWithForeachCallFix());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with forEach" "true"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class Sample {
|
||||
List<String> foo = new ArrayList<>();
|
||||
{
|
||||
foo.forEach(System.out::println);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with forEach" "true"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class Sample {
|
||||
List<String> foo = new ArrayList<>();
|
||||
{
|
||||
for (String s : fo<caret>o) System.out.println(s);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user