void (@NotNull ActionContext context, @NotNull PsiSwitchBlock switchBlock, @NotNull ModPsiUpdater updater) { if (!HighlightingFeature.PATTERNS_IN_SWITCH.isAvailable(switchBlock)) return; PsiCodeBlock body = switchBlock.getBody(); if (body == null) return; PsiExpression selector = switchBlock.getExpression(); if (selector == null) return; PsiType selectorType = selector.getType(); if (selectorType == null) return; List<PsiElement> branches = SwitchUtils.getSwitchBranches(switchBlock); for (PsiElement branch : branches) { // just for the case if we already contain null, there is no need to apply the fix if (branch instanceof PsiExpression expression && TypeConversionUtil.isNullType(expression.getType())) return; } PsiElement unconditionalLabel = findUnconditionalLabel(switchBlock); PsiElement bodyElement = body.getFirstBodyElement(); if (bodyElement instanceof PsiWhiteSpace && bodyElement == body.getLastBodyElement()) { bodyElement.delete(); } PsiElement anchor = unconditionalLabel != null ? unconditionalLabel : body.getRBrace(); if (anchor == null) return; PsiElementFactory factory = JavaPsiFacade.getElementFactory(anchor.getProject()); generateStatements(switchBlock, SwitchUtils.isRuleFormatSwitch(switchBlock), unconditionalLabel) .stream() .map(text -> factory.createStatementFromText(text, body)) .forEach(statement -> body.addBefore(statement, anchor)); CreateDefaultBranchFix.startTemplateOnStatement(PsiTreeUtil.getPrevSiblingOfType(anchor, PsiStatement.class), updater); }