boolean (PsiElement element, boolean commentIsContent, boolean emptyBlocks) { if (!commentIsContent && element instanceof PsiComment) { return true; } else if (element instanceof PsiEmptyStatement) { return !commentIsContent || PsiTreeUtil.getChildOfType(element, PsiComment.class) == null && !(PsiTreeUtil.skipWhitespacesBackward(element) instanceof PsiComment); } else if (element instanceof PsiWhiteSpace) { return true; } else if (element instanceof final PsiBlockStatement block) { return isEmpty(block.getCodeBlock(), commentIsContent, emptyBlocks); } else if (emptyBlocks && element instanceof final PsiCodeBlock codeBlock) { final PsiElement[] children = codeBlock.getChildren(); if (children.length == 2) { return true; } for (int i = 1; i < children.length - 1; i++) { final PsiElement child = children[i]; if (!isEmpty(child, commentIsContent, true)) { return false; } } return true; } return false; }