void (@NotNull Editor editor, @NotNull GroovySmartEnterProcessor processor, @NotNull PsiElement psiElement) { if (psiElement instanceof GrWhileStatement whileStatement) { final Document doc = editor.getDocument(); final PsiElement rParenth = whileStatement.getRParenth(); final PsiElement lParenth = whileStatement.getLParenth(); final GrCondition condition = whileStatement.getCondition(); if (condition == null) { if (lParenth == null || rParenth == null) { int stopOffset = doc.getLineEndOffset(doc.getLineNumber(whileStatement.getTextRange().getStartOffset())); final GrStatement block = whileStatement.getBody(); if (block != null) { stopOffset = Math.min(stopOffset, block.getTextRange().getStartOffset()); } stopOffset = Math.min(stopOffset, whileStatement.getTextRange().getEndOffset()); doc.replaceString(whileStatement.getTextRange().getStartOffset(), stopOffset, "while ()"); processor.registerUnresolvedError(whileStatement.getTextRange().getStartOffset() + "while (".length()); } else { processor.registerUnresolvedError(lParenth.getTextRange().getEndOffset()); } } else if (rParenth == null) { doc.insertString(condition.getTextRange().getEndOffset(), ")"); } } }