Search in sources :

Example 1 with CLASS_ACCESSOR_METHOD

use of com.perl5.lang.perl.parser.Class.Accessor.ClassAccessorElementTypes.CLASS_ACCESSOR_METHOD in project Perl5-IDEA by Camelcade.

the class PerlClassAccessorHandler method computeLightElementsFromPsi.

@Override
@NotNull
public List<? extends PerlDelegatingLightNamedElement<?>> computeLightElementsFromPsi(@NotNull PerlSubCallElement psiElement) {
    String packageName = PerlPackageUtil.getContextNamespaceName(psiElement);
    if (StringUtil.isEmpty(packageName)) {
        return Collections.emptyList();
    }
    List<PsiElement> listElements = psiElement.getCallArgumentsList();
    if (listElements.isEmpty()) {
        return Collections.emptyList();
    }
    List<PerlDelegatingLightNamedElement<?>> result = new ArrayList<>();
    for (PsiElement listElement : listElements) {
        if (!psiElement.isAcceptableIdentifierElement(listElement)) {
            continue;
        }
        String baseName = ElementManipulators.getValueText(listElement);
        PerlSubAnnotations subAnnotations = PerlSubAnnotations.computeForLightElement(psiElement, listElement);
        for (Function<String, String> computation : getNamesComputations(psiElement)) {
            result.add(new PerlClassAccessorMethod(psiElement, baseName, computation, CLASS_ACCESSOR_METHOD, listElement, packageName, subAnnotations));
        }
    }
    return result;
}
Also used : PerlSubAnnotations(com.perl5.lang.perl.psi.utils.PerlSubAnnotations) PerlDelegatingLightNamedElement(com.perl5.lang.perl.psi.light.PerlDelegatingLightNamedElement) ArrayList(java.util.ArrayList) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with CLASS_ACCESSOR_METHOD

use of com.perl5.lang.perl.parser.Class.Accessor.ClassAccessorElementTypes.CLASS_ACCESSOR_METHOD in project Perl5-IDEA by Camelcade.

the class PerlClassAccessorWrapper method calcLightElementsFromPsi.

@NotNull
@Override
public List<PerlDelegatingLightNamedElement> calcLightElementsFromPsi() {
    String packageName = PerlPackageUtil.getContextPackageName(this);
    if (StringUtil.isEmpty(packageName)) {
        return Collections.emptyList();
    }
    List<PsiElement> listElements = getCallArgumentsList();
    if (listElements.isEmpty()) {
        return Collections.emptyList();
    }
    List<PerlDelegatingLightNamedElement> result = new ArrayList<>();
    for (PsiElement listElement : listElements) {
        if (!isAcceptableIdentifierElement(listElement)) {
            continue;
        }
        String baseName = ElementManipulators.getValueText(listElement);
        PerlSubAnnotations subAnnotations = computeSubAnnotations(this, listElement);
        for (Function<String, String> computation : getNamesComputations()) {
            result.add(new PerlClassAccessorMethod(this, baseName, computation, CLASS_ACCESSOR_METHOD, listElement, packageName, subAnnotations));
        }
    }
    return result;
}
Also used : PerlSubAnnotations(com.perl5.lang.perl.psi.utils.PerlSubAnnotations) PerlDelegatingLightNamedElement(com.perl5.lang.perl.psi.light.PerlDelegatingLightNamedElement) ArrayList(java.util.ArrayList) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiElement (com.intellij.psi.PsiElement)2 PerlDelegatingLightNamedElement (com.perl5.lang.perl.psi.light.PerlDelegatingLightNamedElement)2 PerlSubAnnotations (com.perl5.lang.perl.psi.utils.PerlSubAnnotations)2 ArrayList (java.util.ArrayList)2 NotNull (org.jetbrains.annotations.NotNull)2