简体   繁体   English

在Intellij Idea中自动将所有匿名内部类替换为lambda

[英]Automatic replacing all anonymous inner class to lambda in Intellij Idea

I working on a project which is implemented in java 7 and now I want to migrate to java 8. I use Intellij Idea and find all "new inner class occurrence" whit regex finding("new . (. )\\s*{[.|\\s]*"), But those are very numerous! 我正在研究一个在java 7中实现的项目,现在我想迁移到java 8.我使用Intellij Idea并找到所有“新内部类发生”的whit regex查找(“new。 (。 )\\ s * {[。 | \\ s] *“),但那些数量非常多! How to enforce Intellij to replace all these inner class? 如何强制Intellij替换所有这些内部类?

In the Analyze menu, select "Run Inspection by Name...". 在“ Analyze菜单中,选择“按名称运行检验...”。 In the search box, type "Anonymous" and select the one that says "Anonymous class may be replaced by lambda" or something to that effect. 在搜索框中,键入“匿名”并选择“匿名类可能被lambda替换”或类似的内容。 Select your scope and start the analysis. 选择范围并开始分析。

In the results, you can inspect them individually and click the "Replace with lambda" link on the right to make the change, or, if you are brave, you can right click on the node at the top of the results and select the "apply fix" to update all of them. 在结果中,您可以单独检查它们并单击右侧的“替换为lambda”链接进行更改,或者,如果您是勇敢的,可以右键单击结果顶部的节点并选择“应用修复“以更新所有这些。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM