mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
change signature: don't unwrap try-with-resources with non-empty resource list (IDEA-202731)
This commit is contained in:
+2
-1
@@ -399,7 +399,8 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
|
||||
PsiCodeBlock tryBlock = tryStatement.getTryBlock();
|
||||
if (tryBlock != null) {
|
||||
if (tryStatement.getCatchSections().length == 0 &&
|
||||
tryStatement.getFinallyBlock() == null) {
|
||||
tryStatement.getFinallyBlock() == null &&
|
||||
tryStatement.getResourceList() == null) {
|
||||
PsiElement firstBodyElement = tryBlock.getFirstBodyElement();
|
||||
if (firstBodyElement != null) {
|
||||
tryStatement.getParent().addRangeAfter(firstBodyElement, tryBlock.getLastBodyElement(), tryStatement);
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
class Scratch {
|
||||
|
||||
static class C implements AutoCloseable {
|
||||
public void close() {}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try (C c = new C()) {
|
||||
foo();
|
||||
}
|
||||
}
|
||||
|
||||
static void f<caret>oo() throws Exception { }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class Scratch {
|
||||
|
||||
static class C implements AutoCloseable {
|
||||
public void close() {}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try (C c = new C()) {
|
||||
foo();
|
||||
}
|
||||
}
|
||||
|
||||
static void foo() { }
|
||||
}
|
||||
@@ -445,6 +445,10 @@ public class ChangeSignatureTest extends ChangeSignatureBaseTest {
|
||||
doTest(null, null, null, new ParameterInfoImpl[0], new ThrownExceptionInfo[0], false);
|
||||
}
|
||||
|
||||
public void testKeepTryWithResources() {
|
||||
doTest(null, null, null, new ParameterInfoImpl[0], new ThrownExceptionInfo[0], false);
|
||||
}
|
||||
|
||||
public void testVisibilityOfOverriddenMethod() {
|
||||
doTest(PsiModifier.PACKAGE_LOCAL, "foo", "void", new ParameterInfoImpl[0], new ThrownExceptionInfo[0], false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user