tryRewriteBinaryAsUnary(node, node.getLeft(), node.getRight());
return true;
}
}
else if (binaryOp.isCommutative() && innerRight.matches(left)) {
final ResolveResult leftResult = _resolver.apply(left);
final ResolveResult innerLeftResult = _resolver.apply(innerLeft);
//
// The transform from `t = n + t` to `t += n` is legal for numeric types, but the
// commutative property does not hold for string concatenation (i.e., the result
// depends on the order of the operands). If the assignment target does not match
// the left operand, and either operand is a string, then do not apply a compound
// assignment transform.
//
if (leftResult == null || leftResult.getType() == null ||
innerLeftResult == null || innerLeftResult.getType() == null) {
return false;
}
if (CommonTypeReferences.String.isEquivalentTo(leftResult.getType()) ||
CommonTypeReferences.String.isEquivalentTo(innerLeftResult.getType())) {
return false;
}
final AssignmentOperatorType assignOp = AssignmentExpression.getCorrespondingAssignmentOperator(binaryOp);