MCPcopy Index your code
hub / github.com/JetBrains-Research/RefactorInsight

github.com/JetBrains-Research/RefactorInsight @2.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 2.0.0 ↗ · + Follow
1,124 symbols 3,634 edges 251 files 146 documented · 13%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

JB Research License pipeline status Downloads

Gradle IntelliJ Plugin

RefactorInsight Plugin

RefactorInsight is a plugin for IntelliJ IDEA that enhances the representation of code changes with refactoring information in Java and Kotlin projects.

RefactorInsight relies on RefactoringMiner and kotlinRMiner for retrieval of refactorings.

The plugin is compatible with IntelliJ IDEA 2023.1 and is available for free on JetBrains Marketplace.

Table of contents

Features

Smart diff

RefactorInsight labels code diffs with information about performed refactorings. It shows close to refactoring changes and opens the corresponding code diff by click.

Code Diff

To make reviewing bug fixes or new features easier, the plugin auto folds refactorings in code diffs and shows hints with short descriptions of each refactoring. Currently, it works for the following refactoring types: Move Method, Pull Up/Push Down Method, Extract Method, and Inline Method.

Example

Hide non-functional changes

RefactorInsight provides a possibility to collapse refactoring changes in code diffs allowing users to focus on functional changes.

Example

Refactorings in commits

To see refactorings in your Git repository, go to the Git tab in IntelliJ IDEA and click the toggle button on the right.

Click a commit and then the to see the refactorings detected in that commit. It looks like this:

Example

Refactorings in pull requests

To see the refactorings in a specific pull request, go to the Pull Requests tab in IntelliJ IDEA, select any pull request and click .

PullRequests

Refactoring history of an object

To see the refactoring history of a method, class, or attribute, right-click the object's signature and select Check Refactoring History. Here is an example for a method named Repl:

RefactoringHistory

Double-click a leaf node in the tree to open the VCS log at that specific commit and see a list of detected refactorings in that commit.

Settings

By default, for performance reasons, refactorings are only retrieved from the last 100 commits in the project history. This number can be adjusted in the plugin's settings. Alternatively, you can use Mine All Refactorings on the Tools menu to go through all commits in the history of your project. The plugin also keeps track of new commits and processes them.

Build instructions

You need to install Java 17 and IntelliJ IDEA. The project structure consists of several modules: * common — adapters for entities from RefactoringMiner and kotlinRMiner; * java-impl — handlers of refactorings performed in Java; * kotlin-impl — handlers of refactorings performed in Kotlin; * plugin — UI components (actions, toggles, diffs); * runner — runners for refactoring detection that could be used in external plugins.

Available Run configurations could be found in Gradle → Run Configurations: * Build Plugin — builds the plugin; * Run Plugin — runs an IDE instance with pre-installed plugin.

Contribution and feedback

You are welcome to submit a bug report or suggest a feature: open an issue. Pull requests are also welcome and encouraged.

For more information about the tool on which RefactorInsight relies to identify refactorings, read RefactoringMiner 2.0.

Citing RefactorInsight

A paper about RefactorInsight was presented at ASE'21. If you use RefactorInsight in your academic work, please cite it.

@article{kurbatova2021refactorinsight,
  title={Refactorinsight: Enhancing ide representation of changes in git with refactorings information},
  author={Kurbatova, Zarina and Kovalenko, Vladimir and Savu, Ioana and Brockbernd, Bob and Andreescu, Dan 
  and Anton, Matei and Venediktov, Roman and Tikhomirova, Elena and Bryksin, Timofey},
  journal={arXiv preprint arXiv:2108.11202},
  year={2021}
}

Extension points exported contracts — how you extend this code

FoldingHandler (Interface)
(no doc) [10 implementers]
plugin/src/main/java/org/jetbrains/research/refactorinsight/folding/handlers/FoldingHandler.java
Engine (Interface)
(no doc) [1 implementers]
plugin/src/test/testData/example-refactorings/src/main/java/vehicles/components/carComponents/Engine.java
Vehicle (Interface)
(no doc) [1 implementers]
plugin/src/test/testData/miningService/commit_15/src/moved/misc/Vehicle.java

Core symbols most depended-on inside this repo

createCodeRangeFromJava
called by 177
java-impl/src/main/java/org/jetbrains/research/refactorinsight/data/util/JavaUtils.java
setGroup
called by 138
common/src/main/java/org/jetbrains/research/refactorinsight/data/RefactoringInfo.java
addMarking
called by 116
common/src/main/java/org/jetbrains/research/refactorinsight/data/RefactoringInfo.java
setNameBefore
called by 97
common/src/main/java/org/jetbrains/research/refactorinsight/data/RefactoringInfo.java
setNameAfter
called by 97
common/src/main/java/org/jetbrains/research/refactorinsight/data/RefactoringInfo.java
setDetailsBefore
called by 83
common/src/main/java/org/jetbrains/research/refactorinsight/data/RefactoringInfo.java
setDetailsAfter
called by 83
common/src/main/java/org/jetbrains/research/refactorinsight/data/RefactoringInfo.java
getName
called by 77
common/src/main/java/org/jetbrains/research/refactorinsight/adapters/Refactoring.java

Shape

Method 861
Class 252
Enum 8
Interface 3

Languages

Java100%
Kotlin1%

Modules by API surface

common/src/main/java/org/jetbrains/research/refactorinsight/data/RefactoringInfo.java66 symbols
common/src/main/java/org/jetbrains/research/refactorinsight/data/RefactoringLine.java24 symbols
plugin/src/main/java/org/jetbrains/research/refactorinsight/ui/DiffHintLineMarkerProvider.java22 symbols
plugin/src/main/java/org/jetbrains/research/refactorinsight/ui/windows/DiffWindow.java21 symbols
plugin/src/main/java/org/jetbrains/research/refactorinsight/services/MiningService.java21 symbols
common/src/main/java/org/jetbrains/research/refactorinsight/diff/MoreSidedDiffRequestGenerator.java17 symbols
plugin/src/main/java/org/jetbrains/research/refactorinsight/actions/ComboBoxRefactoringAction.java16 symbols
common/src/main/java/org/jetbrains/research/refactorinsight/data/RefactoringEntry.java16 symbols
plugin/src/main/java/org/jetbrains/research/refactorinsight/pullrequests/PRFileEditor.java15 symbols
plugin/src/main/java/org/jetbrains/research/refactorinsight/ui/windows/RefactoringHistoryToolbar.java13 symbols
plugin/src/main/java/org/jetbrains/research/refactorinsight/processors/CommitMiner.java12 symbols
common/src/main/java/org/jetbrains/research/refactorinsight/utils/Utils.java12 symbols

For agents

$ claude mcp add RefactorInsight \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact