有什么方法可以从Intellij中的项目中获取所有枚举类及其各自的价值观?
我需要创建一个在Intellij中的项目中声明为枚举的类的列表,在每个项目中,每个类别都列出了相应的值。是否有任何自动化方法可以完成此任务,因为它是一个相当大的项目,发生了数百个事件。
I need to create a list of classes declared as enum in a project in IntelliJ and, inside each one, list the respective values. Is there any automated way to accomplish this task, as it is a rather large project, with hundreds of occurrences.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以使用类型的层次结构视图来执行此操作,并将条目导出到文件。我正在使用Eclipse快捷方式,可以使用
f4
打开类型层次结构。只需确保过滤生产
文件即可。示例使用guava项目:
对于获取每个枚举的所有值,我认为Intellij中没有这样的功能,但是您可能可以编写一个脚本来处理导出的文件。
编辑
此方法将使用Intellij导出的文件打印枚举值。您可能需要修改它以处理错误,等等。
Yes, you can do this using the type hierarchy view and export the entries to a file. I'm using eclipse shortcuts and I can open the type hierarchy using
F4
. Just make sure to filterProduction
files.Example using the Guava project:
As for getting all the values for each enum, I don't think there's such a feature in IntelliJ, but you could probably write a script to process the exported file.
Edit
This method will print enum values using the file exported from IntelliJ. You might need to modify it to handle errors, etc.