Generator<ActionOnFile> (@NotNull PsiFile file) { InvokeIntention anyIntentionInSwitchRange = new InvokeIntentionAtElement( file, new JavaIntentionPolicy(), PsiSwitchBlock.class, Function.identity()); InvokeIntention replaceToEnhancedSwitchIntention = new InvokeIntentionAtElement(file, new IntentionPolicy() { @Override protected boolean shouldSkipIntention(@NotNull String actionText) { return !"Replace with 'switch' expression".equals(actionText) && !"Replace with enhanced 'switch' statement".equals(actionText); } }, PsiSwitchBlock.class, PsiSwitchBlock::getFirstChild); return Generator.sampledFrom(anyIntentionInSwitchRange, replaceToEnhancedSwitchIntention, new StripTestDataMarkup(file)); }