void (@NotNull ActionContext context, @NotNull PsiDeconstructionList deconstructionList, @NotNull ModPsiUpdater updater) { if (deconstructionList.getParent() instanceof PsiDeconstructionPattern deconstructionPattern) { boolean isEmptyList = deconstructionList.getDeconstructionComponents().length == 0; String deconstructionListText = deconstructionList.getText(); String prefix = deconstructionListText.substring(0, deconstructionListText.length() - 1) + (isEmptyList ? "" : ","); String newDeconstructionListText = StreamEx.of(myMissingPatterns).map(Pattern::toString).joining(",", prefix, ")"); PsiElementFactory factory = PsiElementFactory.getInstance(context.project()); String text = "o instanceof " + deconstructionPattern.getTypeElement().getText() + newDeconstructionListText; PsiInstanceOfExpression instanceOf = (PsiInstanceOfExpression)factory.createExpressionFromText(text, null); PsiDeconstructionPattern newPattern = (PsiDeconstructionPattern)instanceOf.getPattern(); assert newPattern != null; deconstructionPattern.replace(newPattern); } }