@Nullable @Override public Type visitSwitch(SwitchTree node, Void unused) { if (current == node.getExpression()) { return state.getTypes().unboxedTypeOrType(getType(current)); } else { return null; } }
@Override public Description matchSwitch(SwitchTree tree, VisitorState state) { Type switchType = ASTHelpers.getType(tree.getExpression()); if (switchType.asElement().getKind() != ElementKind.ENUM) { return Description.NO_MATCH; } // default case is present if (tree.getCases().stream().anyMatch(c -> c.getExpression() == null)) { return Description.NO_MATCH; } ImmutableSet<String> handled = tree.getCases().stream() .map(CaseTree::getExpression) .filter(IdentifierTree.class::isInstance) .map(e -> ((IdentifierTree) e).getName().toString()) .collect(toImmutableSet()); Set<String> unhandled = Sets.difference(ASTHelpers.enumValues(switchType.asElement()), handled); if (unhandled.isEmpty()) { return Description.NO_MATCH; } return buildDescription(tree).setMessage(buildMessage(unhandled)).build(); }
@Override public Description matchSwitch(SwitchTree tree, VisitorState state) { Type switchType = ASTHelpers.getType(tree.getExpression()); if (switchType.asElement().getKind() == ElementKind.ENUM) {
@Override public Choice<State<JCSwitch>> visitSwitch(final SwitchTree node, State<?> state) { return chooseSubtrees( state, s -> unifyExpression(node.getExpression(), s), s -> unify(node.getCases(), s), (expr, cases) -> maker().Switch(expr, List.convert(JCCase.class, cases))); }
@Override public Void visitSwitch(SwitchTree expected, Tree actual) { Optional<SwitchTree> other = checkTypeAndCast(expected, actual); if (!other.isPresent()) { addTypeMismatch(expected, actual); return null; } scan(expected.getExpression(), other.get().getExpression()); parallelScan(expected.getCases(), other.get().getCases()); return null; }
@Override public Void visitSwitch(SwitchTree expected, Tree actual) { Optional<SwitchTree> other = checkTypeAndCast(expected, actual); if (!other.isPresent()) { addTypeMismatch(expected, actual); return null; } scan(expected.getExpression(), other.get().getExpression()); parallelScan(expected.getCases(), other.get().getCases()); return null; }
@Override public Void visitSwitch(SwitchTree expected, Tree actual) { Optional<SwitchTree> other = checkTypeAndCast(expected, actual); if (!other.isPresent()) { addTypeMismatch(expected, actual); return null; } scan(expected.getExpression(), other.get().getExpression()); parallelScan(expected.getCases(), other.get().getCases()); return null; }
@Override public Void visitSwitch(SwitchTree node, EnumSet<UseTypes> p) { scan(node.getExpression(), EnumSet.of(UseTypes.READ)); for (CaseTree ct : node.getCases()) { scan(ct, null); } return null; }
public R visitSwitch(SwitchTree node, P p) { R r = scan(node.getExpression(), p); r = scanAndReduce(node.getCases(), p, r); return r; }
private SwitchTree modifySwitchCase(SwitchTree swic, int index, CaseTree kejs, Operation op) { SwitchTree copy = Switch( swic.getExpression(), c(swic.getCases(), index, kejs, op) ); return copy; }
@Override public Type visitSwitch(SwitchTree node, Void unused) { if (current == node.getExpression()) { return state.getTypes().unboxedTypeOrType(getType(current)); } else { return null; } }
public R visitSwitch(SwitchTree node, P p) { R r = scan(node.getExpression(), p); r = scanAndReduce(node.getCases(), p, r); return r; }
public R visitSwitch(SwitchTree node, P p) { R r = scan(node.getExpression(), p); r = scanAndReduce(node.getCases(), p, r); return r; }
public Boolean visitSwitch(SwitchTree node, TreePath p) { if (p == null) { super.visitSwitch(node, p); return false; } SwitchTree st = (SwitchTree) p.getLeaf(); if (!scan(node.getExpression(), st.getExpression(), p)) { return false; } return checkLists(node.getCases(), st.getCases(), p); }
public R visitSwitch(SwitchTree node, P p) { R r = scan(node.getExpression(), p); r = scanAndReduce(node.getCases(), p, r); return r; }
protected final SwitchTree rewriteChildren(SwitchTree tree) { ExpressionTree selector = (ExpressionTree)translate(tree.getExpression()); List<? extends CaseTree> cases = translateStable(tree.getCases()); if (selector!=tree.getExpression() || !cases.equals(tree.getCases())) { SwitchTree n = make.Switch(selector, cases); model.setType(n, model.getType(tree)); copyCommentTo(tree,n); copyPosTo(tree,n); tree = n; } return tree; }
public List<Tree> visitSwitch(SwitchTree node, ExpressionScanner.ExpressionsInfo p) { List<Tree> result = null; if (acceptsTree(node)) { result = scan(node.getExpression(), p); } return reduce(result, scan(node.getCases(), p)); }
@Override public List<Tree> visitSwitch(SwitchTree node, ExpressionScanner.ExpressionsInfo p) { List<Tree> result = null; if (acceptsTree(node)) { result = scan(node.getExpression(), p); } return reduce(result, scan(node.getCases(), p)); }
@Override public Tree visitSwitch(SwitchTree tree, Void p) { SwitchTree n = make.Switch(tree.getExpression(), tree.getCases()); model.setType(n, model.getType(tree)); comments.copyComments(tree, n); model.setPos(n, model.getPos(tree)); return n; }
@Override public Choice<State<JCSwitch>> visitSwitch(final SwitchTree node, State<?> state) { return chooseSubtrees( state, s -> unifyExpression(node.getExpression(), s), s -> unify(node.getCases(), s), (expr, cases) -> maker().Switch(expr, List.convert(JCCase.class, cases))); }