boolean (@NotNull PsiComment comment) { final JavaCodeFoldingSettings settings = JavaCodeFoldingSettings.getInstance(); final PsiElement parent = comment.getParent(); if (parent instanceof PsiJavaFile) { if (((PsiJavaFile)parent).getName().equals(PsiPackage.PACKAGE_INFO_FILE)) { return false; } PsiElement firstChild = parent.getFirstChild(); if (firstChild instanceof PsiWhiteSpace) { firstChild = firstChild.getNextSibling(); } if (comment.equals(firstChild)) { return settings.isCollapseFileHeader(); } } if (comment instanceof PsiDocComment) return settings.isCollapseJavadocs(); final IElementType commentType = comment.getTokenType(); if (commentType == JavaTokenType.END_OF_LINE_COMMENT) return settings.isCollapseEndOfLineComments(); if (commentType == JavaTokenType.C_STYLE_COMMENT) return settings.isCollapseMultilineComments(); return false; }