Search in sources :

Example 1 with PerlSubExpr

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

the class MojoHelperWrapper method calcLightElementsFromPsi.

@NotNull
@Override
public List<PerlDelegatingLightNamedElement> calcLightElementsFromPsi() {
    List<PsiElement> listElements = getCallArgumentsList();
    if (listElements.size() != 2) {
        return Collections.emptyList();
    }
    PsiElement identifierElement = listElements.get(0);
    if (!isAcceptableIdentifierElement(identifierElement)) {
        return Collections.emptyList();
    }
    PsiElement bodyElement = listElements.get(1);
    // fixme we could handle reference here
    if (!(bodyElement instanceof PerlSubExpr)) {
        return Collections.emptyList();
    }
    String subName = ElementManipulators.getValueText(identifierElement);
    if (StringUtil.isEmpty(subName)) {
        return Collections.emptyList();
    }
    PsiPerlBlock subDefinitionBody = ((PerlSubExpr) bodyElement).getBlock();
    return Collections.singletonList(new MojoHelperDefinition(this, subName, LIGHT_METHOD_DEFINITION, identifierElement, MOJO_CONTROLLER_NS, PerlSubDefinitionElement.getPerlSubArgumentsFromBody(subDefinitionBody), computeSubAnnotations(this, identifierElement), subDefinitionBody));
}
Also used : PsiPerlBlock(com.perl5.lang.perl.psi.PsiPerlBlock) PerlSubExpr(com.perl5.lang.perl.psi.PerlSubExpr) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 PerlSubExpr (com.perl5.lang.perl.psi.PerlSubExpr)1 PsiPerlBlock (com.perl5.lang.perl.psi.PsiPerlBlock)1 NotNull (org.jetbrains.annotations.NotNull)1