A plugin for PyCharm that takes the recurrent change patterns and highlights potential places for their application in the developer’s code editor. We use graph-based code change representations gathered from 120 GitHub repositories by Python Change Miner.
Behind the scenes, the plugin runs an inspection which builds isomorphic mappings between fine-grained Program Dependence Graphs of the mined patterns and a similar graph of your code and then suggests a relevant quick-fix to apply for the highlighted code fragment.
At first, clone this repository and open the root folder.
Build the plugin from sources and go:
- Run
./gradlew :plugin:buildPlugin
- Check out
./plugin/build/distributions/plugin-*.zip
- Install the plugin in your PyCharm 2020.3.3 via
File
-Settings
-Plugins
-Install Plugin from Disk...
Quick IDE launch for evaluation:
- Run
./gradlew :plugin:runIde
- Open any Python file with functions, possibly containing mined code patterns
- You can find a test project for evaluation here
- Wait until the code analysis is complete
- Check out
WARNING
messages
- Let's say you've already mined patterns using Python Change Miner.
- Select the ones you need to automate and put them in a separate folder. Make sure each pattern is represented by a
directory and contains all the necessary files as they were provided by the miner (
fragment-*.dot
,sample-*.html
, ...). - Run the preprocessing script via:
./gradlew :preprocessing:cli -Psrc=path/to/patterns/dir/ -Pdst=path/to/destination/dir/ -PaddDescription
- Gradle task arguments:
-Psrc
: Path to input directory with the patterns mined by the miner (always required)-Pdst
: Path to output directory for processed patterns (always required)-PaddDescription
: If you want to add description for each pattern manually (optional)
- Gradle task arguments:
- Follow the instructions in the command line (actually, you only need to provide tooltip annotations for the patterns, because all the other preparation tasks will be done automatically).
- Finally, each preprocessed pattern's folder should contain 4 files:
graph.dot
: an actual graph of the patternactions.json
: edit actions stored by GumTree when it processes corresponding commits of a change patternlabels_groups.json
: matched nodes and groups of labels for all the variables in the graph, to be used for localization in the IDEdescription.txt
: textual description you provided when the pattern was processed; they can explain the reason why a developer may be interested in this type of code change
- When you are finished, just copy preprocessed patterns from the destination directory to
./plugin/src/main/resources/patterns
and re-build the plugin.
If you have any questions or suggestions, don't hesitate to open an issue or contact the developers at oleg.smirnov@jetbrains.com