* Returns the index of the corresponding ElementType in it's parent
* Only applicable if the given astNode is corresponding to an ElementType within a SequenceElementType
* For all the other cases it returns 0.
*/
private int getElementTypeIndex(ASTNode astNode){
ASTNode parentAstNode = astNode.getTreeParent();
if (parentAstNode.getElementType() instanceof SequenceElementType) {
SequenceElementType sequenceElementType = (SequenceElementType) parentAstNode.getElementType();
int index = 0;
ASTNode child = parentAstNode.getFirstChildNode();
while (child != null) {
if (astNode == child) {
break;
}
index++;
child = child.getTreeNext();
if (child instanceof PsiWhiteSpace){
child = child.getTreeNext();
}
}
return sequenceElementType.indexOf((ElementType) astNode.getElementType(), index);
}
return 0;