Eclipse可以将if-else转换为枚举吗 [英] Can Eclipse convert if-else to switch for enums

查看:97
本文介绍了Eclipse可以将if-else转换为枚举吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果枚举上的状态,ReShaper可以自动识别,并提出将其转换为 switch 语句(或返回)。 (当然,只有在 if 语句仅测试枚举而不进行其他操作时,才会发生这种情况。)

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

Eclipse可以执行类似的操作以及如何执行该操作吗?

Can Eclipse do something like that and how?

推荐答案

Eclipse可以将switch语句转换为if-else,但不能将其转换为if-else。已经存在一个漏洞,可以提供将'if-else'转换为'switch'快速帮助的错误,请参见 https://bugs.eclipse.org/bugs/show_bug.cgi?id=348179

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

更新:该错误已已修复,从4.3 Milestone 1开始,Eclipse将支持将if-else语句转换为switch语句。

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

这篇关于Eclipse可以将if-else转换为枚举吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆