ASTNode (int role) { LOG.assertTrue(ChildRole.isUnique(role)); switch(role){ default: return null; case ChildRole.CONDITION: return getFirstChildNode(); case ChildRole.QUEST: return findChildByType(JavaTokenType.QUEST); case ChildRole.THEN_EXPRESSION: ASTNode quest = findChildByRole(ChildRole.QUEST); ASTNode child = quest.getTreeNext(); while(true){ if (child == null) return null; if (ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())) break; child = child.getTreeNext(); } return child; case ChildRole.COLON: return findChildByType(JavaTokenType.COLON); case ChildRole.ELSE_EXPRESSION: ASTNode colon = findChildByRole(ChildRole.COLON); if (colon == null) return null; return ElementType.EXPRESSION_BIT_SET.contains(getLastChildNode().getElementType()) ? getLastChildNode() : null; } }