IntentionPreviewInfo (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { final PsiField psiField = PsiTreeUtil.getParentOfType(getElement(editor, file), PsiField.class); if (psiField == null) return IntentionPreviewInfo.EMPTY; PsiType type = psiField.getType(); if (type == PsiTypes.nullType()) return IntentionPreviewInfo.EMPTY; String fieldName = psiField.getName(); String presentableText = type.getPresentableText(); String genericArg = presentableText; if (type instanceof PsiPrimitiveType) { genericArg = StringUtil.getShortName(Objects.requireNonNull(((PsiPrimitiveType)type).getBoxedTypeName())); } return new IntentionPreviewInfo.CustomDiff(JavaFileType.INSTANCE, null, presentableText + " " + fieldName, "ThreadLocal<" + genericArg + "> " + fieldName + " = ThreadLocal.withInitial(...)"); }