I have recently struggled to clean up a package that I maintain using Expression operators instead of using Code blocks full of strings, i.e. Code('$a ^ $b') and have discovered that quite a few operators are missing from the Expression class. So I've added all the missing operators and assignments found on https://dart.dev/language/operators.
added operators
method
generates
Expression.operatorIntDivide
this ~/ other
Expression.operatorUnaryPrefixIncrement
++this
Expression.operatorUnaryPostfixIncrement
this++
Expression.operatorUnaryMinus
-this
Expression.operatorUnaryPrefixDecrement
--this
Expression.operatorUnaryPostfixDecrement
this--
Expression.operatorBitwiseAnd
this & other
Expression.operatorBitwiseOr
this \| other
Expression.operatorBitwiseXor
this ^ other
Expression.operatorUnaryBitwiseComplement
~this
Expression.operatorShiftLeft
this << other
Expression.operatorShiftRight
this >> other
Expression.operatorShiftRightUnsigned
this >>> other
added assignments
method
generates
Expression.addAssign
this += other
Expression.subtractAssign
this -= other
Expression.multiplyAssign
this *= other
Expression.divideAssign
this /= other
Expression.intDivideAssign
this ~/= other
Expression.euclideanModuloAssign
this %= other
Expression.shiftLeftAssign
this <<= other
Expression.shiftRightAssign
this >>= other
Expression.shiftRightUnsignedAssign
this >>>= other
Expression.bitwiseAndAssign
this &= other
Expression.bitwiseXorAssign
this ^= other
Expression.bitwiseOrAssign
this \|= other
deprecated the misnamed Expression.operatorSubstract method and created a correctly named Expression.operatorSubtract method.
[x] I’ve reviewed the contributor guide and applied the relevant portions to this PR.
I have recently struggled to clean up a package that I maintain using
Expression
operators instead of usingCode
blocks full of strings, i.e.Code('$a ^ $b')
and have discovered that quite a few operators are missing from theExpression
class. So I've added all the missing operators and assignments found on https://dart.dev/language/operators.added operators
Expression.operatorIntDivide
this ~/ other
Expression.operatorUnaryPrefixIncrement
++this
Expression.operatorUnaryPostfixIncrement
this++
Expression.operatorUnaryMinus
-this
Expression.operatorUnaryPrefixDecrement
--this
Expression.operatorUnaryPostfixDecrement
this--
Expression.operatorBitwiseAnd
this & other
Expression.operatorBitwiseOr
this \| other
Expression.operatorBitwiseXor
this ^ other
Expression.operatorUnaryBitwiseComplement
~this
Expression.operatorShiftLeft
this << other
Expression.operatorShiftRight
this >> other
Expression.operatorShiftRightUnsigned
this >>> other
added assignments
Expression.addAssign
this += other
Expression.subtractAssign
this -= other
Expression.multiplyAssign
this *= other
Expression.divideAssign
this /= other
Expression.intDivideAssign
this ~/= other
Expression.euclideanModuloAssign
this %= other
Expression.shiftLeftAssign
this <<= other
Expression.shiftRightAssign
this >>= other
Expression.shiftRightUnsignedAssign
this >>>= other
Expression.bitwiseAndAssign
this &= other
Expression.bitwiseXorAssign
this ^= other
Expression.bitwiseOrAssign
this \|= other
deprecated the misnamed
Expression.operatorSubstract
method and created a correctly namedExpression.operatorSubtract
method.[x] I’ve reviewed the contributor guide and applied the relevant portions to this PR.