void (ASTNode node, List<FoldingDescriptor> descriptors) { IElementType elementType = node.getElementType(); if (node.getPsi() instanceof PyFile) { final List<PyImportStatementBase> imports = ((PyFile)node.getPsi()).getImportBlock(); if (imports.size() > 1) { final PyImportStatementBase firstImport = imports.get(0); final PyImportStatementBase lastImport = imports.get(imports.size()-1); descriptors.add(new FoldingDescriptor(firstImport, new TextRange(firstImport.getTextRange().getStartOffset(), lastImport.getTextRange().getEndOffset()))); } } else if (elementType == PyElementTypes.STATEMENT_LIST) { foldStatementList(node, descriptors); } else if (elementType == PyElementTypes.STRING_LITERAL_EXPRESSION) { foldLongStrings(node, descriptors); } else if (FOLDABLE_COLLECTIONS_LITERALS.contains(elementType)) { foldCollectionLiteral(node, descriptors); } else if (elementType == PyTokenTypes.END_OF_LINE_COMMENT) { foldSequentialComments(node, descriptors); } else if (elementType == PyElementTypes.ANNOTATION) { var annotation = node.getPsi(); if (annotation instanceof PyAnnotation pyAnnotation && pyAnnotation.getValue() != null) { descriptors.add(new FoldingDescriptor(node, pyAnnotation.getValue().getTextRange(), FoldingGroup.newGroup(PYTHON_TYPE_ANNOTATION_GROUP_NAME))); } } ASTNode child = node.getFirstChildNode(); while (child != null) { appendDescriptors(child, descriptors); child = child.getTreeNext(); } }