Search in sources :

Example 1 with CfmlCompositeElement

use of com.intellij.coldFusion.model.psi.CfmlCompositeElement in project intellij-plugins by JetBrains.

the class CfmlFoldingBuilder method buildFoldRegions.

@NotNull
public FoldingDescriptor[] buildFoldRegions(@NotNull ASTNode node, @NotNull Document document) {
    final PsiElement element = node.getPsi();
    if (element instanceof CfmlFile) {
        final CfmlFile file = (CfmlFile) element;
        final PsiElement[] children = file.getChildren();
        Collection<FoldingDescriptor> result = new LinkedList<>();
        for (PsiElement child : children) {
            if (child != null && (child instanceof CfmlCompositeElement || child instanceof PsiComment)) {
                List<FoldingDescriptor> descriptors = new ArrayList<>();
                addFoldingDescriptors(descriptors, child, document);
                result.addAll(descriptors);
            }
        }
        return result.toArray(FoldingDescriptor.EMPTY);
    }
    return FoldingDescriptor.EMPTY;
}
Also used : FoldingDescriptor(com.intellij.lang.folding.FoldingDescriptor) PsiComment(com.intellij.psi.PsiComment) CfmlFile(com.intellij.coldFusion.model.files.CfmlFile) ArrayList(java.util.ArrayList) CfmlCompositeElement(com.intellij.coldFusion.model.psi.CfmlCompositeElement) PsiElement(com.intellij.psi.PsiElement) LinkedList(java.util.LinkedList) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

CfmlFile (com.intellij.coldFusion.model.files.CfmlFile)1 CfmlCompositeElement (com.intellij.coldFusion.model.psi.CfmlCompositeElement)1 FoldingDescriptor (com.intellij.lang.folding.FoldingDescriptor)1 PsiComment (com.intellij.psi.PsiComment)1 PsiElement (com.intellij.psi.PsiElement)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 NotNull (org.jetbrains.annotations.NotNull)1