boolean (@NotNull ControlFlow flow, @NotNull ReturnContext context) { if (hasChainedAssignmentsInScope(flow, context.returnedVariable, context.returnStatement)) { return false; } if (context.returnScope != context.variableScope) { if (ControlFlowUtil.isVariableReadInFinally(flow, context.returnScope, context.variableScope, context.returnedVariable)) { return false; } final int flowStart = flow.getStartOffset(context.returnScope); final int flowEnd = flow.getEndOffset(context.returnScope); if (flowStart < 0 || flowEnd < 0) return false; if (ControlFlowUtil.hasObservableThrowExitPoints(flow, flowStart, flowEnd, new PsiElement[]{context.refactoredStatement}, context.variableScope)) { return false; } } Mover mover = new Mover(flow, context.refactoredStatement, context.returnedVariable, context.returnType, true); mover.moveTo(context.refactoredStatement, true); return !mover.isEmpty(); }