Search in sources :

Example 1 with PerlPolyNamedElementStub

use of com.perl5.lang.perl.psi.stubs.PerlPolyNamedElementStub in project Perl5-IDEA by Camelcade.

the class PerlClassAccessorWrapper method isFollowBestPractice.

public boolean isFollowBestPractice() {
    PerlPolyNamedElementStub stub = getStub();
    if (stub != null) {
        return ((PerlClassAccessorWrapperStub) stub).isFollowBestPractice();
    }
    PerlClassAccessorWrapperStub greenStub = getGreenStub();
    if (greenStub != null) {
        return greenStub.isFollowBestPractice();
    }
    boolean[] result = new boolean[] { false };
    // fixme we need a smarter treewalkup here, scopes are not necessary here
    PerlResolveUtil.treeWalkUp(this, (element, state) -> {
        if (element instanceof PsiPerlNamespaceContent) {
            return false;
        }
        if (PsiUtilCore.getElementType(element) == CLASS_ACCESSOR_FBP) {
            result[0] = true;
            return false;
        }
        return true;
    });
    return result[0];
}
Also used : PerlPolyNamedElementStub(com.perl5.lang.perl.psi.stubs.PerlPolyNamedElementStub) PerlClassAccessorWrapperStub(com.perl5.lang.perl.parser.Class.Accessor.psi.stubs.PerlClassAccessorWrapperStub) PsiPerlNamespaceContent(com.perl5.lang.perl.psi.PsiPerlNamespaceContent)

Example 2 with PerlPolyNamedElementStub

use of com.perl5.lang.perl.psi.stubs.PerlPolyNamedElementStub in project Perl5-IDEA by Camelcade.

the class PerlPsiUtil method processElementsFromStubs.

public static boolean processElementsFromStubs(@Nullable Stub stub, @Nullable Processor<PsiElement> processor, @Nullable Class<? extends PsiElement> avoidPsiClass) {
    if (stub == null || processor == null) {
        return false;
    }
    for (Stub childStub : stub.getChildrenStubs()) {
        ProgressManager.checkCanceled();
        PsiElement childPsi = ((StubElement) childStub).getPsi();
        if (!processor.process(childPsi)) {
            return false;
        }
        if (// don't enter sublcasses
        avoidPsiClass == null || !avoidPsiClass.isInstance(childPsi)) {
            if (!processElementsFromStubs(childStub, processor, avoidPsiClass)) {
                return false;
            }
        }
    }
    if (stub instanceof PerlPolyNamedElementStub) {
        for (PsiElement child : ((PerlPolyNamedElementStub) stub).getPsi().getLightElements()) {
            ProgressManager.checkCanceled();
            if (!processor.process(child)) {
                return false;
            }
        }
    }
    return true;
}
Also used : PerlPolyNamedElementStub(com.perl5.lang.perl.psi.stubs.PerlPolyNamedElementStub) PerlPolyNamedElementStub(com.perl5.lang.perl.psi.stubs.PerlPolyNamedElementStub) Stub(com.intellij.psi.stubs.Stub) PsiFileStub(com.intellij.psi.stubs.PsiFileStub) StubElement(com.intellij.psi.stubs.StubElement) ASTWrapperPsiElement(com.intellij.extapi.psi.ASTWrapperPsiElement)

Aggregations

PerlPolyNamedElementStub (com.perl5.lang.perl.psi.stubs.PerlPolyNamedElementStub)2 ASTWrapperPsiElement (com.intellij.extapi.psi.ASTWrapperPsiElement)1 PsiFileStub (com.intellij.psi.stubs.PsiFileStub)1 Stub (com.intellij.psi.stubs.Stub)1 StubElement (com.intellij.psi.stubs.StubElement)1 PerlClassAccessorWrapperStub (com.perl5.lang.perl.parser.Class.Accessor.psi.stubs.PerlClassAccessorWrapperStub)1 PsiPerlNamespaceContent (com.perl5.lang.perl.psi.PsiPerlNamespaceContent)1