void (PsiTryStatement tryStatement) { PsiUtilCore.ensureValid(tryStatement); PsiCodeBlock tryBlock = tryStatement.getTryBlock(); if (tryBlock == null) { return; } final PsiElement parent = tryStatement.getParent(); boolean singleStatement = false; if (parent instanceof PsiStatement) { final PsiStatement[] statements = tryBlock.getStatements(); if (statements.length == 1 && !(statements[0] instanceof PsiDeclarationStatement)) { singleStatement = true; } else { tryStatement = expandSingleStatementToBlockStatement(tryStatement); } } else if (parent instanceof PsiCodeBlock) { if (containsConflictingDeclarations(tryBlock, (PsiCodeBlock)parent)) { tryStatement = expandSingleStatementToBlockStatement(tryStatement); } } else { return; } tryBlock = tryStatement.getTryBlock(); assert tryBlock != null; final PsiElement first = singleStatement ? skip(tryBlock.getFirstBodyElement(), true) : tryBlock.getFirstBodyElement(); final PsiElement last = singleStatement? skip(tryBlock.getLastBodyElement(), false) : tryBlock.getLastBodyElement(); assert first != null && last != null; tryStatement.getParent().addRangeBefore(first, last, tryStatement); tryStatement.delete(); }