private static void inlineSingleAssignment(@NotNull PsiVariable resultVar,
                                             @NotNull PsiAssignmentExpression assignment,
                                             @NotNull PsiReferenceExpression resultUsage) {
    LOG.assertTrue(assignment.getParent() instanceof PsiExpressionStatement);
    // SCR3175 fixed: inline only if declaration and assignment is in the same code block.
    if (!(assignment.getParent().getParent() == resultVar.getParent().getParent())) return;
    String name = Objects.requireNonNull(resultVar.getName());
    PsiDeclarationStatement declaration = JavaPsiFacade.getElementFactory(resultVar.getProject())
      .createVariableDeclarationStatement(name, resultVar.getType(), assignment.getRExpression());
    declaration = (PsiDeclarationStatement)assignment.getParent().replace(declaration);
    resultVar.getParent().delete();
    resultVar = (PsiVariable)declaration.getDeclaredElements()[0];

    PsiElement parentStatement = CommonJavaRefactoringUtil.getParentStatement(resultUsage, true);
    PsiElement next = declaration.getNextSibling();
    boolean canInline = false;
    while (true) {
      if (next == null) break;
      if (next.equals(parentStatement)) {
        canInline = true;
        break;
      }
      if (next instanceof PsiStatement) break;
      next = next.getNextSibling();
    }

    if (canInline) {
      inlineVariable(resultVar, resultVar.getInitializer(), resultUsage);
      declaration.delete();
    }
  }
private static void inlineSingleAssignment(@NotNull PsiVariable resultVar,
                                             @NotNull PsiAssignmentExpression assignment,
                                             @NotNull PsiReferenceExpression resultUsage)