A type selector provides a form of refinement for a give type. More specifically, it determines which type tags are active for a given type. @author David J. Pearce
| 6731 | * |
| 6732 | */ |
| 6733 | public static class Selector { |
| 6734 | /** |
| 6735 | * Indicates that the given element is not selected. |
| 6736 | */ |
| 6737 | public static final Selector BOTTOM = new Selector() { |
| 6738 | @Override |
| 6739 | public String toString(Type t) { |
| 6740 | return "..."; |
| 6741 | } |
| 6742 | @Override |
| 6743 | public String toString() { |
| 6744 | return "_"; |
| 6745 | } |
| 6746 | @Override |
| 6747 | public Type apply(Type source) { |
| 6748 | return Type.Void; |
| 6749 | } |
| 6750 | }; |
| 6751 | /** |
| 6752 | * Indicates that the given element is selected entirely. |
| 6753 | */ |
| 6754 | public static final Selector TOP = new Selector() { |
| 6755 | @Override |
| 6756 | public String toString(Type t) { |
| 6757 | return t.toString(); |
| 6758 | } |
| 6759 | @Override |
| 6760 | public Type apply(Type source) { |
| 6761 | return source; |
| 6762 | } |
| 6763 | @Override |
| 6764 | public String toString() { |
| 6765 | return "*"; |
| 6766 | } |
| 6767 | }; |
| 6768 | |
| 6769 | private final Selector[] children; |
| 6770 | |
| 6771 | public Selector(Selector... nodes) { |
| 6772 | this.children = nodes; |
| 6773 | } |
| 6774 | |
| 6775 | public int size() { |
| 6776 | return children.length; |
| 6777 | } |
| 6778 | |
| 6779 | public Selector get(int ith) { |
| 6780 | return children[ith]; |
| 6781 | } |
| 6782 | |
| 6783 | @Override |
| 6784 | public String toString() { |
| 6785 | String r = ""; |
| 6786 | for(int i=0;i!=children.length;++i) { |
| 6787 | if(i != 0) { r += ","; } |
| 6788 | r += children[i].toString(); |
| 6789 | } |
| 6790 | return "(" + r + ")"; |
nothing calls this directly
no outgoing calls
no test coverage detected