The SplitBrains plugin for IntelliJ provides advanced refactoring and analysis tools for projects.
Splitbrains is a refactoring tool for IntelliJ. It allows the developer to declare splitpoints in a project, and then take actions on code that defines, contains, uses, references, or depends on those splitpoints.
Splitbrains also provides tools to assist in the in decoupling of dependencies, such as:
The follow actions are added to IntelliJ menus, and can be assigned to keyboard shortcuts.
Use this if you are OK with duplicate code in different packages. If there are non-refactored libraries that reference the code, this will prevent them from reporting a Class Not Found Exception.
Move the source to a new package in the same or different module.
{
"type" : "repackage",
"newPackage : "com.some.package"
"rebase" : ["com.some"],
"referenceAction": "update|ignore"
"module" : "new module"
}
Sources will be placed within the target package. The rebase parameter specifies prefixes of the source package that will be stripped, and then append to the new package. Unmatched packages will be moved into the new package using their entire package name.
If rebase is not defined, all sources will be moved into the new package.
newPackage a.b.c
sourcePackage x.y.z.Class
result a.b.c.Class
rebase = "x.y.z"
newPackage a.b.c
sourcePackage x.y.z.Class
result a.b.c.Class
rebase = "x.y"
newPackage a.b.c
sourcePackage x.y.z.Class
result a.b.c.z.Class
rebase = ""
newPackage a.b.c
sourcePackage x.y.z.Class
result a.b.c.x.y.z.Class
The action to perform on references to any modified packages. This will affect any files that import the package.
The target module. If unset, the same module as the source will be used.
{
"name": "Untitled Splitbrains Script",
"trigger": {
"packages": [
"tv.twelvetone.splitpoint_samples.old_package"
]
},
"source": "file",
"action": [
{
"type": "report"
},
{
"type": "repackage",
"newPackage": "tv.twelvetone.splitpoint_samples.new_package"
},
{
"type": "x-backup",
"toFolder": "splitbrains_copy"
}
],
"target": {
}
}
Trigger on import of com.vaadin.*
Source is file.
Target is new module - Vaadin Client
This will move all files that depend on Vaadin to a new module.
Next, we can move any com.mysql code to a sql module.