void (@NotNull ReturnContext context, @NotNull ModPsiUpdater updater) { PsiExpression value = PsiUtil.skipParenthesizedExprDown(context.returnedVariable.getInitializer()); boolean isConstant = value instanceof PsiLiteralExpression || value instanceof PsiThisExpression || PsiUtil.isConstantExpression(value); boolean isSimple = isSimpleExpression(value, context.returnScope); if (value != null && !isConstant && !isSimple) { return; } List<PsiReferenceExpression> usages = VariableAccessUtils.getVariableReferences(context.returnedVariable, context.variableScope); for (PsiReference usage : usages) { PsiElement parent = PsiTreeUtil.skipParentsOfType(usage.getElement(), PsiParenthesizedExpression.class, PsiTypeCastExpression.class); if (!(parent instanceof PsiReturnStatement)) { return; } } PsiExpression firstInlined = null; boolean isSingleUsage = value != null && usages.size() == 1; if (isSimple || isSingleUsage) { for (PsiJavaCodeReferenceElement usage : usages) { PsiExpression inlined = CommonJavaInlineUtil.getInstance().inlineVariable(context.returnedVariable, value, usage, null); if (firstInlined == null) firstInlined = inlined; updater.highlight(inlined); } } if (isSimple || isSingleUsage || usages.isEmpty()) { CommentTracker tracker = new CommentTracker(); if (firstInlined != null) { tracker.delete(context.returnedVariable); tracker.insertCommentsBefore(firstInlined); } else { tracker.deleteAndRestoreComments(context.returnedVariable); } } }