@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 boolean matches(CompoundAssignmentTree tree, VisitorState state) { return exprMatcher.matches(tree.getVariable(), state); } };
@Override public Description matchCompoundAssignment(CompoundAssignmentTree tree, VisitorState state) { return matchDivZero(tree, tree.getExpression(), state); }
@Override public Void visitCompoundAssignment(CompoundAssignmentTree tree, Void unused) { check(tree.getVariable()); return super.visitCompoundAssignment(tree, unused); }
if (hasSideEffect(((CompoundAssignmentTree) 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(); }
@Override public UAssignOp visitCompoundAssignment(CompoundAssignmentTree tree, Void v) { return UAssignOp.create( template(tree.getVariable()), tree.getKind(), template(tree.getExpression())); }
@Override public Void visitCompoundAssignment(CompoundAssignmentTree node, InitializationContext init) { init = InitializationContext.NONE; writes.recordAssignment(node.getVariable(), init); return super.visitCompoundAssignment(node, init); }
@Override public Description matchCompoundAssignment(CompoundAssignmentTree tree, VisitorState state) { return matchDivZero(tree, tree.getExpression(), state); }
@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)); }
CharSequence var = state.getSourceForNode(tree.getVariable()); CharSequence expr = state.getSourceForNode(tree.getExpression()); if (var == null || expr == null) { return Optional.absent(); switch (tree.getKind()) { case RIGHT_SHIFT_ASSIGNMENT: break; Kind regularAssignmentKind = regularAssignmentFromCompound(tree.getKind()); String op = assignmentToString(regularAssignmentKind); if (tree.getExpression() instanceof JCBinary) { Kind rhsKind = tree.getExpression().getKind(); if (!OperatorPrecedence.from(rhsKind) .isHigher(OperatorPrecedence.from(regularAssignmentKind))) { 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));
@Override public Void visitCompoundAssignment(CompoundAssignmentTree node, Void unused) { recordWrite(node.getVariable()); return super.visitCompoundAssignment(node, null); }
if (hasSideEffect(((CompoundAssignmentTree) tree).getExpression())) { SuggestedFix replacement = SuggestedFix.replace(
@Override public List<Tree> visitCompoundAssignment(CompoundAssignmentTree node, ExpressionScanner.ExpressionsInfo p) { return scan(node.getVariable(), node.getExpression(), p); }
@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 visitCompoundAssignment(CompoundAssignmentTree node, Void v) { checkLValue(node.getVariable()); return super.visitCompoundAssignment(node, v); }
public List<Tree> visitCompoundAssignment(CompoundAssignmentTree node, ExpressionScanner.ExpressionsInfo p) { return scan(node.getVariable(), node.getExpression(), p); }
@Nullable @Override 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 LEFT_SHIFT_ASSIGNMENT: case RIGHT_SHIFT_ASSIGNMENT: case UNSIGNED_RIGHT_SHIFT_ASSIGNMENT: if (tree.getExpression().equals(current)) { return unaryNumericPromotion(expressionType, state);
@Override public boolean matches(CompoundAssignmentTree tree, VisitorState state) { return exprMatcher.matches(tree.getVariable(), state); } };