RedundantExplicitCloseInspection: support parentheses in close(); fixed support of resource expression; check field qualifiers

This commit is contained in:
Tagir Valeev
2018-07-06 15:13:13 +07:00
parent b0cc9d68d4
commit df28f9a4c0
8 changed files with 103 additions and 18 deletions
@@ -2,7 +2,7 @@
class MyAutoCloseable implements AutoCloseable {
@Override
void close() {
public void close() {
}
}
@@ -0,0 +1,18 @@
// "Remove redundant close" "true"
class MyAutoCloseable implements AutoCloseable {
@Override
public void close() {
}
}
class RemoveTry {
final MyAutoCloseable ac;
public void main(RemoveTry other) {
try(other.ac) {
System.out.println("asdasd");
}
}
}
@@ -0,0 +1,16 @@
// "Remove redundant close" "true"
class MyAutoCloseable implements AutoCloseable {
@Override
public void close() {
}
}
class RemoveTry {
public static void main(MyAutoCloseable ac) {
try(ac) {
System.out.println("asdasd");
}
}
}
@@ -2,7 +2,7 @@
class MyAutoCloseable implements AutoCloseable {
@Override
void close() {
public void close() {
}
}
@@ -11,7 +11,7 @@ class RemoveTry {
public static void main(String[] args) {
try(MyAutoCloseable ac = new MyAutoCloseable()) {
System.out.println("asdasd");
ac.close<caret>();
(ac).close<caret>();
}
}
}
@@ -0,0 +1,19 @@
// "Remove redundant close" "false"
class MyAutoCloseable implements AutoCloseable {
@Override
public void close() {
}
}
class RemoveTry {
final MyAutoCloseable ac;
public void main(RemoveTry other) {
try(other.ac) {
System.out.println("asdasd");
this.ac.clo<caret>se();
}
}
}
@@ -0,0 +1,19 @@
// "Remove redundant close" "true"
class MyAutoCloseable implements AutoCloseable {
@Override
public void close() {
}
}
class RemoveTry {
final MyAutoCloseable ac;
public void main(RemoveTry other) {
try(other.ac) {
System.out.println("asdasd");
other.ac.clo<caret>se();
}
}
}
@@ -0,0 +1,17 @@
// "Remove redundant close" "true"
class MyAutoCloseable implements AutoCloseable {
@Override
public void close() {
}
}
class RemoveTry {
public static void main(MyAutoCloseable ac) {
try(ac) {
System.out.println("asdasd");
(ac).close<caret>();
}
}
}