-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code action to apply DeMorgan's law #1243
Comments
Synced to Apple’s issue tracker as rdar://128016621 |
Could this code action extend to cover bitwise operators as well? |
Yes, that would make sense. |
@ahoppen as you mentioned in #1539, being overly restrictive is more of a problem than being too permissive. However for DeMorgan's law, the situation is a bit different. We may identify multiple candidate expressions as we walk up the syntax tree, e.g. I can think of two possible ways to deal with the ambiguity,
|
It’s probably one of these situations where we need some reference implementation and then use it to decide what feels best. But I think starting with the outermost expression makes sense as a start. |
Shall we support generalised DeMorgan's in addition to dual DeMorgan's? |
I would start with one direction. The dual would be a nice follow-up after that. |
Description
Sometimes in code we end up with something like:
and it would be cleaner to apply DeMorgan's law to make this:
We should have a code action to do this correctly, which requires dealing with inverting conditions and dealing with operator precedence. The
SwiftOperators
module of swift-syntax can help here.The text was updated successfully, but these errors were encountered: