简体   繁体   中英

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! How to enforce Intellij to replace all these inner class?

In the Analyze menu, select "Run Inspection by Name...". In the search box, type "Anonymous" and select the one that says "Anonymous class may be replaced by lambda" or something to that effect. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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