void (PsiClass originalClass, Map<String, PsiElement> originalNamedElements, PsiClass replacementClass) { final List<? extends PsiElement> elements = originalClass.getUserData(GlobalMatchingVisitor.UNMATCHED_ELEMENTS_KEY); if (elements == null) { return; } final List<PsiNamedElement> anchors = PsiTreeUtil.getChildrenOfTypeAsList(replacementClass, PsiNamedElement.class); for (PsiNamedElement anchor : anchors) { final String replacedMemberName = anchor.getName(); final PsiElement originalMember = originalNamedElements.get(replacedMemberName); if (originalMember == null) { continue; } final Iterator<? extends PsiElement> iterator = elements.iterator(); while (iterator.hasNext()) { final PsiElement element = iterator.next(); if (PsiElementOrderComparator.getInstance().compare(element, originalMember) < 0) { addElementAndWhitespaceBeforeAnchor(replacementClass, element, anchor); iterator.remove(); } else { break; } } } final PsiElement anchor = replacementClass.getRBrace(); if (anchor == null) { return; } for (PsiElement element : elements) { addElementAndWhitespaceBeforeAnchor(replacementClass, element, anchor); } }