IntentionPreviewInfo (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { PsiNewExpression element = myNewExpression.getElement(); if (element == null) return IntentionPreviewInfo.EMPTY; PsiJavaCodeReferenceElement classReference = getReferenceElement(element); if (classReference == null) return IntentionPreviewInfo.EMPTY; PsiClass aClass = (PsiClass)file.add(getKind().create(JavaPsiFacade.getElementFactory(project), classReference.getReferenceName())); setupClassFromNewExpression(aClass, element); setupGenericParameters(aClass, classReference); CodeStyleManager.getInstance(project).reformat(aClass); return new IntentionPreviewInfo.CustomDiff(JavaFileType.INSTANCE, "", aClass.getText()); }