boolean (@NotNull ASTNode node) { if (isImport(node)) { return CodeFoldingSettings.getInstance().COLLAPSE_IMPORTS; } var elementType = node.getElementType(); if (elementType == PyElementTypes.STRING_LITERAL_EXPRESSION) { if (getDocStringOwnerType(node) == PyElementTypes.FUNCTION_DECLARATION && CodeFoldingSettings.getInstance().COLLAPSE_METHODS) { // method will be collapsed, no need to also collapse docstring return false; } if (getDocStringOwnerType(node) != null) { return CodeFoldingSettings.getInstance().COLLAPSE_DOC_COMMENTS; } return PythonFoldingSettings.getInstance().isCollapseLongStrings(); } if (elementType == PyTokenTypes.END_OF_LINE_COMMENT) { return PythonFoldingSettings.getInstance().isCollapseSequentialComments(); } if (elementType == PyElementTypes.ANNOTATION) { return PythonFoldingSettings.getInstance().isCollapseTypeAnnotations(); } if (elementType == PyElementTypes.STATEMENT_LIST && node.getTreeParent().getElementType() == PyElementTypes.FUNCTION_DECLARATION) { return CodeFoldingSettings.getInstance().COLLAPSE_METHODS; } if (FOLDABLE_COLLECTIONS_LITERALS.contains(elementType)) { return PythonFoldingSettings.getInstance().isCollapseLongCollections(); } return false; }