swiftlang / sourcekit-lsp

Language Server Protocol implementation for Swift and C-based languages
Apache License 2.0
3.21k stars 264 forks source link

Apply DeMorgan's Law #1552

Open AppAppWorks opened 1 week ago

AppAppWorks commented 1 week ago

fixed #1243

AppAppWorks commented 1 week ago

Thanks for tackling this @AppAppWorks. I have left a first set of review comments inline. Correctness-wise, I think it’s mostly missing the addition of parentheses where precedence of operators flips, eg. !(a && b || c) should get transformed to (!a || !b) && !c.

This example involves recursive DeMorgan's Law applications that have not been implemented in this PR? i.e. !(a && b || c) -> !(a && b) && !c -> (!a || !b) && !c