Over the years, researchers have developed a solid toolset to analyse Java software systems. JavaFyPy enables adapting these tools to Python.
JavaFyPy creates a Python AST that the Java AST mining tools can process. The above diagram shows the steps of AST transformation performed by JavaFyPy.
This repositoy presents all the above tools
You can follow the following steps to adapt Java AST mining tools to Python.
-
JPythonParser is a Python parser developed in Java. You can use the class PyASTParser to create the initial AST of the Python code
content
as below.mod ast = PyASTParser.parsePython(content);
-
Then the class
PythonASTUtil:createPyCompilationUnit
in SyntaxtTranformer transforms the syntax and augments the AST with type information using theTypeAugmentor
. You can use the type information in https://github.com/mlcodepatterns/PythonTypeInformation for type augmentation. -
As the next step, migrate the existing Java parser of your tool to our eclipse JDT parser provided in CustomizedEclipseJDT
Using JavaFyPy, we adapted Java RefactoringMiner and CPATMiner to Python. We provide two example usages below.