ASTNode (@Nullable ASTNode node, TokenSet tokens, ArrayList<? super FoldingDescriptor> regions, Document document) { if (node != null && tokens.contains(node.getElementType())) { final ASTNode start = node; ASTNode end = start; node = node.getTreeNext(); if (node != null) { do { end = node; node = node.getTreeNext(); } while (node != null && tokens.contains(node.getElementType())); } if (end != start) { while (end.getPsi() instanceof PsiWhiteSpace) { end = end.getTreePrev(); } if (isOnDifferentLine(start, end, document)) { regions.add(new FoldingDescriptor(start, new TextRange(start.getStartOffset(), end.getTextRange().getEndOffset()))); } } } return node; }