RefactoringUtil#ensureCodeBlock enhanced and used in Surround with try-catch

Fixes IDEA-178781 "Surround with try-catch" QuickFix for "Unhandled exception" in a field initializer
Enables stream-to-loop in field initializer
Fixes stream-to-loop in for initializer
Disables stream-to-loop in for update
This commit is contained in:
Tagir Valeev
2017-09-12 13:34:43 +07:00
parent 94a5fea51d
commit 6e87cb9bfd
10 changed files with 315 additions and 37 deletions

View File

@@ -0,0 +1,19 @@
// "Surround with try/catch" "true"
import java.io.IOException;
class C {
static final String S;
static {
try {
S = getString();
} catch (IOException e) {
e.printStackTrace();
}
}
static String getString() throws IOException {
if(Math.random() > 0.5) throw new IOException();
return "foo";
}
}