public void moveFieldInitializations() throws IncorrectOperationException { LOG.assertTrue(myMembersAfterMove != null); final LinkedHashSet<PsiField> movedFields = new LinkedHashSet<>(); for (PsiMember member : myMembersAfterMove) { if (member instanceof PsiField) { movedFields.add((PsiField) member); } } if (movedFields.isEmpty()) return; PullUpHelper<MemberInfo> processor = getProcessor(myTargetSuperClass); LOG.assertTrue(processor != null, myTargetSuperClass); processor.moveFieldInitializations(movedFields); }
@Override protected void performRefactoring(@NotNull UsageInfo[] usages) { moveMembersToBase(); moveFieldInitializations(); for (UsageInfo usage : usages) { PsiElement element = usage.getElement(); if (element == null) continue; PullUpHelper<MemberInfo> processor = getProcessor(element); if (processor == null) continue; processor.updateUsage(element); } ApplicationManager.getApplication() .invokeLater( () -> processMethodsDuplicates(), ModalityState.NON_MODAL, myProject.getDisposed()); }
public void moveMembersToBase() throws IncorrectOperationException { myMovedMembers = ContainerUtil.newHashSet(); myMembersAfterMove = ContainerUtil.newHashSet(); // build aux sets for (MemberInfo info : myMembersToMove) { myMovedMembers.add(info.getMember()); } final PsiSubstitutor substitutor = upDownSuperClassSubstitutor(); for (MemberInfo info : myMembersToMove) { PullUpHelper<MemberInfo> processor = getProcessor(info); LOG.assertTrue(processor != null, info.getMember()); if (!(info.getMember() instanceof PsiClass) || info.getOverrides() == null) { processor.setCorrectVisibility(info); processor.encodeContextInfo(info); } processor.move(info, substitutor); } for (PsiMember member : myMembersAfterMove) { PullUpHelper<MemberInfo> processor = getProcessor(member); LOG.assertTrue(processor != null, member); processor.postProcessMember(member); final JavaRefactoringListenerManager listenerManager = JavaRefactoringListenerManager.getInstance(myProject); ((JavaRefactoringListenerManagerImpl) listenerManager).fireMemberMoved(mySourceClass, member); } }