mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java: while -> foreach with empty loop (IDEA-268952)
GitOrigin-RevId: a569bb1c7046b97af445919e56abd5d2a46807cc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
66873cdedb
commit
66bcae147f
@@ -490,7 +490,9 @@ public class ForCanBeForeachInspection extends BaseInspection {
|
||||
PsiVariable iterator, PsiType contentType, PsiElement childToSkip,
|
||||
CommentTracker commentTracker, StringBuilder out) {
|
||||
if (isIteratorNext(element, iterator, contentType)) {
|
||||
out.append(contentVariableName);
|
||||
if (!(element.getParent() instanceof PsiExpressionStatement)) {
|
||||
out.append(contentVariableName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
final PsiElement[] children = element.getChildren();
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import java.util.Iterator;
|
||||
|
||||
class MyTest {
|
||||
public static void foo(Iterable<?> bar) {
|
||||
for (Object o : bar) ;
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import java.util.Iterator;
|
||||
|
||||
class MyTest {
|
||||
public static void foo(Iterable<?> bar) {
|
||||
Iterator<?> it = bar.iterator();
|
||||
wh<caret>ile (it.hasNext()) it.next();
|
||||
}
|
||||
}
|
||||
+1
@@ -24,6 +24,7 @@ public class WhileCanBeForeachFixTest extends IGQuickFixesTestCase {
|
||||
public void testRawIterator() { doTest(); }
|
||||
public void testUnboxing() { doTest(); }
|
||||
public void testParentheses() { doTest(); }
|
||||
public void testEmptyLoop() { doTest(); }
|
||||
|
||||
@Override
|
||||
protected void tuneFixture(JavaModuleFixtureBuilder builder) {
|
||||
|
||||
Reference in New Issue
Block a user