Automated Composition of Refactorings

Implementing and evaluating a search-based Extract and Move Method refactoring

This web page contains some resources related to this master's thesis. One of the resources is the git repository containing everything related to the thesis, including the software written. On this page, you can also find downloads of some plugins developed as part of the master's project, installation instructions and how to use them.

The source code and case studies data

The Java source code written as part of this master's project can be found in the git repository git://, in the software directory. The software can be browsed here.

The data from the case studies can be found in the case-study directory.

The Eclipse plugins

Below, two plugins are found which can be used to explorer the software developed for this master's project. The no.uio.ifi.refaktor plugin is the main product, while the examples plugin is just used to import some example code into the workspace. The main plugin must be seen as a "proof of concept", and may not behave as one would expect of a finished product.

The no.uio.ifi.refaktor plugin

There are two versions of this plugin available. Version 1.0.1 is the latest version, with some corrections to the semantics of the search-based Extract and Move Method refactoring, compared to version 1.0.0. The version 1.0.1 is the one that reflects the semantics of chapter 2 and the example presented there. Version 1.0.0 is the one used in the case studies presented in the thesis.


The no.uio.ifi.refaktor.examples plugin

This plugin makes it possible to create a project in the workspace called "examples" that contains some example code used when developing the main plugin. Most of this example code is created for serving the unit tests for the main plugin. The example project also contains code for the main example of chapter 2 of the thesis. This code can be found in the package "grandExample".

The part of the examples plugin that creates the "examples" project in the workspace is developed by Volker Stolz and his associates.


Installation instructions

To install the plugins above, download them (only one of the no.uio.ifi.refaktor plugins) and put them in the "dropins" folder of your Eclipse installation.

The plugins has been successfully installed in Eclipse Standard 4.3.1 (64-bit version for Linux). Installation in Eclipse Standard 4.3.2, which is currently the latest version, does not work properly.


How to add the example code

With the no.uio.ifi.refaktor.examples plugin installed, open the dialog "New -> Others", either with CTRL+N or by right-clicking with your mouse in the explorer.

Choose the "Extract Refaktor-example into workspace" option, from the "Other" category, and click "Finish". The example code should now exist in the workspace as the project "examples".

How to use the search-based Extract and Move Method refactoring

There has not been put great effort into making the no.uio.ifi.refaktor plugin user friendly. Therefore, a lot of the output resembles debug output. Also, when performing long-running operations, the user interface may become unresponsive.

Most of the functionality of the plugin is accessed either through the package explorer or the project explorer. In one of the explorers, right-click with the mouse on any of the tree items. The menu that pops up should contain a sub-menu called "IFI Refaktor Tree Selection". Depending on what type of item selected, this sub-menu may contain a command that can be used to execute the search-based Extract and Move Method refactoring on the item.

As an example, when right-clicking on a package in the package explorer, a command called "Package Wide Search Based Extract And Move Method Changer" is available, which, if chosen, would run the refactoring for all the methods of the selected package.

Refactoring per selection

It is also possible to run the refactoring for a custom text selection. To do this, select some text/statements in the editor and right-click to run the command "Extract and Move Method" in the "IFI Refaktor Selection" sub-menu.


If a candidate is found for the refactoring, a dialog will open to let you change the name of the extracted method. If none are found, nothing will happen, unfortunately.


And the result:

If the name of the extracted method is not changed, it will have a generated name on the format "generated_<long-integer>", where <long-integer> is a pseudorandom 64-bit integer. This naming convention is also valid for the per-method search-based refactoring.

Statistics report

By default, a statistics report will be written to the "/tmp" directory, if present (Unix-like operating systems). To explicitly set the output directory for this report, set the "refaktor.reports" system property.


If something gets logged during the execution of a plugin, the log file can be found in the "no.uio.ifi.refaktor.logs" directory, which is created within the directory referenced by the "user.home" system property.

Other resources

Tags: refactoring, PMA, static analysis By Erlend Kristiansen, Volker Stolz
Published Apr. 29, 2014 4:24 PM - Last modified Apr. 13, 2018 10:32 AM