@Override
 @Nullable
 public PsiMethod generateMethodPrototype(
     @NotNull PsiField field, @NotNull String methodName, boolean isGetter) {
   PsiMethod prototype =
       isGetter
           ? GenerateMembersUtil.generateGetterPrototype(field)
           : GenerateMembersUtil.generateSetterPrototype(field);
   try {
     prototype.setName(methodName);
     return prototype;
   } catch (IncorrectOperationException e) {
     return null;
   }
 }
 private void appendAccessors(final Set<PsiParameter> params, boolean isGetter) {
   final PsiElement element = getElement();
   if (element != null) {
     for (PsiParameter parameter : params) {
       final IntroduceParameterObjectProcessor.ParameterChunk parameterChunk =
           IntroduceParameterObjectProcessor.ParameterChunk.getChunkByParameter(
               parameter, parameters);
       LOGGER.assertTrue(parameterChunk != null);
       final PsiField field = parameterChunk.getField();
       if (field != null) {
         element.add(
             isGetter
                 ? GenerateMembersUtil.generateGetterPrototype(field)
                 : GenerateMembersUtil.generateSetterPrototype(field));
       }
     }
   }
 }
 private boolean hasSetter(final PsiField field) {
   return hasGetterOrSetter(
       sourceClass.findMethodsBySignature(
           GenerateMembersUtil.generateSetterPrototype(field), false));
 }
  protected void performRefactoring(@NotNull UsageInfo[] usageInfos) {
    final PsiClass psiClass = buildClass();
    if (psiClass == null) return;
    if (delegationRequired) {
      buildDelegate();
    }
    myExtractEnumProcessor.performEnumConstantTypeMigration(usageInfos);
    final Set<PsiMember> members = new HashSet<PsiMember>();
    for (PsiMethod method : methods) {
      final PsiMethod member = psiClass.findMethodBySignature(method, false);
      if (member != null) {
        members.add(member);
      }
    }
    for (PsiField field : fields) {
      final PsiField member = psiClass.findFieldByName(field.getName(), false);
      if (member != null) {
        members.add(member);
        final PsiExpression initializer = member.getInitializer();
        if (initializer != null) {
          final boolean[] moveInitializerToConstructor = new boolean[1];
          initializer.accept(
              new JavaRecursiveElementWalkingVisitor() {
                @Override
                public void visitReferenceExpression(PsiReferenceExpression expression) {
                  super.visitReferenceExpression(expression);
                  final PsiElement resolved = expression.resolve();
                  if (resolved instanceof PsiField && !members.contains(resolved)) {
                    moveInitializerToConstructor[0] = true;
                  }
                }
              });

          if (moveInitializerToConstructor[0]) {
            final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(myProject);
            PsiMethod[] constructors = psiClass.getConstructors();
            if (constructors.length == 0) {
              final PsiMethod constructor =
                  (PsiMethod) elementFactory.createConstructor().setName(psiClass.getName());
              constructors = new PsiMethod[] {(PsiMethod) psiClass.add(constructor)};
            }
            for (PsiMethod constructor : constructors) {
              MoveInstanceMembersUtil.moveInitializerToConstructor(
                  elementFactory, constructor, member);
            }
          }
        }
      }
    }

    if (myGenerateAccessors) {
      final NecessaryAccessorsVisitor visitor = checkNecessaryGettersSetters4SourceClass();
      for (PsiField field : visitor.getFieldsNeedingGetter()) {
        sourceClass.add(GenerateMembersUtil.generateGetterPrototype(field));
      }

      for (PsiField field : visitor.getFieldsNeedingSetter()) {
        sourceClass.add(GenerateMembersUtil.generateSetterPrototype(field));
      }
    }
    super.performRefactoring(usageInfos);
    if (myNewVisibility == null) return;
    for (PsiMember member : members) {
      VisibilityUtil.fixVisibility(UsageViewUtil.toElements(usageInfos), member, myNewVisibility);
    }
  }