private Map<PsiMember, SmartPsiElementPointer<PsiMember>> performMove(PsiClass targetClass,
                                                                        Set<PsiMember> membersToMove,
                                                                        List<MoveMembersUsageInfo> usages) {
    // collect anchors to place moved members at
    final Map<PsiMember, SmartPsiElementPointer<PsiElement>> anchors = new HashMap<>();
    final Map<PsiMember, PsiMember> anchorsInSourceClass = new HashMap<>();
    for (PsiMember member : membersToMove) {
      final MoveMemberHandler handler = MoveMemberHandler.EP_NAME.forLanguage(member.getLanguage());
      if (handler != null) {
        final PsiElement anchor = handler.getAnchor(member, targetClass, membersToMove);
        if (anchor instanceof PsiMember && membersToMove.contains((PsiMember)anchor)) {
          anchorsInSourceClass.put(member, (PsiMember)anchor);
        } else {
          anchors.put(member, anchor == null ? null : SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(anchor));
        }
      }
    }

    // correct references to moved members from the outside
    ArrayList<MoveMembersUsageInfo> otherUsages = new ArrayList<>();
    for (MoveMembersUsageInfo usage : usages) {
      if (!usage.reference.isValid()) continue;
      final MoveMemberHandler handler = MoveMemberHandler.EP_NAME.forLanguage(usage.getElement().getLanguage());
      if (handler != null) {
        if (handler.changeExternalUsage(myOptions, usage)) continue;
      }
      otherUsages.add(usage);
    }

    // correct references inside moved members and outer references to Inner Classes
    Map<PsiMember, SmartPsiElementPointer<PsiMember>> movedMembers = new HashMap<>();
    for (PsiMember member : membersToMove) {
      ArrayList<PsiReference> refsToBeRebind = new ArrayList<>();
      for (Iterator<MoveMembersUsageInfo> iterator = otherUsages.iterator(); iterator.hasNext();) {
        MoveMembersUsageInfo info = iterator.next();
        if (member.equals(info.member)) {
          PsiReference ref = info.getReference();
          if (ref != null) {
            refsToBeRebind.add(ref);
          }
          iterator.remove();
        }
      }
      getTransaction().getElementListener(member); // initialize the listener while PSI is valid
      final MoveMemberHandler handler = MoveMemberHandler.EP_NAME.forLanguage(member.getLanguage());
      if (handler != null) {

        SmartPsiElementPointer<? extends PsiElement> anchor;
        if (anchorsInSourceClass.containsKey(member)) {
          final PsiMember memberInSourceClass = anchorsInSourceClass.get(member);
          //anchor should be already moved as myMembersToMove contains members in order they appear in source class
          anchor = memberInSourceClass != null ? movedMembers.get(memberInSourceClass) : null;
        }
        else {
          anchor = anchors.get(member);
        }

        PsiMember newMember = handler.doMove(myOptions, member, anchor == null ? null : anchor.getElement(), targetClass);

        movedMembers.put(member, SmartPointerManager.createPointer(newMember));

        fixModifierList(member, newMember, usages);
        for (PsiReference reference : refsToBeRebind) {
          try {
            reference.bindToElement(newMember);
          }
          catch (Throwable e) {
            LOG.error(e);
          }
        }
      }
    }

    // qualifier info must be decoded after members are moved
    MoveMemberHandler handler = MoveMemberHandler.EP_NAME.forLanguage(targetClass.getLanguage());
    if (handler != null) handler.decodeContextInfo(targetClass);

    return movedMembers;
  }
private Map<PsiMember, SmartPsiElementPointer<PsiMember>> performMove(PsiClass targetClass,
                                                                        Set<PsiMember> membersToMove,
                                                                        List<MoveMembersUsageInfo> usages)