Open rodrigo-brito opened 3 years ago
I will try to work on it during the week, but if you found some solution for this, please comment here.
I ran the code in your repo https://github.com/rodrigo-brito/refactoring-python-example/blob/master/main.py and I got the below results. The relationships in root are identified correctly and of type USE. Should it not work now and identify the Extract_Method correctly?
No, in this example, we have four relationships: /main.py USE /calculator.py/Calculator/summary /main.py USE /calculator.py/Calculator/multiply, /main.py USE /main.py/printIsEven, /main.py/printIsEven USE /main.py/isEven
Also, The Address is not unique, we have:
@Mosallamy, In my computer I got a single relationship. Does your printscreen represent the last commit?
@rodrigo-brito yes it is up-to date
Hi @rodrigo-brito, Currently I think there are multiple things that I have identified and should be fixed
File
type should have function calls
, and I will try to fix it, should Class
also have one too?relationships
, n1
and n2
right?getFilesFromPath
? I tried to make a function based of what I understood from the name but it doesn't seem to work.Hi @QassemNa
should Class also have one too?
I think that in Python we are unable to make function calls in a Class outside a function body, right? So I don't think you need to do it.
Just to make sure when you said uniquely identified between different commits
A string with location/name is ok (actual format). A numeric ID that can be problematic. It is difficult to keep it the same for each CST Node between different commits. This is used only in that part of building function calls
Do you have the code for the function getFilesFromPath?
I think it is an internal function of RefDiff, I will take a look on this.
Ok thanks, I will start working on that.
Hello @rodrigo-brito , I have been able to extract the refactoring inline
and extract
but now I have been facing a problem with rename
, it still shows rename but it is not reliable, like if I run it in your repo for python example it would show me all refactoring except rename. But at times it would show them, from what I have seen it works great with class rename
If you want to take a look and try it out yourself you can see the code in my account.
That is great! The rename refactoring just checks the simpleName
field. I will try to check with your example today and report here. Maybe, I will take look on it at night.
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:
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: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 forsummary
,multiply
, andprintIsEven
. Also,printIsEven
should contains a function call forisEven
function.For this example,
functionCalls
must be something like this:If it is done, I think all other refactorings will work.