mosallamy / refdiff-python Goto Github PK
View Code? Open in Web Editor NEWPython refactoring extraction tool for GitHub commit history
Python refactoring extraction tool for GitHub commit history
I found some issues with function calls
The parser identifies the function calls very well, but this relationship is not defined in nodes.
To extract and inline function works, we need to create relationships with the nodes:
root.getRelationships().add(new CstNodeRelationship(CstNodeRelationshipType.USE, caller.getId(),
nodeByAddress.get(functionCall).getId()));
In RefDiff we have two relationships to setup up (USE for call functions and SUBTYPE for inheritance)
We have the information to construct the USE
relationship. But, it is difficult to identify nodes. The snippet above uses a map that contains all nodes found in the parser step, in which the KEY of the map should be a unique identifier for each node. For the following example https://github.com/rodrigo-brito/refactoring-python-example/blob/master/main.py, it should look like:
{
/main.py: <CST Node of main.py>,
/main.py/isEven: <CST Node of isEven function>,
/main.py/printIsEven: <CST Node of printIsEven function>,
/calculator.py: <CST Node of calculator.py>,
/calculator.py/Calculator: <CST Node of Calculator Class>,
/calculator.py/Calculator/summary: <CST Node of summary Function>,
/calculator.py/Calculator/multiply: <CST Node of multiply Function>,
}
The KEY format is free, but it should be equal between commits. Then, a good way to construct this key could be joining Parent KEY + Node name.
And functionCalls
map, should contain the relationship between these unique IDs. For example, in the example repository. The CST Node /main.py
should contain function calls for summary
, multiply
, and printIsEven
. Also, printIsEven
should contains a function call for isEven
function.
For this example, functionCalls
must be something like this:
{
/main.py: [
/calculator.py/Calculator/summary,
/calculator.py/Calculator/multiply,
/main.py/printIsEven,
],
/main.py/printIsEven: [
/main.py/isEven
]
}
If it is done, I think all other refactorings will work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.