TC-Infer: Inferring Type Changes
IntelliTC: Applying Type Changes
IntelliTC is a plugin for IntelliJ IDEA that adapts the current approach of Type Migration refactoring for Java to use custom structural-replace templates created by TC-Infer that express the adaptations required to perform the type change
Download Download IntelliTC sources Download TC-Infer sources
Installation
- Download the archive with the plugin and update your IntelliJ IDEA to 2021.1+ version
- Go to the Settings menu tab and choose the following item:
- Choose the path to the downloaded plugin's ZIP archive. On Linux / MacOS, it should be something like that:
![](assets/img/install.png)
/path/to/plugin-org.company.ddtm.zip
Overview
There are several modalities provided by the plugin.
Classic mode
In this mode, the plugin operates as a usual code intention that can be invoked from the Show Context Actions item in the popup menu when you click on the type element in your Java code. Then, you can choose any of the suggested Type Migration Rules from the dropdown list, and the plugin will try to update all data-flow dependent references of the selected element:
![](assets/img/light-proactive.gif)
If the plugin does not succeed in migrating some references, it will show the Failed Type Changes tool window. Moreover, for some of them it can suggest another type conversion rules using another type of code intention — Recovering Type Change Intention. But this one could also change the type of the overall expression or statement in your code, so be careful when applying them.
![](assets/img/recovering.jpg)
Suggested Refactoring mode
In such mode, an intention (and corresponding refactoring) is suggested when the user changes some type element in Java code manually. After the single type change is performed, you can put the caret on the element that was just changed, and open the Show Context Actions menu item. If such a type change is supported by the plugin, it will offer you the appropriate type migration rules. You can also click on the icon that appears on the gutter, and run the type migration from there:
![](assets/img/light-reactive.gif)
Inspection mode
Suggests the user to perform a type changes based on the recommendations from Effective Java and other popular developer forums.
![](assets/img/light-inspection.gif)
Other features
Don't forget to choose an appropriate search scope for type changes each time!
For now, the plugin
supports
3 different scopes: Local Scope, Current File, and All Project.
Also, you can always edit any of type change patterns or rewrite rules manually in the
Settings menu
tab:
![](assets/img/new-settings.png)