PsiCodeFragment (@NotNull Project project, @NotNull String text, String contextId) { final PsiCodeFragmentImpl fragment = MEMBER_CONTEXT.getId().equals(contextId) ? (PsiCodeFragmentImpl)JavaCodeFragmentFactory.getInstance(project).createMemberCodeFragment(text, null, true) : (PsiCodeFragmentImpl)JavaCodeFragmentFactory.getInstance(project).createCodeBlockCodeFragment(text, null, true); fragment.setIntentionActionsFilter(intentionAction -> false); return fragment; }