Search in sources :

Example 1 with PsiPerlSubSignatureElementIgnore

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

the class PerlSubDefinitionMixin method processSignatureElement.

@Override
protected boolean processSignatureElement(PsiElement signatureElement, List<PerlSubArgument> arguments) {
    if (!super.processSignatureElement(signatureElement, arguments)) {
        if (signatureElement instanceof PsiPerlSubSignatureElementIgnore) {
            PerlSubArgument newArgument = PerlSubArgument.empty();
            // has elements inside, means optional
            newArgument.setOptional(signatureElement.getFirstChild() != signatureElement.getLastChild());
            arguments.add(newArgument);
        } else if (signatureElement.getNode().getElementType() == PerlElementTypes.OPERATOR_ASSIGN && arguments.size() > 0) {
            // setting last element as optional
            arguments.get(arguments.size() - 1).setOptional(true);
        } else {
            return false;
        }
    }
    return true;
}
Also used : PerlSubArgument(com.perl5.lang.perl.psi.utils.PerlSubArgument) PsiPerlSubSignatureElementIgnore(com.perl5.lang.perl.psi.PsiPerlSubSignatureElementIgnore)

Aggregations

PsiPerlSubSignatureElementIgnore (com.perl5.lang.perl.psi.PsiPerlSubSignatureElementIgnore)1 PerlSubArgument (com.perl5.lang.perl.psi.utils.PerlSubArgument)1