mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: fix "'try finally' replaceable with 'try' with resources" inspection quickfix problem
This commit is contained in:
+6
@@ -142,6 +142,12 @@ public class TryFinallyCanBeTryWithResourcesInspection extends BaseInspection {
|
||||
}
|
||||
separator = true;
|
||||
}
|
||||
int j = 1;
|
||||
while (!unwantedChildren.contains(Integer.valueOf(j)) && j < tryBlockChildren.length - 1) {
|
||||
tryStatement.getParent().addBefore(tryBlockChildren[j], tryStatement);
|
||||
unwantedChildren.add(Integer.valueOf(j));
|
||||
j++;
|
||||
}
|
||||
newTryStatementText.append(") {");
|
||||
final int tryBlockStatementsLength = tryBlockChildren.length - 1;
|
||||
for (int i = 1; i < tryBlockStatementsLength; i++) {
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import java.io.*;
|
||||
|
||||
class Dependents {
|
||||
void m() throws IOException {
|
||||
String filename = "filename";
|
||||
try (InputStream in = new FileInputStream(filename)) {
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import java.io.*;
|
||||
|
||||
class Dependents {
|
||||
void m() throws IOException {
|
||||
InputStream in = null;
|
||||
try<caret> {
|
||||
String filename = "filename";
|
||||
in = new FileInputStream(filename);
|
||||
}finally{
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -23,6 +23,7 @@ public class TryFinallyCanBeTryWithResourcesFixTest extends IGQuickFixesTestCase
|
||||
|
||||
public void testComments() { doTest(); }
|
||||
public void testMultiple() { doTest(); }
|
||||
public void testDependents() { doTest(); }
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user