void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { if (!(element instanceof PsiExpression expression)) { return; } CommentTracker tracker = new CommentTracker(); String simplifiedExpression = buildSimplifiedExpression(expression, new StringBuilder(), tracker).toString(); boolean isConstant = simplifiedExpression.equals("true") || simplifiedExpression.equals("false"); if (isConstant && myHasSideEffect) { CodeBlockSurrounder surrounder = CodeBlockSurrounder.forExpression(expression); if (surrounder == null) return; CodeBlockSurrounder.SurroundResult result = surrounder.surround(); expression = result.getExpression(); PsiStatement anchor = result.getAnchor(); List<PsiExpression> sideEffects = extractSideEffects(expression); for (PsiExpression sideEffect : sideEffects) { tracker.markUnchanged(sideEffect); } PsiStatement[] statements = StatementExtractor.generateStatements(sideEffects, expression); if (statements.length > 0) { BlockUtils.addBefore(anchor, statements); } } expression = (PsiExpression)tracker.replaceAndRestoreComments(expression, simplifiedExpression); PsiExpression topExpression = ExpressionUtils.getTopLevelExpression(expression); if (getExpressionKind(topExpression) == BooleanExpressionKind.USELESS) { tracker = new CommentTracker(); simplifiedExpression = buildSimplifiedExpression(topExpression, new StringBuilder(), tracker).toString(); tracker.replaceAndRestoreComments(topExpression, simplifiedExpression); } }