Can Eclipse convert if-else to switch for enums

前端 未结 2 1758
说谎
说谎 2021-01-14 05:32

ReShaper can automatically recognize if states on enums and offer to convert them to switch statements (or back). (Of course, this can only happen

相关标签:
2条回答
  • 2021-01-14 06:25

    For sake of completeness, the option Convert 'if-else' to 'switch' is shown by having the cursor e.g. on the if and then pressing the quick-assist command (Ctrl + 1).

    0 讨论(0)
  • 2021-01-14 06:31

    Eclipse can convert switch statements to if-else but not the other way around. There is already a bug open to provide a "Convert 'if-else' to 'switch'" quick assist, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=348179

    Update: The bug has been fixed, Starting 4.3 Milestone 1 Eclipse will support converting if-else statements to switch statements.

    0 讨论(0)
提交回复
热议问题