@Override public Description matchCompoundAssignment(CompoundAssignmentTree tree, VisitorState state) { return matchDivZero(tree, tree.getExpression(), state); }
@Override public boolean matches(CompoundAssignmentTree compoundAssignmentTree, VisitorState state) { if (!operators.contains(compoundAssignmentTree.getKind())) { return false; } return receiverMatcher.matches(compoundAssignmentTree.getVariable(), state) && expressionMatcher.matches(compoundAssignmentTree.getExpression(), state); }
@Override public UAssignOp visitCompoundAssignment(CompoundAssignmentTree tree, Void v) { return UAssignOp.create( template(tree.getVariable()), tree.getKind(), template(tree.getExpression())); }
CompoundAssignmentTree tree, VisitorState state) { CharSequence var = state.getSourceForNode(tree.getVariable()); CharSequence expr = state.getSourceForNode(tree.getExpression()); if (var == null || expr == null) { return Optional.absent(); if (tree.getExpression() instanceof JCBinary) { Kind rhsKind = tree.getExpression().getKind(); if (!OperatorPrecedence.from(rhsKind) .isHigher(OperatorPrecedence.from(regularAssignmentKind))) {
@Override public Description matchCompoundAssignment(CompoundAssignmentTree tree, VisitorState state) { String message = identifyBadCast( getType(tree.getVariable()), getType(tree.getExpression()), state.getTypes()); if (message == null) { return Description.NO_MATCH; } Optional<Fix> fix = rewriteCompoundAssignment(tree, state); if (!fix.isPresent()) { return Description.NO_MATCH; } return buildDescription(tree).addFix(fix.get()).setMessage(message).build(); }
public Type visitCompoundAssignment(CompoundAssignmentTree tree, Void unused) { Type variableType = getType(tree.getVariable()); Type expressionType = getType(tree.getExpression()); Types types = state.getTypes(); switch (tree.getKind()) { case UNSIGNED_RIGHT_SHIFT_ASSIGNMENT: if (tree.getExpression().equals(current)) { return unaryNumericPromotion(expressionType, state);
@Override public Description matchCompoundAssignment(CompoundAssignmentTree tree, VisitorState state) { if (!matchWithinClass) { return Description.NO_MATCH; } Type lhsType = ASTHelpers.getType(tree.getVariable()); Type stringType = state.getTypeFromString("java.lang.String"); if (lhsType != null && !lhsType.equals(stringType)) { // both LHS and RHS could get unboxed return doUnboxingCheck(state, tree.getVariable(), tree.getExpression()); } return Description.NO_MATCH; }
@Override public Choice<State<JCAssignOp>> visitCompoundAssignment( final CompoundAssignmentTree node, State<?> state) { return chooseSubtrees( state, s -> unifyExpression(node.getVariable(), s), s -> unifyExpression(node.getExpression(), s), (var, expr) -> maker().Assignop(((JCAssignOp) node).getTag(), var, expr)) .condition(assignOp -> !(assignOp.result().getVariable() instanceof PlaceholderParamIdent)); }
@Override public Choice<Unifier> visitCompoundAssignment(CompoundAssignmentTree assignOp, Unifier unifier) { return Choice.condition(getKind() == assignOp.getKind(), unifier) .thenChoose(unifications(getVariable(), assignOp.getVariable())) .thenChoose(unifications(getExpression(), assignOp.getExpression())); } }
if (hasSideEffect(((CompoundAssignmentTree) tree).getExpression())) {
@Override public Void visitCompoundAssignment(CompoundAssignmentTree expected, Tree actual) { Optional<CompoundAssignmentTree> other = checkTypeAndCast(expected, actual); if (!other.isPresent()) { addTypeMismatch(expected, actual); return null; } scan(expected.getVariable(), other.get().getVariable()); scan(expected.getExpression(), other.get().getExpression()); return null; }
@Override public Void visitCompoundAssignment(CompoundAssignmentTree expected, Tree actual) { Optional<CompoundAssignmentTree> other = checkTypeAndCast(expected, actual); if (!other.isPresent()) { addTypeMismatch(expected, actual); return null; } scan(expected.getVariable(), other.get().getVariable()); scan(expected.getExpression(), other.get().getExpression()); return null; }
public R visitCompoundAssignment(CompoundAssignmentTree node, P p) { R r = scan(node.getVariable(), p); r = scanAndReduce(node.getExpression(), p, r); return r; }
public Boolean visitCompoundAssignment(CompoundAssignmentTree node, TreePath p) { if (p == null) { super.visitCompoundAssignment(node, p); return false; } CompoundAssignmentTree bt = (CompoundAssignmentTree) p.getLeaf(); boolean result = scan(node.getExpression(), bt.getExpression(), p); return result && scan(node.getVariable(), bt.getVariable(), p); }
@Override public boolean matches(CompoundAssignmentTree compoundAssignmentTree, VisitorState state) { if (!operators.contains(compoundAssignmentTree.getKind())) { return false; } return receiverMatcher.matches(compoundAssignmentTree.getVariable(), state) && expressionMatcher.matches(compoundAssignmentTree.getExpression(), state); }
protected final CompoundAssignmentTree rewriteChildren(CompoundAssignmentTree tree) { ExpressionTree lhs = (ExpressionTree)translate(tree.getVariable()); ExpressionTree rhs = (ExpressionTree)translate(tree.getExpression()); if (lhs!=tree.getVariable() || rhs!=tree.getExpression()) { CompoundAssignmentTree n = make.CompoundAssignment(tree.getKind(), lhs, rhs); model.setType(n, model.getType(tree)); copyCommentTo(tree,n); copyPosTo(tree,n); tree = n; } return tree; }
@Override public UAssignOp visitCompoundAssignment(CompoundAssignmentTree tree, Void v) { return UAssignOp.create( template(tree.getVariable()), tree.getKind(), template(tree.getExpression())); }
@Override public Tree visitCompoundAssignment(CompoundAssignmentTree tree, Void p) { CompoundAssignmentTree n = make.CompoundAssignment(tree.getKind(), tree.getVariable(), tree.getExpression()); model.setType(n, model.getType(tree)); comments.copyComments(tree, n); model.setPos(n, model.getPos(tree)); return n; }
@Override public JExpression visitCompoundAssignment(CompoundAssignmentTree ct, Void __) { return $b.invoke(opName(ct.getKind())) .arg(loc(ct)) .arg(visit(ct.getVariable())) .arg(visit(ct.getExpression())); }
@Override public Choice<State<JCAssignOp>> visitCompoundAssignment( final CompoundAssignmentTree node, State<?> state) { return chooseSubtrees( state, s -> unifyExpression(node.getVariable(), s), s -> unifyExpression(node.getExpression(), s), (var, expr) -> maker().Assignop(((JCAssignOp) node).getTag(), var, expr)) .condition(assignOp -> !(assignOp.result().getVariable() instanceof PlaceholderParamIdent)); }