IntentionPreviewInfo (@NotNull Project project, @NotNull PsiElement element) { if (!(element instanceof PsiField field)) { return IntentionPreviewInfo.EMPTY; } final FieldDescriptor fieldDescriptor = new FieldDescriptorImpl(field, GenerateMembersUtil.suggestGetterName(field), GenerateMembersUtil.suggestSetterName(field), GenerateMembersUtil.generateGetterPrototype(field), GenerateMembersUtil.generateSetterPrototype(field)); final EncapsulateFieldsDescriptor descriptor = new EncapsulateOnPreviewDescriptor(fieldDescriptor); final EncapsulateFieldsProcessor processor = new EncapsulateFieldsProcessor(project, descriptor) { @Override protected Iterable<PsiReferenceExpression> getFieldReferences(@NotNull PsiField field) { return VariableAccessUtils.getVariableReferences(field, field.getContainingFile()); } }; processor.performRefactoring(processor.findUsages()); return IntentionPreviewInfo.DIFF; }