boolean (@NotNull UExpression expression, @NotNull List<? super UExpression> formatParameters, @NotNull Project project, @NotNull StringBuilder result) { if (!(expression instanceof UIfExpression)) return false; PsiElement sourcePsi = expression.getSourcePsi(); if (sourcePsi == null) return false; UastCodeGenerationPlugin generationPlugin = UastCodeGenerationPlugin.byLanguage(sourcePsi.getLanguage()); if (generationPlugin == null) return false; UExpression thenExpression = ((UIfExpression)expression).getThenExpression(); UExpression elseExpression = ((UIfExpression)expression).getElseExpression(); if (!(thenExpression instanceof ULiteralExpression) && !(elseExpression instanceof ULiteralExpression)) return false; boolean nested = !(thenExpression instanceof ULiteralExpression && elseExpression instanceof ULiteralExpression); String thenStr = getSideText(formatParameters, project, thenExpression, nested); String elseStr = getSideText(formatParameters, project, elseExpression, nested); result.append("{") .append(formatParameters.size()) .append(", choice, 0#").append(thenStr) .append("|1#").append(elseStr) .append("}"); PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); UIfExpression exCopy = UastContextKt.toUElement(sourcePsi.copy(), UIfExpression.class); assert exCopy != null; generationPlugin.replace(Objects.requireNonNull(exCopy.getThenExpression()), Objects.requireNonNull(UastContextKt.toUElement(elementFactory.createExpressionFromText("0", null), ULiteralExpression.class)), ULiteralExpression.class); generationPlugin.replace(Objects.requireNonNull(exCopy.getElseExpression()), Objects.requireNonNull(UastContextKt.toUElement(elementFactory.createExpressionFromText("1", null), ULiteralExpression.class)), ULiteralExpression.class); formatParameters.add(exCopy); return true; }