IDEA-122392 intention: "Create Local Var from instanceof Usage" does not format generated code

This commit is contained in:
Anna Kozlova
2014-03-19 20:54:49 +01:00
parent c9e83b2679
commit b92955274f
3 changed files with 25 additions and 0 deletions

View File

@@ -206,6 +206,7 @@ public class CreateLocalVarFromInstanceofAction extends BaseIntentionAction {
final PsiStatement statementInside = isNegated(instanceOfExpression) ? null : getExpressionStatementInside(file, editor, instanceOfExpression.getOperand());
PsiDeclarationStatement decl = createLocalVariableDeclaration(instanceOfExpression, statementInside);
if (decl == null) return;
decl = (PsiDeclarationStatement)CodeStyleManager.getInstance(project).reformat(decl);
decl = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(decl);
PsiLocalVariable localVariable = (PsiLocalVariable)decl.getDeclaredElements()[0];

View File

@@ -0,0 +1,13 @@
// "Insert '(IOException)o' declaration" "true"
import java.io.IOException;
class C {
void f(Object o) {
if (o instanceof IOException) {
IOException ioException = (IOException) o;
}
}
}

View File

@@ -0,0 +1,11 @@
// "Insert '(IOException)o' declaration" "true"
import java.io.IOException;
class C {
void f(Object o) {
if (o instanceof IOException) {
<caret>
}
}
}