boolean (@NotNull Editor editor, @Nullable ASTNode astNode) { if (!(BasicJavaAstTreeUtil.is(astNode, BASIC_FOR_STATEMENT))) { return false; } ASTNode condition = BasicJavaAstTreeUtil.getForCondition(astNode); if (BasicJavaAstTreeUtil.getForUpdate(astNode) != null || condition == null) { return false; } TextRange range = condition.getTextRange(); Document document = editor.getDocument(); CharSequence text = document.getCharsSequence(); for (int i = range.getEndOffset() - 1, max = astNode.getTextRange().getEndOffset(); i < max; i++) { if (text.charAt(i) == ';') { return false; } } String toInsert = ";"; PsiElement psiElement = BasicJavaAstTreeUtil.toPsi(astNode); if (psiElement != null && getSpaceAfterSemicolon(psiElement)) { toInsert += " "; } document.insertString(range.getEndOffset(), toInsert); return true; }