Resource declaration and assignment conflicts highlighting

This commit is contained in:
Roman Shevchenko
2011-02-23 21:04:42 +01:00
parent fdbaba14e1
commit 0a17b195bb
7 changed files with 60 additions and 77 deletions
@@ -27,24 +27,14 @@ class C {
System.out.println(r1);
}
try (MyResource r2 = <warning descr="Variable 'r2' initializer 'new MyResource()' is redundant">new MyResource()</warning>) {
r2 = null; // todo: check for NPE
System.out.println(r2);
}
MyResource r2 = null;
System.out.println(r2);
try (r2 = <warning descr="The value 'new MyResource()' assigned to r2 is never used">new MyResource()</warning>) { }
MyResource r3 = null;
System.out.println(r3);
try (r3 = <warning descr="The value 'new MyResource()' assigned to r3 is never used">new MyResource()</warning>) { }
try (MyResource <warning descr="Variable 'r3' is never used">r3</warning> = new MyResource()) { }
try (MyResource <warning descr="Variable 'r4' is never used">r4</warning> = new MyResource()) { }
try (MyResource r5 = new MyResource()) {
System.out.println(r5);
r5 = <warning descr="The value 'new MyResource()' assigned to r5 is never used">new MyResource()</warning>;
}
MyResource <warning descr="Variable 'r6' is never assigned">r6</warning>;
try (MyResource r = <error descr="Variable 'r6' might not have been initialized">r6</error>) {
MyResource <warning descr="Variable 'r4' is never assigned">r4</warning>;
try (MyResource r = <error descr="Variable 'r4' might not have been initialized">r4</error>) {
System.out.println(r);
}
}