IntelliJ IDEA 14.1.0 Help

Replace Method Code Duplicates

The Replace Method Code Duplicates allows you to find code repetitions similar to the selected method and replace them with calls to the method.


Before After
public void method() { ; ; (int a, int b) {
public void method() { (a,b); (b,c); (int a, int b) {

To replace method code duplicates

  1. Position the cursor within the method, duplicates of which you want to search for.
  2. Do one of the following to open the Replace Method Code Duplicates dialog box:
    • On the Refactor menu, choose Replace Method Code Duplicates.
    • On the context menu, choose Refactor | Replace Method Code Duplicates.
  3. Press the Replace button to continue. For each code fragment found, IntelliJ IDEA will prompt you to confirm replacement.

See Also

Last modified: 24 March 2015
comments powered by Disqus