use of com.perl5.lang.perl.psi.impl.PsiPerlCommaSequenceExprImpl in project Perl5-IDEA by Camelcade.
the class PerlParameterInfoHandler method markActiveparametersRecursively.
private static int markActiveparametersRecursively(PsiElement element, PerlParameterInfo[] parameterInfos, int currentIndex, int offset) {
while (element != null) {
if (parameterInfos.length <= currentIndex) {
return currentIndex;
}
IElementType elementType = PsiUtilCore.getElementType(element);
if (element instanceof PsiPerlParenthesisedExprImpl || element instanceof PsiPerlCommaSequenceExprImpl) {
currentIndex = markActiveparametersRecursively(element.getFirstChild(), parameterInfos, currentIndex, offset);
} else {
if (isComma(elementType)) {
if (parameterInfos[currentIndex].getArgument().getContextType() == PerlContextType.SCALAR) {
currentIndex++;
}
}
}
if (element.getTextRange().getEndOffset() >= offset) {
if (element instanceof PerlCompositeElementImpl) {
PerlContextType valueContextType = PerlContextType.from(element);
if (valueContextType == PerlContextType.SCALAR) {
if (currentIndex < parameterInfos.length) {
parameterInfos[currentIndex].setSelected(true);
}
return parameterInfos.length;
} else if (// consumes all arguments to the end
valueContextType == PerlContextType.LIST) {
while (currentIndex < parameterInfos.length) {
parameterInfos[currentIndex++].setSelected(true);
}
return currentIndex;
}
}
// space, comma or smth
if (currentIndex < parameterInfos.length) {
parameterInfos[currentIndex].setSelected(true);
}
return parameterInfos.length;
} else if (elementType == SUB_EXPR && element.getFirstChild() instanceof PsiPerlBlock) {
PsiElement nextSibling = PerlPsiUtil.getNextSignificantSibling(element);
if (!isComma(PsiUtilCore.getElementType(nextSibling))) {
currentIndex++;
}
} else if (isPrintHandleArgument(element)) {
currentIndex++;
}
element = element.getNextSibling();
}
return currentIndex;
}
Aggregations