Search in sources :

Example 1 with PerlStructureViewElement

use of com.perl5.lang.perl.idea.structureView.elements.PerlStructureViewElement in project Perl5-IDEA by Camelcade.

the class PerlAttributeGrouper method group.

@NotNull
@Override
public Collection<Group> group(@NotNull AbstractTreeNode parent, @NotNull Collection<TreeElement> children) {
    if (children.isEmpty() || parent instanceof GroupWrapper && ((GroupWrapper) parent).getValue() instanceof AttributeGroup) {
        return Collections.emptyList();
    }
    Map<PerlMooseAttributeWrapper, AttributeGroup> groupMap = FactoryMap.create(AttributeGroup::new);
    for (TreeElement childTreeElement : children) {
        if (!(childTreeElement instanceof PerlStructureViewElement)) {
            continue;
        }
        Object value = ((PerlStructureViewElement) childTreeElement).getValue();
        if (!(value instanceof PerlLightMethodDefinitionElement)) {
            continue;
        }
        PsiElement delegate = ((PerlLightMethodDefinitionElement) value).getDelegate();
        if (!(delegate instanceof PerlMooseAttributeWrapper)) {
            continue;
        }
        groupMap.get(delegate).addChild(childTreeElement);
    }
    return new ArrayList<>(groupMap.values());
}
Also used : PerlLightMethodDefinitionElement(com.perl5.lang.perl.psi.light.PerlLightMethodDefinitionElement) PerlMooseAttributeWrapper(com.perl5.lang.perl.parser.moose.psi.impl.PerlMooseAttributeWrapper) PerlStructureViewElement(com.perl5.lang.perl.idea.structureView.elements.PerlStructureViewElement) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 PerlStructureViewElement (com.perl5.lang.perl.idea.structureView.elements.PerlStructureViewElement)1 PerlMooseAttributeWrapper (com.perl5.lang.perl.parser.moose.psi.impl.PerlMooseAttributeWrapper)1 PerlLightMethodDefinitionElement (com.perl5.lang.perl.psi.light.PerlLightMethodDefinitionElement)1 NotNull (org.jetbrains.annotations.NotNull)1