-
Notifications
You must be signed in to change notification settings - Fork 295
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
Suggest to reverse condition when 'Then' block is empty #874
Comments
This might be interesting with more complex if-conditions...
|
I handled this for C# code in VSDiagnostics. I should be able to handle it for VBE code too. |
@Hosch250 does VSD revert the operators, or simply sticks a |
It actually reverts the operators:
|
Ok, so
What of |
This will definitely be a mite trickier than VSD because Roslyn has that nifty tree defining precedence and stuff, but not impossible. It will be a little like parsing a mathematical expression, which I have done before. Also, I think XOr stays the same, but I can't say for sure. |
"A XOr B" is basically "(A and not B) or (not A and B)", inverting those is a little trickier... |
A And Not B inverted makes Not A Or B |
Need to consider reversing these too:
|
Might need to apply the same functionality to Compile Directives. |
Other than the code to figure out which operator needs to be inverted (only the top-level one does), this is easily doable with the rewriters at this point. Basically, this would be a parse tree inspection that checked for empty A similar inspection would be an |
This code:
Should be rewritten as:
Or better:
But reversing operators might not be trivial in all condition expressions.
Also applies to if blocks:
Should be rewritten as:
The text was updated successfully, but these errors were encountered: