while(!(child instanceof PsiStatement) || !(child.getParent() instanceof PsiCodeBlock)) {
child = child.getParent();
commonParent = commonParent.getParent();
}
LOG.assertTrue(commonParent != null);
<BUG>PsiDeclarationStatement added = (PsiDeclarationStatement)commonParent.addBefore(newDeclaration, child);
PsiLocalVariable addedVar = (PsiLocalVariable)added.getDeclaredElements()[0];
CodeStyleManager.getInstance(manager.getProject()).reformat(commonParent);</BUG>
PsiExpression initializer = myOutOfScopeVariable.getInitializer();
if (initializer != null) {

while(!(child instanceof PsiStatement) || !(child.getParent() instanceof PsiCodeBlock)) {
child = child.getParent();
commonParent = commonParent.getParent();
}
LOG.assertTrue(commonParent != null);
PsiDeclarationStatement added = (PsiDeclarationStatement)commonParent.addBefore(newDeclaration, child);
final PsiElement[] declaredElements = added.getDeclaredElements();
LOG.assertTrue(declaredElements.length > 0, added.getText());
PsiLocalVariable addedVar = (PsiLocalVariable)declaredElements[0];
CodeStyleManager.getInstance(manager.getProject()).reformat(commonParent);
PsiExpression initializer = myOutOfScopeVariable.getInitializer();
if (initializer != null) {
