IDEA-115516 (Multiple warnings local foreach parameter can be final)

This commit is contained in:
Bas Leijdekkers
2013-10-28 15:17:57 +01:00
parent f214acc2b0
commit 2a1ebb5187
4 changed files with 49 additions and 32 deletions
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>NestedForeach.java</file>
<line>9</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Local variable or parameter can be final</problem_class>
<description>Variable &lt;code&gt;s&lt;/code&gt; can have &lt;code&gt;final&lt;/code&gt; modifier</description>
</problem>
</problems>
@@ -0,0 +1,19 @@
class NestedForeach {
void foo(final List<String> list) {
new Object() {
void one() {
new Object() {
void two() {
new Object() {
void three() {
for (String s : list) {
System.out.println(s);
}
}
};
}
};
}
};
}
}
@@ -129,4 +129,10 @@ public class LocalCanBeFinalTest extends InspectionTestCase {
myTool.REPORT_VARIABLES = false;
doTest();
}
public void testNestedForeach() throws Exception {
myTool.REPORT_VARIABLES = true;
myTool.REPORT_PARAMETERS = false;
doTest();
}
}