public static void tryInlineGeneratedLocal(PsiLocalVariable variable, boolean strictlyFinal) throws IncorrectOperationException {
    List<PsiReferenceExpression> refs = VariableAccessUtils.getVariableReferences(variable);
    PsiReferenceExpression firstRef = ContainerUtil.getFirstItem(refs);

    PsiExpression initializer = variable.getInitializer();
    if (firstRef == null) {
      PsiDeclarationStatement declaration = (PsiDeclarationStatement)variable.getParent();
      if (initializer != null) {
        List<PsiExpression> sideEffects = SideEffectChecker.extractSideEffectExpressions(initializer);
        for (PsiStatement statement : StatementExtractor.generateStatements(sideEffects, initializer)) {
          declaration.getParent().addBefore(statement, declaration);
        }
      }
      declaration.delete();
      return;
    }


    boolean isAccessedForWriting = false;
    boolean usedAsResource = false;
    for (PsiReferenceExpression refElement : refs) {
      if (PsiUtil.isAccessedForWriting(refElement)) {
        isAccessedForWriting = true;
      }
      if (refElement.getParent() instanceof PsiResourceExpression) {
        usedAsResource = true;
      }
    }

    boolean shouldBeFinal = variable.hasModifierProperty(PsiModifier.FINAL) && strictlyFinal;
    Project project = variable.getProject();
    boolean canInline = refs.size() == 1 && !isAccessedForWriting && isFirstUse(variable, refs.get(0)) ||
                        canInlineParameterOrThisVariable(project, initializer, shouldBeFinal, strictlyFinal, refs.size(), isAccessedForWriting);
    canInline &= !usedAsResource;
    if (canInline) {
      if (shouldBeFinal) {
        declareUsedLocalsFinal(initializer, true);
      }
      for (PsiJavaCodeReferenceElement ref : refs) {
        initializer = inlineInitializer(variable, initializer, ref);
      }
      variable.getParent().delete();
    }
  }
public static void tryInlineGeneratedLocal(PsiLocalVariable variable, boolean strictlyFinal)