Search in sources :

Example 1 with PsiNamedElementUsageGroupBase

use of com.intellij.usages.PsiNamedElementUsageGroupBase in project Perl5-IDEA by Camelcade.

the class PodUsageGroupingRule method getParentGroupFor.

@Override
@Nullable
protected UsageGroup getParentGroupFor(@NotNull Usage usage, @NotNull UsageTarget[] targets) {
    if (!(usage instanceof PsiElementUsage)) {
        return null;
    }
    PsiElement element = ((PsiElementUsage) usage).getElement();
    if (element == null || !element.getLanguage().isKindOf(PodLanguage.INSTANCE)) {
        return null;
    }
    PsiElement structuralParentElement = PodBreadCrumbsProvider.getStructuralParentElement(element);
    if (structuralParentElement instanceof PodTitledSection) {
        return new PsiNamedElementUsageGroupBase<>((PodTitledSection) structuralParentElement);
    }
    return null;
}
Also used : PodTitledSection(com.perl5.lang.pod.parser.psi.PodTitledSection) PsiNamedElementUsageGroupBase(com.intellij.usages.PsiNamedElementUsageGroupBase) PsiElement(com.intellij.psi.PsiElement) PsiElementUsage(com.intellij.usages.rules.PsiElementUsage) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 PsiNamedElementUsageGroupBase (com.intellij.usages.PsiNamedElementUsageGroupBase)1 PsiElementUsage (com.intellij.usages.rules.PsiElementUsage)1 PodTitledSection (com.perl5.lang.pod.parser.psi.PodTitledSection)1 Nullable (org.jetbrains.annotations.Nullable)1