diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/LabeledForLoop.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/LabeledForLoop.java new file mode 100644 index 000000000000..ecb0061f3a4b --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/LabeledForLoop.java @@ -0,0 +1,10 @@ +package com.siyeh.ipp.forloop.indexed; + +class LabeledForLoop { + + int[] getArr() { + Label: + for (int x: getArr()) {} + return new int[]{1}; + } +} diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/LabeledForLoop_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/LabeledForLoop_after.java new file mode 100644 index 000000000000..3630dc6233ae --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/LabeledForLoop_after.java @@ -0,0 +1,13 @@ +package com.siyeh.ipp.forloop.indexed; + +class LabeledForLoop { + + int[] getArr() { + int[] arr = getArr(); + Label: + for (int i = 0, arrLength = arr.length; i < arrLength; i++) { + int x = arr[i]; + } + return new int[]{1}; + } +} diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/NewArray.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/NewArray.java new file mode 100644 index 000000000000..132e95f8d087 --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/NewArray.java @@ -0,0 +1,8 @@ +package com.siyeh.ipp.forloop.indexed; + +class NewArray { + void foo() { + for (int k : new int[3]) { + } + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/NewArray_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/NewArray_after.java new file mode 100644 index 000000000000..5dfc3e6e1ead --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/NewArray_after.java @@ -0,0 +1,10 @@ +package com.siyeh.ipp.forloop.indexed; + +class NewArray { + void foo() { + int[] ints = new int[3]; + for (int i = 0, intsLength = ints.length; i < intsLength; i++) { + int k = ints[i]; + } + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/NormalForeachLoop.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/NormalForeachLoop.java new file mode 100644 index 000000000000..670b33d818d8 --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/NormalForeachLoop.java @@ -0,0 +1,9 @@ +package com.siyeh.ipp.forloop.indexed; + +class NormalForEachLoop { + void foo(int[] is) { + for (int i : is) { + System.out.println(i); + } + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/NormalForeachLoop_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/NormalForeachLoop_after.java new file mode 100644 index 000000000000..5bf04ed4a165 --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/forloop/indexed/NormalForeachLoop_after.java @@ -0,0 +1,10 @@ +package com.siyeh.ipp.forloop.indexed; + +class NormalForEachLoop { + void foo(int[] is) { + for (int i1 = 0, isLength = is.length; i1 < isLength; i1++) { + int i = is[i1]; + System.out.println(i); + } + } +} \ No newline at end of file diff --git a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/forloop/ReplaceForEachLoopWithIndexedForLoopIntentionTest.java b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/forloop/ReplaceForEachLoopWithIndexedForLoopIntentionTest.java new file mode 100644 index 000000000000..4155af65f527 --- /dev/null +++ b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/forloop/ReplaceForEachLoopWithIndexedForLoopIntentionTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.siyeh.ipp.forloop; + +import com.siyeh.IntentionPowerPackBundle; +import com.siyeh.ipp.IPPTestCase; + +public class ReplaceForEachLoopWithIndexedForLoopIntentionTest extends IPPTestCase { + public void testLabeledForLoop() { doTest(); } + public void testNormalForeachLoop() { doTest(); } + public void testNewArray() { doTest(); } + + @Override + protected String getIntentionName() { + return IntentionPowerPackBundle.message("replace.for.each.loop.with.indexed.for.loop.intention.name"); + } + + @Override + protected String getRelativePath() { + return "forloop/indexed"; + } +}