public static @Nullable PsiStatement addFieldAssignmentStatement(@NotNull Project project,
                                                                   @NotNull PsiField field,
                                                                   @NotNull PsiParameter parameter,
                                                                   @Nullable ModPsiNavigator updater) {
    PsiMethod method = (PsiMethod)parameter.getDeclarationScope();
    PsiCodeBlock methodBody = method.getBody();
    if (methodBody == null) return null;
    PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
    String fieldName = field.getName();
    String parameterName = parameter.getName();
    boolean isMethodStatic = method.hasModifierProperty(PsiModifier.STATIC);
    PsiClass targetClass = method.getContainingClass();
    if (targetClass == null) return null;

    ToolsImpl tool = InspectionProfileManager.getInstance(project).getCurrentProfile()
      .getToolsOrNull(UnqualifiedFieldAccessInspection.SHORT_NAME, project);
    boolean codeStyleRequiresThis = tool != null && tool.isEnabled(field) && tool.getLevel(field) != HighlightDisplayLevel.DO_NOT_SHOW;

    String stmtText = fieldName + " = " + parameterName + ";";
    if (Comparing.strEqual(fieldName, parameterName) ||
        JavaPsiFacade.getInstance(project).getResolveHelper().resolveReferencedVariable(fieldName, methodBody) != field ||
        (codeStyleRequiresThis && !isMethodStatic)) {
      @NonNls String prefix = isMethodStatic ? targetClass.getName() == null ? "" : targetClass.getName() + "." : "this.";
      stmtText = prefix + stmtText;
    }

    PsiStatement assignmentStmt = (PsiStatement)CodeStyleManager.getInstance(project).reformat(factory.createStatementFromText(stmtText, methodBody));
    PsiStatement[] statements = methodBody.getStatements();
    int i = FieldFromParameterUtils.findFieldAssignmentAnchor(statements, null, null, targetClass, parameter);
    PsiStatement inserted;
    if (i == statements.length) {
      inserted = (PsiStatement)methodBody.add(assignmentStmt);
    }
    else {
      inserted = (PsiStatement)methodBody.addAfter(assignmentStmt, i > 0 ? statements[i - 1] : null);
    }
    if (updater != null) {
      updater.moveCaretTo(inserted.getTextRange().getEndOffset());
    }
    return inserted;
  }
public static @Nullable PsiStatement addFieldAssignmentStatement(@NotNull Project project,
                                                                   @NotNull PsiField field,
                                                                   @NotNull PsiParameter parameter,
                                                                   @Nullable ModPsiNavigator updater)