void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiExpression expr = PsiTreeUtil.getNonStrictParentOfType(element, PsiExpression.class); if (expr == null) return; CodeBlockSurrounder surrounder = CodeBlockSurrounder.forExpression(expr); if (surrounder == null) return; CodeBlockSurrounder.SurroundResult result = surrounder.surround(); expr = result.getExpression(); PsiElement anchorElement = result.getAnchor(); PsiElement prev = PsiTreeUtil.skipWhitespacesBackward(anchorElement); if (prev instanceof PsiComment && JavaSuppressionUtil.getSuppressedInspectionIdsIn(prev) != null) { anchorElement = prev; } final PsiElementFactory factory = JavaPsiFacade.getElementFactory(expr.getProject()); @NonNls String text = "assert " + myText + ";"; PsiAssertStatement assertStatement = (PsiAssertStatement)factory.createStatementFromText(text, expr); anchorElement.getParent().addBefore(assertStatement, anchorElement); }