NecessaryAccessorsVisitor () { final NecessaryAccessorsVisitor visitor = new NecessaryAccessorsVisitor() { @Override protected boolean hasGetterOrSetter(PsiMethod[] getters) { for (PsiMethod getter : getters) { if (isInMovedElement(getter)) return true; } return false; } @Override protected boolean isProhibitedReference(PsiField field) { if (fields.contains(field)) { return true; } if (innerClasses.contains(field.getContainingClass())) { return true; } return false; } @Override public void visitMethod(@NotNull PsiMethod method) { if (methods.contains(method)) return; super.visitMethod(method); } @Override public void visitField(@NotNull PsiField field) { if (fields.contains(field)) return; super.visitField(field); } @Override public void visitClass(@NotNull PsiClass aClass) { if (innerClasses.contains(aClass)) return; super.visitClass(aClass); } }; sourceClass.accept(visitor); return visitor; }