@Override public boolean matches(CompoundAssignmentTree tree, VisitorState state) { return exprMatcher.matches(tree.getVariable(), state); } };
@Override public Void visitCompoundAssignment(CompoundAssignmentTree tree, Void unused) { check(tree.getVariable()); return super.visitCompoundAssignment(tree, unused); }
@Override public Void visitCompoundAssignment(CompoundAssignmentTree node, InitializationContext init) { init = InitializationContext.NONE; writes.recordAssignment(node.getVariable(), init); return super.visitCompoundAssignment(node, init); }
@Override public Void visitCompoundAssignment(CompoundAssignmentTree node, Void unused) { recordWrite(node.getVariable()); return super.visitCompoundAssignment(node, null); }
@Override public Boolean visitCompoundAssignment(CompoundAssignmentTree node, Void v) { checkLValue(node.getVariable()); return super.visitCompoundAssignment(node, v); }
@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 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())); }
@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(); }
CharSequence var = state.getSourceForNode(tree.getVariable()); CharSequence expr = state.getSourceForNode(tree.getExpression()); if (var == null || expr == null) { String castType = getType(tree.getVariable()).toString(); String replacement = String.format("%s = (%s) (%s %s %s)", var, castType, var, op, expr); return Optional.of(SuggestedFix.replace(tree, replacement));
@Nullable @Override public Type visitCompoundAssignment(CompoundAssignmentTree tree, Void unused) { Type variableType = getType(tree.getVariable()); Type expressionType = getType(tree.getExpression()); Types types = state.getTypes();
@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())); } }
@Override public boolean matches(CompoundAssignmentTree tree, VisitorState state) { return exprMatcher.matches(tree.getVariable(), state); } };
@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; }
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 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)); }