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 false; } if (innerClasses.contains(field.getContainingClass())) { return false; } return true; } }; for (PsiField field : fields) { field.accept(visitor); } for (PsiMethod method : methods) { method.accept(visitor); } for (PsiClass innerClass : innerClasses) { innerClass.accept(visitor); } return visitor; }