List<FoldingDescriptor> descriptors = new ArrayList<FoldingDescriptor>();
PsiElement child = node.getPsi().getFirstChild();
while (child != null) {
if (child instanceof RootPsiElement) {
RootPsiElement rootPsiElement = (RootPsiElement) child;
/*FoldingDescriptor rootFoldingDescriptor = new FoldingDescriptor(
rootPsiElement.getAstNode(),
rootPsiElement.getTextRange());
foldingDescriptors.add(rootFoldingDescriptor);*/
for (ExecutablePsiElement executablePsiElement : rootPsiElement.getExecutablePsiElements()) {
FoldingDescriptor foldingDescriptor = new FoldingDescriptor(
executablePsiElement.getNode(),
executablePsiElement.getTextRange());
descriptors.add(foldingDescriptor);
}