Search in sources :

Example 1 with PerlSubCallElementData

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

the class PerlClassAccessorHandler method isFollowBestPractice.

static boolean isFollowBestPractice(@NotNull PerlSubCallElement psiElement) {
    PerlSubCallElementStub stub = psiElement.getGreenStub();
    if (stub != null) {
        PerlSubCallElementData callData = stub.getCallData();
        LOG.assertTrue(callData instanceof PerlClassAccessorCallData, "Got: " + callData);
        return ((PerlClassAccessorCallData) callData).isFBP();
    }
    return CachedValuesManager.getCachedValue(psiElement, () -> {
        Ref<Boolean> result = Ref.create(Boolean.FALSE);
        // fixme we need a smarter treewalkup here, scopes are not necessary here
        PerlResolveUtil.treeWalkUp(psiElement, (element, state) -> {
            if (element instanceof PsiPerlNamespaceContent) {
                return false;
            }
            if (element instanceof PerlSubCallElement && StringUtil.equals("follow_best_practice", ((PerlSubCallElement) element).getSubName())) {
                result.set(Boolean.TRUE);
                return false;
            }
            return true;
        });
        return CachedValueProvider.Result.create(result.get(), psiElement);
    }) == Boolean.TRUE;
}
Also used : PerlSubCallElementData(com.perl5.lang.perl.psi.stubs.calls.PerlSubCallElementData) Arrays(java.util.Arrays) PerlPackageUtil(com.perl5.lang.perl.util.PerlPackageUtil) CLASS_ACCESSOR_METHOD(com.perl5.lang.perl.parser.Class.Accessor.ClassAccessorElementTypes.CLASS_ACCESSOR_METHOD) PerlSubCallElementStub(com.perl5.lang.perl.psi.stubs.calls.PerlSubCallElementStub) PerlSubCallHandler(com.perl5.lang.perl.psi.PerlSubCallHandler) PerlSubCallElement(com.perl5.lang.perl.psi.impl.PerlSubCallElement) GETTER_COMPUTATION(com.perl5.lang.perl.parser.Class.Accessor.psi.impl.PerlClassAccessorMethod.GETTER_COMPUTATION) ArrayList(java.util.ArrayList) CachedValueProvider(com.intellij.psi.util.CachedValueProvider) SETTER_COMPUTATION(com.perl5.lang.perl.parser.Class.Accessor.psi.impl.PerlClassAccessorMethod.SETTER_COMPUTATION) StubInputStream(com.intellij.psi.stubs.StubInputStream) PsiElement(com.intellij.psi.PsiElement) Logger(com.intellij.openapi.diagnostic.Logger) PerlSubCallElementData(com.perl5.lang.perl.psi.stubs.calls.PerlSubCallElementData) ElementManipulators(com.intellij.psi.ElementManipulators) PerlDelegatingLightNamedElement(com.perl5.lang.perl.psi.light.PerlDelegatingLightNamedElement) StringUtil(com.intellij.openapi.util.text.StringUtil) PerlSubDefinitionStub(com.perl5.lang.perl.psi.stubs.subsdefinitions.PerlSubDefinitionStub) IOException(java.io.IOException) StubOutputStream(com.intellij.psi.stubs.StubOutputStream) PerlSubAnnotations(com.perl5.lang.perl.psi.utils.PerlSubAnnotations) Collectors(java.util.stream.Collectors) CachedValuesManager(com.intellij.psi.util.CachedValuesManager) PsiPerlNamespaceContent(com.perl5.lang.perl.psi.PsiPerlNamespaceContent) List(java.util.List) Function(com.intellij.util.Function) PerlResolveUtil(com.perl5.lang.perl.psi.utils.PerlResolveUtil) NotNull(org.jetbrains.annotations.NotNull) Ref(com.intellij.openapi.util.Ref) Collections(java.util.Collections) Ref(com.intellij.openapi.util.Ref) PerlSubCallElementStub(com.perl5.lang.perl.psi.stubs.calls.PerlSubCallElementStub) PerlSubCallElement(com.perl5.lang.perl.psi.impl.PerlSubCallElement) PsiPerlNamespaceContent(com.perl5.lang.perl.psi.PsiPerlNamespaceContent)

Aggregations

Logger (com.intellij.openapi.diagnostic.Logger)1 Ref (com.intellij.openapi.util.Ref)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 ElementManipulators (com.intellij.psi.ElementManipulators)1 PsiElement (com.intellij.psi.PsiElement)1 StubInputStream (com.intellij.psi.stubs.StubInputStream)1 StubOutputStream (com.intellij.psi.stubs.StubOutputStream)1 CachedValueProvider (com.intellij.psi.util.CachedValueProvider)1 CachedValuesManager (com.intellij.psi.util.CachedValuesManager)1 Function (com.intellij.util.Function)1 CLASS_ACCESSOR_METHOD (com.perl5.lang.perl.parser.Class.Accessor.ClassAccessorElementTypes.CLASS_ACCESSOR_METHOD)1 GETTER_COMPUTATION (com.perl5.lang.perl.parser.Class.Accessor.psi.impl.PerlClassAccessorMethod.GETTER_COMPUTATION)1 SETTER_COMPUTATION (com.perl5.lang.perl.parser.Class.Accessor.psi.impl.PerlClassAccessorMethod.SETTER_COMPUTATION)1 PerlSubCallHandler (com.perl5.lang.perl.psi.PerlSubCallHandler)1 PsiPerlNamespaceContent (com.perl5.lang.perl.psi.PsiPerlNamespaceContent)1 PerlSubCallElement (com.perl5.lang.perl.psi.impl.PerlSubCallElement)1 PerlDelegatingLightNamedElement (com.perl5.lang.perl.psi.light.PerlDelegatingLightNamedElement)1 PerlSubCallElementData (com.perl5.lang.perl.psi.stubs.calls.PerlSubCallElementData)1 PerlSubCallElementStub (com.perl5.lang.perl.psi.stubs.calls.PerlSubCallElementStub)1 PerlSubDefinitionStub (com.perl5.lang.perl.psi.stubs.subsdefinitions.PerlSubDefinitionStub)1