An IntelliJ-based IDE plugin for performing Python AST transformations using PSI elements. You can use this plugin as a library or as a tool to work with Python PSI. The differences between these options can be found below.
- Anonymization
- Augmented Assignment
- Comments Removal
- Comparison Unification
- Constant folding
- Dead Code Removal
- EmptyLinesRemoval
- Expression Unification
- If Statement Redundant Lines Removal
- Multiple Operator Comparison
- Multiple Target Assignment
- Outer Not Elimination
Just clone the repo by git clone https://github.com/JetBrains-Research/ast-transformations
.
Run the command ./gradlew :ast-transformations-plugin:cli -Pinput=<Input directory with python files> -Poutput=<Output directory>
.
All transformations will be applied.
You can use this plugin as a library in your plugin by importing it in settings.gradle.kts
and build.gradle.kts files
:
- File
settings.gradle.kts
:
sourceControl {
gitRepository(URI.create("https://github.com/JetBrains-Research/ast-transformations.git")) {
producesModule("org.jetbrains.research.ml.ast.transformations:ast-transformations")
}
}
- File
build.gradle.kts
:
implementation("org.jetbrains.research.ml.ast.transformations:ast-transformations") {
version {
branch = "master"
}
}
The available features:
- Forward transformations
- Backward transformations (unstable)
All usage examples can be found in the test folder.