RefactoringElementListener (PsiElement element) { final RefactoringElementListenerComposite composite = new RefactoringElementListenerComposite(); final JUnitConfiguration.Data data = getConfiguration().getPersistentData(); final Set<String> patterns = data.getPatterns(); for (final String pattern : patterns) { final PsiClass testClass = getTestClass(getConfiguration().getProject(), pattern.trim()); if (testClass != null && testClass.equals(element)) { final RefactoringElementListener listeners = RefactoringListeners.getListeners(testClass, new RefactoringListeners.Accessor<>() { private String myOldName = testClass.getQualifiedName(); @Override public void setName(String qualifiedName) { final Set<String> replaced = new LinkedHashSet<>(); for (String currentPattern : patterns) { if (myOldName.equals(currentPattern)) { replaced.add(qualifiedName); myOldName = qualifiedName; } else { replaced.add(currentPattern); } } patterns.clear(); patterns.addAll(replaced); } @Override public PsiClass getPsiElement() { return testClass; } @Override public void setPsiElement(PsiClass psiElement) { if (psiElement == testClass) { setName(psiElement.getQualifiedName()); } } }); if (listeners != null) { composite.addListener(listeners); } } } return composite; }